uLib  User mode C/C++ extended API library for Win32 programmers.

Module Description

Additional message box APIs...

Macros

#define MB_INFO   MB_OK| MB_ICONINFORMATION
 
#define MB_QUERY   MB_YESNO| MB_ICONQUESTION
 
#define MB_QUERYCANCEL   MB_YESNOCANCEL| MB_ICONQUESTION
 
#define MB_WARNING   MB_OK| MB_ICONEXCLAMATION
 
#define MB_ERROR   MB_OK| MB_ICONSTOP
 
#define CloseAsyncMsgBox(hBox)   SendMessage( hBox, WM_SYSCOMMAND, SC_CLOSE, 0 )
 

Functions

int __cdecl MsgBox (HWND Owner, UINT Type, CSTR Cap, CSTR Fmt,...)
 
HANDLE __cdecl AsyncMsgBox (UINT Type, PINT_PTR pResult, CSTR Title, CSTR Fmt,...)
 
HANDLE __cdecl AsyncMsgBoxEx (HWND Owner, UINT Flags, CSTR Title, HINSTANCE hInst, CSTR IconId, DWORD LangId, DWORD_PTR HelpId, MSGBOXCALLBACK Callback, PINT_PTR pResult, CSTR TextFmt,...)
 

Macro Definition Documentation

◆ MB_INFO

#define MB_INFO   MB_OK| MB_ICONINFORMATION

Ok button + Info icon.

Definition at line 1224 of file UtilFunc.h.

◆ MB_QUERY

#define MB_QUERY   MB_YESNO| MB_ICONQUESTION

Yes and No buttons + Query icon.

Definition at line 1225 of file UtilFunc.h.

◆ MB_QUERYCANCEL

#define MB_QUERYCANCEL   MB_YESNOCANCEL| MB_ICONQUESTION

Yes, No, and Cancel buttons + Query icon.

Definition at line 1226 of file UtilFunc.h.

◆ MB_WARNING

#define MB_WARNING   MB_OK| MB_ICONEXCLAMATION

Ok button + Warning icon.

Definition at line 1227 of file UtilFunc.h.

◆ MB_ERROR

#define MB_ERROR   MB_OK| MB_ICONSTOP

Ok button + Stop icon.

Definition at line 1228 of file UtilFunc.h.

◆ CloseAsyncMsgBox

#define CloseAsyncMsgBox (   hBox)    SendMessage( hBox, WM_SYSCOMMAND, SC_CLOSE, 0 )

Close an asynchronous message box programmatically.

Definition at line 1300 of file UtilFunc.h.

Function Documentation

◆ MsgBox()

int __cdecl MsgBox ( HWND  Owner,
UINT  Type,
CSTR  Cap,
CSTR  Fmt,
  ... 
)

MsgBox is a message box with printf() flavor.

Parameters
OwnerMessage box owner.
TypeMB_nn message box flags.
CapMessage box caption.
If Cap is NULL and Owner is non-NULL, the owner's caption is used
as title for the message box. If both are NULL, no title is shown.
FmtMessage text with optional printf() inserts.
The resulting string with inserts is limited to 512 chars, incl _NUL.
...Insert parameters...

Definition at line 271 of file UserUtil.cpp.

◆ AsyncMsgBox()

HANDLE __cdecl AsyncMsgBox ( UINT  Type,
PINT_PTR  pResult,
CSTR  Title,
CSTR  Fmt,
  ... 
)

AsyncMsgBox displays a non-blocking, self-threaded, message box.
This function allows you to use a message box as a kind of modeless dialog.

Parameters
TypeMB_nn MessageBox option flags.
pResult[out,opt] When the function returns, pResult, if provided, returns the MessageBox
window handle, and when the box is closed it recieves the MessageBox result.
TitleMessage box caption.
FmtMessage text with optional printf inserts.
The resulting string with inserts is limited to 512 chars, incl _NUL.
...Insert parameters...
Returns
Returns the thread handle so you may wait on it (if you wish).
Do not forget to CloseHandle() on the thread handle when done.
Warning
If you terminate the box thread, you will leak around 550 bytes.
Instead, use CloseAsyncMsgBox() on the message box window.

See also AsyncMsgBoxEx().

Definition at line 430 of file UserUtil.cpp.

◆ AsyncMsgBoxEx()

HANDLE __cdecl AsyncMsgBoxEx ( HWND  Owner,
UINT  Flags,
CSTR  Title,
HINSTANCE  hInst,
CSTR  IconId,
DWORD  LangId,
DWORD_PTR  HelpId,
MSGBOXCALLBACK  Callback,
PINT_PTR  pResult,
CSTR  TextFmt,
  ... 
)

AsyncMsgBoxEx displays a custom, non-blocking, self-threaded, message box.
This function allows you to use a message box as a kind of modeless dialog.

Parameters
Owner[optional] Message box owner.
Note: If, for some obscure reason, you want the box to block, set Owner
to non-NULL, and include MB_TASKMODAL or MB_SYSTEMMODAL in Flags.
MB_APPLMODAL blocking on Owner has been sacrificed in order to allow
non-blocking message boxes (which is the point of this function).
FlagsMB_nn MessageBox option flags.
Note: A message box that specifies MB_YESNO does not respond to
CloseAsyncMsgBox() because the system disables it's cancel button.
If you need a yes/no box use MB_YESNOCANCEL.
Title[optional] Message box caption.
If Owner is non-NULL and Title is NULL, the owner's caption is used
as title for the message box. If both are NULL, no title is shown.
hInst[optional] Instance that contains the IconId custom icon.
IconId[optional] Custom icon id (in hInst). If used, it MUST be an integer id.
If hInst+IconId are not used, a standard icon based on the MB_nn flags is used.
LangId[optional] MAKELANGID.
HelpId[optional] HELPINFO::dwContextId.
Callback[optional] Process help events for the message box.
pResult[out,opt] When the function returns, pResult, if provided, returns the MessageBox
window handle, and when the box is closed it recieves the MessageBox result.
TextFmtMessage text with optional printf inserts.
The resulting string with inserts is limited to 512 chars, incl _NUL.
...Insert parameters...
Returns
The function returns the thread handle so you may wait on it.
Do not forget to call CloseHandle() on the thread handle when done.
Note: The thread that invokes the message box will return the MessageBox result
when it exits, so you may also use GetExitCodeThread() as an alternative to pResult.
Warning
If you terminate the box thread, you will leak over 550 bytes.
Instead, use CloseAsyncMsgBox() on the message box window.
See also
See also MSGBOXPARAMS and MessageBoxIndirect() for parameter details.

Definition at line 455 of file UserUtil.cpp.