您的位置:首页 > 其它

我的第一个MFC程序...

2010-02-02 16:22 267 查看
#include <windows.h>
LRESULT CALLBACK WinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg) {
case WM_CHAR:
MessageBox(hwnd, "KeyBoard Press", "MessageBox", MB_OK);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd, "Mouse Clicked", "MessageBox", MB_OK);
break;
case WM_CLOSE:
if (MessageBox(hwnd, "是否真的结束", "MessageBox",MB_YESNO) == IDYES) {
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASS winclass;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.hCursor = LoadCursor(NULL, IDC_APPSTARTING);
winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winclass.hInstance = hInstance;
winclass.lpfnWndProc = WinProc;
winclass.lpszClassName = "Test";
winclass.lpszMenuName = NULL;
winclass.style = CS_HREDRAW | CS_VREDRAW;
RegisterClass(&winclass);
HWND hwnd;
hwnd = CreateWindow("Test", "Hello MFC", WS_OVERLAPPEDWINDOW, 100, 100, 320, 240, NULL, NULL, hInstance, NULL);
ShowWindow(hwnd, SW_SHOWNORMAL);
MSG msg;
while(GetMessage(&msg, hwnd, 0,0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}


PS:实在没有动力学这个..........
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: