我的第一个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:实在没有动力学这个..........
相关文章推荐
- 新开始,第一个MFC程序
- 从零开始学MFC(1)——第一个win32程序
- 第一个自编的MFC小小程序-ASC码正反查询器-分享初学MFC!
- 第一个MFC程序编译有感
- 第一个MFC程序“Hello, World!”(vs2008)
- 我的第一个MFC程序------登录对话框简单实现
- 我的第一个MFC程序
- 第一个VTK-MFC程序
- VS2012创建MFC项目、第一个VS2012版MFC程序及MFC程序发布(release)
- 第一个MFC程序编译有感
- OSG + MFC单文档 实现第一个程序
- 第一个MFC程序搞定, 根据孙鑫的视频写的, 调试也很成功
- 终于手动做好了第一个稍微有的形状的MFC程序~一个简陋的图形绘图工具
- MFC的第一个程序Hello World, Hello MFC
- MFC-01-Chapter01:Hello,MFC---1.3 第一个MFC程序(01)
- MFC第一个例子 -- windows程序运行原理
- 我的第一个MFC程序
- 我的第一个MFC程序
- [技术学习]在Linux平台学习Windows开发技术(一)----编译第一个MFC程序
- MFC-01-Chapter01:Hello,MFC---1.3 第一个MFC程序(02)