1. Use of parameters
Modal mode for all windows of MB_SYSTEMMODAL, including WS_EX_TOPMOST (this style can be set separately by MB_TOPMOST)
MB_SERVICE_NOTIFICATION is displayed on the current desktop, even if no user is logged on (generally used for service)
Messagebox problems in the dialog box
Http://community.csdn.net/Expert/topic/3318/3318010.xml? Temp =. 359234.
How to Use the MB_USERICON attribute in MessageBox?
Http://community.csdn.net/Expert/topic/4193/4193253.xml? Temp =. 2414667.
3. WH_CBT hook (generally used to set the window position and modify the button text)
A) set the position of the window (http://support.microsoft.com/default.aspx? Scid = kb; en-us; 180936)
HHOOK hHook;
Lresult callback CBTProc (int nCode, WPARAM wParam, LPARAM lParam)
{
If (nCode = HCBT_ACTIVATE)
{
RECT rect;
GetWindowRect (hWnd, & rect );
MoveWindow (HWND) hWnd, 0, 0, rect. right-rect.left, rect. bottom-rect.top, TRUE );
}
Return CallNextHookEx (hHook, nCode, wParam, lParam );
}
Usage
HHook = SetWindowsHookEx (WH_CBT, CBTProc, GetModuleHandle (NULL), 0 );
MessageBox (NULL, "hello world! "," Info ", MB_ OK );
Problem list:
How to specify the pop-up location of the MessageBox box
Http://community.csdn.net/Expert/topic/3695/3695161.xml? Temp =. 1622888.
How do I set the position of the MessageBox pop-up?
Http://community.csdn.net/Expert/topic/3196/3196290.xml? Temp =. 1177027.
Position of the MessageBox pop-up box
Http://community.csdn.net/Expert/topic/4035/4035756.xml? Temp =. 9125635.
How can I change the initial position of the AfxMessageBox dialog box?
Http://community.csdn.net/Expert/topic/3519/3519806.xml? Temp =. 5104181.
B) modify button text (generally used for internationalization)
HHOOK hHook;
LRESULT _ stdcall CBTHookProc (long nCode, WPARAM wParam, LPARAM lParam)
{
If (nCode = HCBT_ACTIVATE)
{
SetDlgItemText (HWND) wParam, IDYES, "& Yes ");
SetDlgItemText (HWND) wParam, IDNO, "& No ");
SetDlgItemText (HWND) wParam, IDOK, "& OK ");
SetDlgItemText (HWND) wParam, IDCANCEL, "& Cancel ");
UnhookWindowsHookEx (hHook );
}
Return 0;
}
Usage:
HHook = SetWindowsHookEx (WH_CBT, (HOOKPROC) CBTHookProc, AfxGetInstanceHandle (), NULL );
Problem list:
Messagebox determines how to always set the Security button in Chinese and how to display English
Http://community.csdn.net/Expert/topic/4094/4094181.xml? Temp =. 3754541.
P.S. MessageBox that disappears for a while (originated from MSDN)
Void CALLBACK MessageBoxTimer (HWND hwnd, UINT uiMsg, UINT idEvent, DWORD dwTime)
{
PostQuitMessage (0 );
}
UINT TimedMessageBox (HWND hwndParent, LPCTSTR ptszMessage, LPCTSTR ptszTitle, UINT flags, DWORD dwTimeout)
{
MSG msg;
UINT idTimer = SetTimer (NULL, 0, dwTimeout, (TIMERPROC) MessageBoxTimer );
UINT uiResult = MessageBox (hwndParent, ptszMessage, ptszTitle, flags );
KillTimer (NULL, idTimer );
If (PeekMessage (& msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE )){
UiResult = 0; // Default Value
}
Return uiResult;
}
The usage is the same as MessageBox, but the DWORD parameter dwTimeout is added.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.