64,654
社区成员
发帖
与我相关
我的任务
分享
#include<Windows.h>
#include<iostream.h>
LRESULT CALLBACK WindowFProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, LPSTR lpCmdLine,int nCmdShow)
{
WNDCLASS wndclass;
wndclass.hInstance=hInstance;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hCursor=LoadCursor(hInstance,IDC_CROSS);
wndclass.lpfnWndProc=WindowFProc;
wndclass.hIcon=LoadIcon(hInstance,IDI_ERROR);
wndclass.hbrBackground=(HBRUSH)GetStockObject(GRAY_BRUSH);
wndclass.lpszClassName="SimpWClass";
wndclass.lpszMenuName=NULL;
wndclass.style=CS_HREDRAW|CS_VREDRAW;
RegisterClass(&wndclass);
HWND hwnd;
hwnd=CreateWindow("szWindowClass","第一个窗口",WS_OVERLAPPEDWINDOW ,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
MSG msg;
while(GetMessage(&msg,hwnd,0,0)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowFProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam){
switch(uMsg){
case WM_CHAR:
break;
case WM_PAINT:
PAINTSTRUCT paintStruct;
HDC hdc;
hdc = BeginPaint(hWnd,&paintStruct);
EndPaint(hWnd,&paintStruct);
break;
case WM_CLOSE:
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
DefWindowProc(hWnd,uMsg,wParam,lParam);
}
return 0;
}
LRESULT CALLBACK WindowFProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, LPSTR lpCmdLine,int nCmdShow)
{
WNDCLASS wndclass;
wndclass.hInstance=hInstance;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hCursor=LoadCursor(hInstance,IDC_CROSS);
wndclass.lpfnWndProc=WindowFProc;
wndclass.hIcon=LoadIcon(hInstance,IDI_ERROR);
wndclass.hbrBackground=(HBRUSH)GetStockObject(GRAY_BRUSH);
wndclass.lpszClassName="SimpWClass";
wndclass.lpszMenuName=NULL;
wndclass.style=CS_HREDRAW|CS_VREDRAW;
RegisterClass(&wndclass);
HWND hwnd;
hwnd=CreateWindow("SimpWClass","第一个窗口",WS_OVERLAPPEDWINDOW ,
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0,NULL,NULL,hInstance,NULL);//这里第一参数窗口类名不对.
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);
MSG msg;
while(GetMessage(&msg,hwnd,0,0)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowFProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam){
switch(uMsg){
case WM_CHAR:
break;
case WM_PAINT:
PAINTSTRUCT paintStruct;
HDC hdc;
hdc = BeginPaint(hWnd,&paintStruct);
EndPaint(hWnd,&paintStruct);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd,uMsg,wParam,lParam);//对于未处理的消息,这里返回默认窗口处理程序
}
return 0;
}