Message box is a common control with many attributes. This article lists some of its common methods and its application scenarios.
1. Simple usage, without graphics
MessageBox (0, 'disagree ', 'hs', MB_ OK );
MessageBox (0, 'disagree ', 'hs', MB_OKCANCEL );
2. warning dialog box:
MessageBox (0, 'password cannot be blank, please enter password', 'Warning ', MB_ICONEXCLAMATION );
3. Prompt dialog box:
MessageBox (0, 'password cannot be blank, please be sure to enter password', 'hs', MB_ICONASTERISK and MB_ICONINFORMATION );
4. complex usage:
MessageBox (Handle, PChar ('process' + Listview1.Selected. caption + 'cannot be ended! '), PChar ('hprompt'), MB_ICONEXCLAMATION );
Common attributes
Default System icon, which can be displayed in the message box
X error MB_ICONHAND, MB_ICONSTOP, and MB_ICONERROR
? Ask MB_ICONQUESTION
! Warning MB_ICONEXCLAMATION and MB_ICONWARNING
I Information MB_ICONASTERISK and MB_ICONINFORMATION
Button format
MB_ OK default
MB_OKCANCEL confirm cancel
MB_YESNO?
Whether MB_YESNOCANCEL is canceled
Return Value
Idcancel unselect
IDNO no selected
Idok determines to be selected
Idyes is selected
Supplement:
The above message box is used in Delphi. If not, MessageBox (null, "DDD", "DDD", mb_ OK); or MessageBox (hwnd, "DDD ", "DDD", mb_ OK); hwnd is the handle of a window, or afxmessagebox is used directly.