win32 api 显示一张位图的简单代码,释疑用的。

显示一张位图的示例代码:

 1 #include <windows.h>
 2 
 3 int WINAPI WinMain( __in HINSTANCE hInstance, __in_opt HINSTANCE hPrevInstance, __in_opt LPSTR lpCmdLine, __in int nShowCmd )
 4 {
 5     HDC hdc= GetDC(NULL);
 6     HBITMAP hmap = (HBITMAP)LoadImage(NULL,L"test.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
 7     int nRet = GetLastError();
 8     HDC memdc = CreateCompatibleDC(hdc);
 9     SelectObject(memdc,hmap);
10     BitBlt(hdc,0,0,600,500,memdc,0,0,SRCCOPY);
11     ReleaseDC(NULL,hdc);
12     DeleteObject(hmap);
13     return 0;
14 }
posted @ 2012-09-19 16:32  svolcano  阅读(451)  评论(0)    收藏  举报