接以前的,弹出messagebox的时候,修改其按钮文字

 
void CTestmessageboxDlg::OnButton1() 
{
	// TODO: Add your control notification handler code here
	AfxMessageBox( _T( "请看确定按钮的文字" ) );
}

WNDPROC lpfnOldProc = 0; 

LRESULT CALLBACK SCWndProc(HWND hWnd, UINT wMsg, WPARAM wParam,LPARAM lParam)
{
	
	switch (wMsg)
	{
	case WM_ACTIVATE:
		if( WA_INACTIVE == wParam )
		{
			HWND hwnd;
			TCHAR classname[ 0x200 ];

			hwnd = ( HWND )lParam;
			memset( classname, 0, sizeof( classname ) );
			GetClassName( hwnd, classname, sizeof( classname ) / sizeof( TCHAR ) );

			if( !_tcsncmp( classname, _T( "#32770" ), 6 ) )
			{
				DWORD processid;
				GetWindowThreadProcessId( hwnd, &processid );
				if( processid == GetCurrentProcessId() )
				{
					HWND hwndbutton = ::FindWindowEx( hwnd, NULL, NULL, _T( "确定" ) );
					if( hwndbutton )
					{
						::SetWindowText( hwndbutton, _T( "不  确定" ) );
					}
				}
			}
		}
		return TRUE;
		break;
		
	}  
	
	return CallWindowProc (lpfnOldProc, hWnd, wMsg, wParam, lParam); 
	
}  


BOOL CTestmessageboxDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	lpfnOldProc = ( WNDPROC )GetWindowLong( this->GetSafeHwnd(), DWL_DLGPROC );
	SetWindowLong( this->GetSafeHwnd(), DWL_DLGPROC, ( LONG )SCWndProc );

	return TRUE;  // return TRUE  unless you set the focus to a control
}

你可能感兴趣的:(c)