[ Win32 CE API Programming for Smartphone HOME | TrajectoryLabs ]

All about MessageBox()


 
This section details the parameters of the MessageBox() function.


MessageBox (NULL, TEXT ("Hello World"), TEXT ("Hello"), MB_OKCANCEL | MB_ICONEXCLAMATION);
The MessageBox() functon is used to display simple message windows and retrieve basic input. This function is highly configurable with many different styles.


The MessageBox() function is prototyped as:

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


Study the tables below to fully customize message boxes.

MessageBox Parameters

Parameter Purpose
HWND hWnd Handle to the top-level parent window
LPCTSTR lpText Text that appears in the window
LPCTSTR lpCaption Title bar text
UINT uType Flag that specifies the MessageBox appearance (see table below)

 

Default MessageBox Flags

Flags Button or Icon
For Buttons:  
MB_OK OK
MB_OKCANCEL OK and Cancel
MB_RETRYCANCEL Retry and Cancel
MB_YESNO Yes and No
For Icons:  
MB_ICONEXCLAMATION, MB_ICONWARNING
Exclamation point
MB_ICONINFORMATION, MB_ICONASTERISK Lower case i within a circle
MB_ICONQUESTION Question mark
MB_YESNO Yes and No
MB_ICONSTOP, MB_ICONERROR
MB_ICONHAND
Exclamation point
MB_DEFBUTTON1 First button
MB_DEFBUTTON2 Second button
MB_DEFBUTTON3 Third button
The return value from MessageBox indicates the button pressed by the user.
IDOK OK button pressed
IDYES Yes button pressed
IDNO No button pressed
IDCANCEL Cancel button pressed or escape key pressed


 

SAMPLES

mb_ok
MB_OK
mb_yesno
MB_YESNO
mb_iconinformation
MB_OKCANCEL | MB_ICONINFORMATION
mb_iconexlamation
 MB_OKCANCEL | MB_ICONEXCLAMATION
mb_iconstop
MB_OKCANCEL | MB_ICONSTOP or MB_ICONHAND
mb_iconquestion
MB_OKCANCEL | MB_ICONQUESTION









Copyright © Christopher Hill (Trajecto). All rights reserved.