2D游戏编程2--windows高级编程
windows应用程序布局
编译流程
响应菜单事件消息
菜单消息处理实例:
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { // this is the main message handler of the system PAINTSTRUCT ps; // used in WM_PAINT HDC hdc; // handle to a device context // what is the message switch(msg) { case WM_CREATE: { // do initialization stuff here // return success return(0); } break; case WM_COMMAND: { switch(LOWORD(wparam)) { // handle the FILE menu case MENU_FILE_ID_OPEN: { // do work here } break; case MENU_FILE_ID_CLOSE: { // do work here } break; case MENU_FILE_ID_SAVE: { // do work here } break; case MENU_FILE_ID_EXIT: { // do work here } break; // handle the HELP menu case MENU_HELP_ABOUT: { // do work here } break; default: break; } // end switch wparam } break; // end WM_COMMAND case WM_PAINT: { // simply validate the window hdc = BeginPaint(hwnd,&ps); // you would do all your painting here EndPaint(hwnd,&ps); // return success return(0); } break; case WM_DESTROY: { // kill the application, this sends a WM_QUIT message PostQuitMessage(0); // return success return(0); } break; default:break; } // end switch // process any messages that we didn't take care of return (DefWindowProc(hwnd, msg, wparam, lparam)); } // end WinProc