|
我是按照孙鑫视频第一课写的,基本照抄的,但是我的程序调试失败,以下是代码:
#include <windows.h>
#include <stdio.h>
LRESULT CALLBACK WinSunProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPWSTR lpCmdLine,
int nShowCmd
)
{
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndcls.hCursor=LoadCursor(NULL,IDC_ARROW);
wndcls.hIcon=LoadIcon(NULL,IDI_ERROR);
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=WinSunProc;
wndcls.lpszClassName="youxi2012";
wndcls.lpszMenuName=NULL;
wndcls.style=CS_HREDRAW | CS_VREDRAW;
RegisterClass(&wndcls);
HWND hwnd;
hwnd=CreateWindow("youxi2012","feijiyouxi",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,800,600,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WinSunProc(
HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_CHAR:
char szChar[20];
sprintf(szChar,"char is d%",wParam);
MessageBox(hwnd,szChar,"feijiyouxi",0);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"chuji","feijiyouxi",0);
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,0,50,"·&#201;&#187;ú&#201;è&#188;&#198;&#198;&#240;&#178;&#189;",strlen("·&#201;&#187;ú&#201;è&#188;&#198;&#198;&#240;&#178;&#189;"));
ReleaseDC(hwnd,hdc);
break;
case WM_PAINT:
HDC hDC;
PAINTSTRUCT ps;
hDC=BeginPaint(hwnd,&ps);
TextOut(hDC,0,0,"·&#201;&#187;ú&#211;&#206;&#207;·",strlen("·&#201;&#187;ú&#211;&#206;&#207;·"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"&#202;&#199;·&#241;&#213;&#230;&#181;&#196;&#189;á&#202;&#248;","feijiyouxi",MB_YESNO))
{
DestroyWindow(hwnd);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
}
上面哪里有问题啊?
调试结果:
--------------------Configuration: winmain - Win32 Debug--------------------
Compiling...
winmain.cpp
G:\winmain\winmain.cpp(21) : error C2731: 'WinMain' : function cannot be overloaded
G:\winmain\winmain.cpp(15) : see declaration of 'WinMain'
&#214;&#180;&#208;&#208; cl.exe &#202;±&#179;&#246;&#180;í.
winmain.obj - 1 error(s), 0 warning(s) |
|