WinSunProc

来源:百度知道 编辑:UC知道 时间:2024/05/13 02:54:02
小弟刚学VC++,遇到点难题~请高手帮忙下,源代码如下:
#include <windows.h>
#include <stdio.h>
LRESULT CALLBACK Winsunproc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
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, // command line
int nCmdShow // show state
)
{
WNDCLASS wndcls;
wndcls.cbClsExtra=0;
wndcls.cbWndExtra=0;
wndcls.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndcls.hCursor=LoadCursor(NULL,IDC_APPSTARTING);
wndcls.hIcon=LoadIcon(NULL,IDI_APPLICATION);
wndcls.hInstance=hInstance;
wndcls.lpfnWndProc=Winsunproc;
wndcls.lpszClassName="牛逼一刀斩";
wndcls.lpszMenuN

1.
case WM_CHAR:
...
MessageBox(hwdn,szChar,"char",0);//hwnd
...

2.
case WM_LBUTTONDOWN:
...
TextOut(hdc,0,50,"我砍!"strlen("我砍!"));//"我砍!",strlen("我砍!")

3.
case WM_CLOSE:
...
break://break;

4.大括号的确有问题,你可以全选代码,按Alt+F8整理一下代码,就可以看到有的大括号不匹配了。

其他错误不知道了。。不过新手应该多错错。

case WM_CHAR:
char szChar[20];
sprintf(szChar,"char code is %d",wParam);
MessageBox(hwdn,szChar,"char",0);
break;
hwdn改hwnd
case WM_LBUTTONDOWN:
MessageBox(hwnd,"砍死你丫的","message",0);
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,0,50,"我砍!",strlen("我砍!"));
//这里最好加上 ReleaseDC(hwnd,hdc);
break;

这儿:
{while (GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
retu