有..编译一直没问题
这里是代码!
#include<windows.h>
#include<stdio.h>
LRESULT CALLBACK WindowProc(HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
);
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow
)
{
WNDCLASS winclass;
winclass.cbClsExtra=0;
winclass.cbWndExtra=0;
winclass.hbrBackground =(HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.hCursor =LoadCursor(NULL,IDC_CROSS);
winclass.hIcon =LoadIcon(NULL,IDI_ERROR);
winclass.hInstance =hInstance;
winclass.lpfnWndProc =WindowProc;
winclass.lpszClassName ="wangjunren";
winclass.lpszMenuName =NULL;
winclass.style=CS_HREDRAW|CS_VREDRAW;
RegisterClass(&winclass);
HWND hwnd;
hwnd=CreateWindow("wangjunren","i am a wolf",WS_OVERLAPPEDWINDOW,0,0,600,400,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 WindowProc( HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam
)
{
switch(uMsg)
{
case WM_PAINT:
HDC hDC;
PAINTSTRUCT ps;
hDC=BeginPaint(hwnd,&ps);
TextOut(hDC,50,50,"haha",strlen("haha"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
if(IDYES==MessageBox(hwnd,"是否确定退出","box",MB_YESNO))
DestroyWindow(hwnd);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"you put the lbotton down","box",0);
HDC hdc;
hdc=GetDC(hwnd);
TextOut(hdc,0,50,"this is the test of mouse",strlen("this is the test of mouse"));
ReleaseDC(hwnd,hdc);
break;
case WM_CHAR:
char szChar[20];
sprintf(szChar,"this is%d",wParam);
MessageBox(hwnd,szChar,"box",0);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
return 0;
}