#include
#define ID_START 2
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK StartMenuProc (HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("WBD");
MSG msg;
HWND hwnd;
WNDCLASS wndclass;
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 10;
wndclass.cbWndExtra = 20;
wndclass.hbrBackground = (HBRUSH)GetStockObject (WHITE_BRUSH);
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon (NULL, szAppName);
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = szAppName;
if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("Need NT"), szAppName, MB_ICONERROR);
return 0;
}
hwnd = CreateWindow (szAppName, TEXT ("WBD"), WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT,
NULL, NULL, hInstance, NULL);
ShowWindow (hwnd, iCmdShow);
UpdateWindow (hwnd);
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static HINSTANCE hInstance;
static HWND hwndButton;
static RECT rect;
static int cxChar, cyChar;
HDC hdc;
PAINTSTRUCT ps;
static TCHAR szStart[] = TEXT ("Start");
switch (message)
{
case WM_CREATE:
hInstance = ((LPCREATESTRUCT)lParam)->hInstance;
cxChar = LOWORD (GetDialogBaseUnits ());
cyChar = HIWORD (GetDialogBaseUnits ());
hwndButton = CreateWindow (TEXT ("button"), szStart,
WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
30 * cxChar, 30 * cyChar,
20 * cxChar, 7 * cyChar / 4,
hwnd, (HMENU)ID_START,
((LPCREATESTRUCT)lParam)->hInstance, NULL);
return 0;
case WM_SIZE:
rect.left = 24 * cxChar;
rect.top = 2 * cyChar;
rect.right = LOWORD (lParam);
rect.bottom = HIWORD (lParam);
return 0;
case WM_PAINT:
InvalidateRect (hwnd,&rect,TRUE);
hdc = BeginPaint (hwnd, &ps);
SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT));
SetBkMode (hdc, TRANSPARENT);
EndPaint (hwnd, &ps);
return 0;
case WM_DRAWITEM:
case WM_COMMAND:
switch (LOWORD (wParam))
{
case ID_START:
DialogBox (hInstance, TEXT ("StartMenu"), hwnd, StartMenuProc);
break;
}
return 0;
case WM_DESTROY:
PostQuitMessage (0);
return 0;
}
return DefWindowProc (hwnd, message, wParam, lParam);
}
BOOL CALLBACK StartMenuProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG :
return TRUE;
case WM_COMMAND:
switch (LOWORD (wParam))
{
case IDOK:
//case IDCANCEL:
EndDialog (hDlg, 0);
return TRUE;
}
break;
}
return FALSE;
}