#include <stdio.h>
#include <windows.h>
LRESULT CALLBACK WindowProc(
);
HINSTANCE g_hInstance;
int WINAPI WinMain(
WNDCLASS fans;
fans.style=CS_HREDRAW | CS_VREDRAW ;
fans.lpfnWndProc=WindowProc;
fans.cbClsExtra=0;
fans.cbWndExtra=0;
fans.hInstance=hInstance;//这个就是WinMain函数的第一个参数。
fans.hCursor=LoadCursor(NULL,IDC_CROSS);
fans.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
fans.lpszMenuName=NULL;
fans.lpszClassName="Idontknow";
RegisterClass(&fans);
HWND h;
h=CreateWindow("Idontknow",
"woshinid",
WS_OVERLAPPEDWINDOW,
100,100,800,480,
NULL,NULL,
hInstance,
NULL);
while(GetMessage(&msg,NULL,0,0)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WindowProc(
PAINTSTRUCT paintinformation;
HDC hdc;
switch(uMsg)
{
case WM_LBUTTONDOWN:
break;
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_PAINT:
{
hdc=BeginPaint(hwnd,&paintinformation);
RECT rect;
GetClientRect(hwnd,&rect);
HBITMAP
bimp = (HBITMAP)LoadImage(NULL,
"C:\aa.bmp",IMAGE_BITMAP,1280,800,LR_LOADFROMFILE);
CreateCompatibleBitmap(hdc,1280,800);
HDC hh=CreateCompatibleDC(NULL);
SelectObject(hh,bimp);
BitBlt(hdc,0,0,400,200,hh,0,0,SRCCOPY);
EndPaint(hwnd,&paintinformation);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
}
ReleaseDC(hwnd,hdc);
return 0L;
}//WindowProc()函数结束