为什么加载不了位图?
#include <windows.h>LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpszCmdLine, int nCmdShow)
{
HWND hwnd;
MSG Msg;
WNDCLASS wndclass;
TCHAR lpszTitle[]=TEXT("MyDemo3");
wndclass.style =CS_DBLCLKS;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = TEXT("MyClass");
wndclass.hbrBackground=(HBRUSH)GetStockObject(WHITE_BRUSH);
if(!RegisterClass(&wndclass))
{
MessageBox(NULL, TEXT("RegisterClass fail!"), TEXT("error"), MB_ICONERROR);
return 0;
}
hwnd=CreateWindow(
TEXT("MyClass"),
lpszTitle,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg, NULL, 0, 0))
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
LRESULT CALLBACK WndProc(HWND Hwnd, UINT message, WPARAM wParam, LPARAM iParam)
{
HDC hdc,hdcmem;
PAINTSTRUCT ps;
HBITMAP hBm;
switch(message)
{
case WM_PAINT:
hdc = BeginPaint(Hwnd,&ps);
hdcmem=CreateCompatibleDC(hdc);
hBm=(HBITMAP)LoadImage(NULL,TEXT("a.bmp"),IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
SelectObject(hdcmem, hBm);
BitBlt(hdc,10,10,600,421,hdcmem,0,0,SRCCOPY);
DeleteObject(hBm);
DeleteDC(hdcmem);
EndPaint(Hwnd,&ps);
return 0;
case WM_LBUTTONDOWN:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(Hwnd, message, wParam, iParam);
}
我的a.bmp图片放在资源文件那里