我有这个代码来加载位图:
HBITMAP reg_hbmCS = NULL;
LRESULT CALLBACK WndProc(HWND hRegWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_CREATE:
reg_hbmCS = LoadBitmap(NULL, MAKEINTRESOURCE(IDB_CSBITMAP));
if(!reg_hbmCS)
MessageBox(hRegWnd,
"No se ha podido cargar el icono del programa.\r\n"
"Pruebe a reinstalar el programa para solucionar este problema.",
"Atención", MB_ICONEXCLAMATION | MB_OK);
break;
case WM_CLOSE:
DeleteObject(reg_hbmCS);
DestroyWindow(hRegWnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hRegWnd, message, wParam, lParam);
}
return 0;
}
问题是 reg_hbmCS 不会加载,所以我没有可用的位图(它在(if !reg_hbmCS)
.
这是我的资源.h:
#ifndef RESOURCES_H
#define RESOURCES_H
#ifndef IDC_STATIC
#define IDC_STATIC -1
#endif
#define IDI_CSICO 101
#define IDB_CSBITMAP 201
#endif // RESOURCES_H
还有我的资源.rc:
#include <windows.h>
#include "resources.h"
IDI_CSICO ICON "CS-Nursing.ico"
IDB_CSBITMAP BITMAP DISCARDABLE "CS-Nursing.bmp"
如果有必要,我在 WindowsXP SP3 上使用 Code::Blocks 12.11。任何帮助都感激不尽。