- 论坛徽章:
- 0
|
#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="szWindowClass";
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:
AINTSTRUCT paintStruct;
HDC hdc;
hdc = BeginPaint(hWnd,&paintStruct);
EndPaint(hWnd,&paintStruct);
break;
case WM_CLOSE:
break;
case WM_DESTROY:
ostQuitMessage(0);
break;
default:
DefWindowProc(hWnd,uMsg,wParam,lParam);
}
return 0;
}
|
|
|