home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tricks of the Windows Gam…ming Gurus (2nd Edition)
/
Disc2.iso
/
vc98
/
crt
/
src
/
crtmbox.c
< prev
next >
Wrap
C/C++ Source or Header
|
1998-06-17
|
2KB
|
69 lines
/***
*crtmbox.c - CRT MessageBoxA wrapper.
*
* Copyright (c) 1995-1997, Microsoft Corporation. All rights reserved.
*
*Purpose:
* Wrap MessageBoxA.
*
*******************************************************************************/
#ifdef _WIN32
#include <awint.h>
/***
*__crtMessageBox - call MessageBoxA dynamically.
*
*Purpose:
* Avoid static link with user32.dll. Only load it when actually needed.
*
*Entry:
* see MessageBoxA docs.
*
*Exit:
* see MessageBoxA docs.
*
*Exceptions:
*
*******************************************************************************/
int __cdecl __crtMessageBoxA(
LPCSTR lpText,
LPCSTR lpCaption,
UINT uType
)
{
static int (APIENTRY *pfnMessageBoxA)(HWND, LPCSTR, LPCSTR, UINT) = NULL;
static HWND (APIENTRY *pfnGetActiveWindow)(void) = NULL;
static HWND (APIENTRY *pfnGetLastActivePopup)(HWND) = NULL;
HWND hWndParent = NULL;
if (NULL == pfnMessageBoxA)
{
HANDLE hlib = LoadLibrary("user32.dll");
if (NULL == hlib || NULL == (pfnMessageBoxA =
(int (APIENTRY *)(HWND, LPCSTR, LPCSTR, UINT))
GetProcAddress(hlib, "MessageBoxA")))
return 0;
pfnGetActiveWindow = (HWND (APIENTRY *)(void))
GetProcAddress(hlib, "GetActiveWindow");
pfnGetLastActivePopup = (HWND (APIENTRY *)(HWND))
GetProcAddress(hlib, "GetLastActivePopup");
}
if (pfnGetActiveWindow)
hWndParent = (*pfnGetActiveWindow)();
if (hWndParent != NULL && pfnGetLastActivePopup)
hWndParent = (*pfnGetLastActivePopup)(hWndParent);
return (*pfnMessageBoxA)(hWndParent, lpText, lpCaption, uType);
}
#endif /* _WIN32 */