问题描述
此段代码能编译链接,但点运行按钮后没反应,望高手解答#include<windows.h>#include<stdio.h>LRESULTCALLBACKWinSunProc(HWNDhwnd,//handletowindowUINTuMsg,//messageidentifierWPARAMwParam,//firstmessageparameterLPARAMlParam//secondmessageparameter);intWINAPIWinMain(HINSTANCEhInstance,//handletocurrentinstanceHINSTANCEhPrevInstance,//handletopreviousinstanceLPSTRlpCmdLine,//pointertocommandlineintnCmdShow//showstateofwindow){WNDCLASSwc;wc.cbClsExtra=0;wc.cbClsExtra=0;wc.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);wc.hCursor=LoadCursor(NULL,IDC_CROSS);wc.hIcon=LoadIcon(NULL,IDI_ERROR);wc.hInstance=hInstance;wc.lpfnWndProc=WinSunProc;wc.lpszClassName="WeiXin2003";wc.lpszMenuName=NULL;wc.style=CS_HREDRAW|CS_VREDRAW;RegisterClass(&wc);HWNDhwnd;hwnd=CreateWindow("WeiXin2003","北京维新技术开发中心",WS_OVERLAPPEDWINDOW,0,0,600,400,NULL,NULL,hInstance,NULL);ShowWindow(hwnd,SW_SHOWNORMAL);UpdateWindow(hwnd);MSGmsg;while(GetMessage(&msg,NULL,0,0));{TranslateMessage(&msg);DispatchMessage(&msg);}return0;}LRESULTCALLBACKWinSunProc(HWNDhwnd,//handletowindowUINTuMsg,//messageidentifierWPARAMwParam,//firstmessageparameterLPARAMlParam//secondmessageparameter){switch(uMsg){caseWM_CHAR:charszChar[20];sprintf(szChar,"charis%d",wParam);MessageBox(hwnd,szChar,"WeiXin",0);break;caseWM_LBUTTONDOWN:MessageBox(hwnd,"Mouseclicked","WeiXin",0);HDChdc;hdc=GetDC(hwnd);TextOut(hdc,0,60,"计算机语言",strlen("计算机语言"));ReleaseDC(hwnd,hdc);break;caseWM_PAINT:HDChDC;PAINTSTRUCTps;hDC=BeginPaint(hwnd,&ps);TextOut(hDC,0,60,"计算机语言培训教程",strlen("计算机语言培训教程"));EndPaint(hwnd,&ps);break;caseWM_CLOSE:if(IDYES==MessageBox(hwnd,"是否真的结束","WeiXin",MB_YESNO)){DestroyWindow(hwnd);}break;caseWM_DESTROY:PostQuitMessage(0);break;default:returnDefWindowProc(hwnd,uMsg,wParam,lParam);}return0;}
解决方案
解决方案二:
懒得看你的代码了。其实你不用从头写。在VC中新建项目-Win32应用程序,会产生一个模板给你的。
解决方案三:
呵呵阅读下
解决方案四:
2L说的对,用SDK,这种模板不需要记得。
解决方案五:
楼主单步调试吧,一步步跟踪就能找到问题所在的