C++中,自行编写WindowApplication运行时为何会出现控制台窗口?我用Dev C++的
代码如下:LRESULTCALLBACKWndProc(HWNDhwnd,UINTMessage,WPARAMwParam,LPARAMlParam){HWNDbutto...
代码如下:LRESULT CALLBACK WndProc(HWND hwnd,UINT Message,WPARAM wParam,LPARAM lParam){ HWND button; static HWND edit; switch(Message){ case WM_DESTROY: PostQuitMessage(0); break; case WM_CREATE: button=CreateWindowEx(NULL,"Button","b1",WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON,10,50,70,50,hwnd,(HMENU)3301,NULL,NULL); edit=CreateWindowEx(NULL,"EDIT","asdasdsad",WS_VISIBLE|WS_CHILD|ES_MULTILINE,100,50,400,300,hwnd,(HMENU)3302,NULL,NULL); case WM_COMMAND: switch(LOWORD(wParam)){ case 3301: char a[10]; GetWindowText(edit,a,17); MessageBox(NULL,a,"Yes",MB_OK|MB_ICONINFORMATION|MB_OKCANCEL); break; default: break; } case WM_SIZE: /*MoveWindow(hwnd,0,0,600,500,false);*/ break; default: return DefWindowProc(hwnd,Message,wParam,lParam); } return 0;}int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow){ WNDCLASSEX wc; HWND hwnd; MSG msg; memset(&wc,0,sizeof(wc)); wc.cbSize=sizeof(WNDCLASSEX); wc.lpfnWndProc=WndProc; wc.hInstance=hInstance; wc.hCursor=LoadCursor(NULL,IDC_ARROW); wc.hbrBackground=(HBRUSH)(COLOR_WINDOW+1); wc.lpszClassName="WindowClass"; wc.hIcon=LoadIcon(NULL,IDI_APPLICATION); wc.hIconSm=LoadIcon(NULL,IDI_APPLICATION); if(!RegisterClassEx(&wc)){ MessageBox(NULL,"ERROR!","error",MB_ICONEXCLAMATION|MB_OK); return 0; } hwnd=CreateWindowEx(WS_EX_CLIENTEDGE,"WindowClass","Caption",WS_VISIBLE|WS_MINIMIZEBOX|WS_SYSMENU ,CW_USEDEFAULT,CW_USEDEFAULT,600,500,NULL,NULL,hInstance,NULL); if(hwnd==NULL){ MessageBox(NULL,"Error!","error",MB_ICONEXCLAMATION|MB_OK); return 0; } ShowWindow (hwnd, nCmdShow); while(GetMessage(&msg,NULL,0,0)>0){ TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam;}
如能成功解决问题,可提高悬赏,谢谢。 展开
如能成功解决问题,可提高悬赏,谢谢。 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询