求助
#include <stdio.h>
#include <windows.h>
LRESULT CALLBACK WinSunProc(
WNDPROC lpPrevWndFunc, // pointer to previous procedure
HWND hWnd, // handle to window
UINT Msg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // pointer to command line
int nCmdShow // show state of window
)
{
WNDCLASS wincls;
wincls.cbClsExtra=0;
wincls.cbWndExtra=0;
wincls.hbrBackground=(HBRUSH)GetStockObject(COLOR_WINDOW);
wincls.hCursor=LoadCursor(NULL,IDC_CROSS);
wincls.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wincls.hInstance=hInstance;
wincls.lpfnWndProc=WinSunProc;
wincls.lpszClassName="winmain";
wincls.lpszMenuName=NULL;
wincls.style=CS_VREDRAW|CS_HREDRAW;
RegisterClass(&wincls);
HWND hwnd;
CreateWindow("winmain","pro1",WS_OVERLAPPED,0,0,30,60,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(
WNDPROC lpPrevWndFunc, // pointer to previous procedure
HWND hWnd, // handle to window
UINT Msg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch(Msg)
{
case WM_CHAR:
char *me;
sprintf(me,"你按了%d",wParam);
MessageBox(hWnd,me,"按呀",MB_OK);
break;
case WM_LBUTTONDOWN:
HDC hdc;
hdc=GetDC(hWnd);
TextOut(hdc,0,10,"lbuttondown",strlen("lbuttondown"));
ReleaseDC(hWnd,hdc);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hWnd,"结束吗?","确认",MB_YESNO))
{
DestroyWindow(hWnd);
}
break;
case WM_PAINT:
HDC hdc1;
PAINTSTRUCT p;
BeginPaint(hWnd,&p);
TextOut(hdc1,10,20,"paint",strlen("paint"));
EndPaint(hWnd,&p);
break;
default:
return DefWindowProc(hWnd,Msg,wParam,lParam);
}
return 0;
}
编译时一直有这个错误error C2440: '=' : cannot convert from 'long (__stdcall *)(long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long),struct HWND__ *,unsigned int,unsigned int,long)' to 'long (__stdcall *)(str
uct HWND__ *,unsigned int,unsigned int,long)'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
Error executing cl.exe.
问如何改正?什么原因?