【发布时间】:2017-07-26 19:17:23
【问题描述】:
我有一个使用位图图像的工具栏。我使用示例文件中的通用位图,它们工作得非常好。
但是,当我尝试为此实例添加新的位图图标时,它的 close.bmp(它的大小也是正确的 16x15 像素,就像所有其他图标一样)我的程序给了我错误。
我只需要知道如何使用资源文件中的位图
错误
../../src/msw/toolbar.cpp(799): assert "Assert Failure" failed in
Realize():invalid tool button bitmap
Cant load bitmap 'close' from resources! Check.rc file.
资源.rc
new BITMAP "bitmaps/new.bmp"
open BITMAP "bitmaps/open.bmp"
save BITMAP "bitmaps/save.bmp"
help BITMAP "bitmaps/help.bmp"
close BITMAP "bitmaps/close.bmp"
.cpp
{
// Set up toolbar
enum
{
Tool_new,
Tool_open,
Tool_save,
Tool_help,
Tool_close,
Tool_Max
};
wxBitmap toolBarBitmaps[Tool_Max];
#if USE_XPM_BITMAPS
#define INIT_TOOL_BMP(bmp) \
toolBarBitmaps[Tool_##bmp] = wxBitmap(bmp##_xpm)
#else // !USE_XPM_BITMAPS
#define INIT_TOOL_BMP(bmp) \
toolBarBitmaps[Tool_##bmp] = wxBITMAP(bmp)
#endif // USE_XPM_BITMAPS/!USE_XPM_BITMAPS
INIT_TOOL_BMP(new);
INIT_TOOL_BMP(open);
INIT_TOOL_BMP(save);
INIT_TOOL_BMP(help);
INIT_TOOL_BMP(close);
toolBar->AddTool(wxID_ANY, wxT("New"), toolBarBitmaps[Tool_new], wxNullBitmap, wxITEM_NORMAL, wxT("New IWEX Project"));
toolBar->AddTool(wxID_ANY, wxT("Open"), toolBarBitmaps[Tool_open], wxNullBitmap,wxITEM_NORMAL , wxT("Open IWEX Project"));
toolBar->AddTool(idFileClose, wxT("Close"), toolBarBitmaps[Tool_close], wxT("Close button"), wxITEM_NORMAL);
toolBar->Realize();
}
【问题讨论】:
-
很奇怪。哪个 wxWidgets 版本?为了找出罪魁祸首是否是位图,请复制一个工作位图(例如“new.bmp”)并将其重命名(“close.bmp”)。
-
@MaazAzeem,你调用 InitAllImageHandlers() 了吗?