|
程序代码
/*
filename: HelloWin.c
des: show a MessageBox
*/
#include <windows.h>
LRESULT CALLBACK WinProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static char szAppName[] = "HelloWin";
HWND hwnd;
MSG msg;
MwRegisterButtonControl(NULL);
RegisterWndClass(WinProc, szAppName);
hwnd = CreateWindowEx(0L, szAppName, "Hello", WS_OVERLAPPEDWINDOW
| WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, 240, 320,
NULL, NULL, NULL, NULL);
ShowWindow(hwnd, iCmdShow);
UpdateWindow(hwnd);
while ( GetMessage(&msg, NULL, 0, 0) ) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
LRESULT CALLBACK WinProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
{
switch (iMsg) {
case WM_CREATE:
MessageBox(hwnd, "Hello World!");
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,iMsg,wParam,lParam);
}
return (0);
}
|