Dear all,
I'm having this problem when I tried to put PNG wxBitmap in a wxToolBar.
The size of the bitmap is not complete on the tool button!
Please advise me what to you~
Here is the result of the execution:
And the source code is as follows :
toolbar = new wxToolBar(this, wxID_ANY , wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL );
wxImage::AddHandler(new wxPNGHandler());
wxBitmap bmp1(wxT("../_bitmaps/GlobalIcons/FileIcon_01.png"), wxBITMAP_TYPE_PNG);
wxBitmap bmp2(wxT("../_bitmaps/GlobalIcons/FileIcon_02.png"), wxBITMAP_TYPE_PNG);
toolbar->AddTool(ID_NEW, bmp1, wxT("New file"));
toolbar->AddTool(ID_OPEN, bmp2, wxT("Open file"));
toolbar->Realize();
problem with the size of PNG wxBitmap in wxToolBar Topic is solved
In your wxWidgets directory, there is a directory called "samples". There are many samples you can build and play with.
One of them is about toolbars. You can look this sample source code to see how it works, and if your code doesn't run properly, you can try to modify the sample source to use your images, build it and see if it works or not. If it doesn't work, you may conclude there is something wrong with the code you modified, and find the solution.
One of them is about toolbars. You can look this sample source code to see how it works, and if your code doesn't run properly, you can try to modify the sample source to use your images, build it and see if it works or not. If it doesn't work, you may conclude there is something wrong with the code you modified, and find the solution.
Hi! I had that problem once, try calling wxToolBar::SetToolBitmapSize() to specify the size of your images, before adding the buttons. make shure you pass the correct size of your images.
eg.
HTH
eg.
Code: Select all
// create the toolbar
toolbar = new wxToolBar(this, wxID_ANY , wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL );
// set button image size (assuming the size is 16x16)
toolbar->SetToolBitmapSize(wxSize(16,16));
Hier Kommt die Sonne...