TOP Win32API

int MessageBox(
    HWND hWnd,
    LPCTSTR lpText,
    LPCTSTR lpCaption,
    UINT uType
);
int MessageBoxEx(
    HWND hWnd,
    LPCTSTR lpText,
    LPCTSTR lpCaption,
    UINT uType,
    WORD wLanguageId
);

uType

Button

MB_ABORTRETRYIGNOREAbort, Retry, and Ignore.
MB_CANCELTRYCONTINUE2000/XPCancel, Try Again, Continue
MB_HELPHelp
MB_OKOK
MB_OKCANCELOK and Cancel
MB_RETRYCANCELRetry and Cancel
MB_YESNOYes and No
MB_YESNOCANCELYes, No, and Cancel

Icon

MB_ICONEXCLAMATIONexclamation-point
MB_ICONWARNINGexclamation-point
MB_ICONINFORMATION(i)
MB_ICONASTERISK(i)
MB_ICONQUESTION(?)not recommended to use
MB_ICONSTOPstop-sign
MB_ICONERRORstop-sign
MB_ICONHANDstop-sign

Default Button

MB_DEFBUTTON1first button
MB_DEFBUTTON2second button
MB_DEFBUTTON3third button
MB_DEFBUTTON4fourth button

Modality

MB_APPLMODALwait user response.default
MB_SYSTEMMODALWS_EX_TOPMOST styleserious errors
MB_TASKMODALhWnd不明でMODALにしたいとき

other options

MB_DEFAULT_DESKTOP_ONLYNT/2000/XP
MB_RIGHTright-justified
MB_RTLREADINGright-to-left reading order
MB_SETFOREGROUNDSetForegroundWindow()
MB_TOPMOSTWS_EX_TOPMOST style
MB_SERVICE_NOTIFICATIONNT/2000/XPhWnd=NULL
MB_SERVICE_NOTIFICATION_NT3XNT/2000/XP

wLanguageId

0default system language
MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL)the current language associated with the calling thread
MAKELANGID()specify a language

Return Value

Cancel/ESC

Cancel ボタン有無Cancelボタン押下ESC押下
有りIDCANCELIDCANCEL
無しN/AN/A

function fail

zero
  • extended error information: GetLastError()

function succeeds

IDOKOK button
IDCANCECancel button
IDABORTAbort button
IDCONTINUEContinue button
IDIGNOREIgnore button
IDRETRYRetry button
IDTRYAGAINTry Again button
IDYESYes button
IDNONo button

管理人/副管理人のみ編集できます