|
From: Philip B. <ph...@bl...> - 2008-10-12 13:53:57
|
#include <windows.h>
#include <stdio.h>
#include <commctrl.h>
#ifdef __cplusplus
extern "C" {
#endif
HWND hwnd;
/* From Msdn */
void ErrorExit(LPTSTR pszFunction)
{
LPTSTR pszMessage;
DWORD dwLastError = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dwLastError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&pszMessage,
0, NULL );
char cp[1024];
sprintf(cp, "%s failed with error %d: %s\n", pszFunction, dwLastError, pszMessage);
MessageBox(0,cp,"Error",16);
LocalFree(pszMessage);
ExitProcess(dwLastError);
}
BOOL CALLBACK DialogProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
/* May want to do things here later... */
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
/* Will want to do things here... */
default:
break;
}
return TRUE;
case WM_DESTROY:
PostQuitMessage(0);
return TRUE;
case WM_CLOSE:
DestroyWindow (hwnd);
return TRUE;
default:
return FALSE;
}
return FALSE;
}
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
{
hwnd = CreateDialog(hThisInstance, "DIALOG_0", 0, (DLGPROC)DialogProc);
if(hwnd==NULL)
{
ErrorExit("CreateDialog");
return 1;
}
MSG msg;
while(GetMessage(&msg, NULL, 0, 0))
{
if(!IsDialogMessage(hwnd, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
#ifdef __cplusplus
}
#endif
|