User forums > General (but related to Code::Blocks)
wxGenericStaticBitmap
spflanze:
It appears that in my circumstance default "Creating code" property for the custom element cannot be counted on to be correct. I changed this element to the string:
--- Code: ---$(THIS) = new $(CLASS)($(PARENT),$(ID),SchematicCascodeBoostBitmap,$(POS),$(SIZE),$(STYLE),$(NAME));
--- End code ---
Then I defined and insantiated SchematicCascodeBoostBitmap in the constructor as shown in this excerpt:
--- Code: ---TIAFrame::TIAFrame(wxWindow* parent,wxWindowID id)
{
const wxString Filename("Images//TIA Cascode & Bootstrap cropped.sch.png");
const wxBitmap SchematicCascodeBoostBitmap( Filename, wxBITMAP_TYPE_PNG );
//(*Initialize(TIAFrame)
...
img_Schem_Cascode_Boost = new wxGenericStaticBitmap(Panel1,ID_IMG_SCHEM_CASCODE_BOOST,SchematicCascodeBoostBitmap,wxPoint(0,0),wxDefaultSize,,_T("ID_IMG_SCHEM_CASCODE_BOOST"));
...
//*)
}
--- End code ---
The code compiles but the image does not show in the sizer. I know I have defined and instantiated SchematicCascodeBoostBitmap correctly because before I used the Custom element I used SchematicCascodeBoostBitma to add the image in the form in code I created outside of what Code::Blocks creates. I used the code automatically generated code as an example. The image displayed, but not inside the sizer.
What is missing here regarding the use of the Custom element?
BlueHazzard:
as you have found out, the "generic" control is generic. It uses the most common constructor of window classes in wxWidgets but they do not fit all needs.
--- Quote ---The code compiles but the image does not show in the sizer
--- End quote ---
From here on it is no codeblocks problem anymore, and you will need to search for help in a wx forum. We can not support this kind of questions.
--- Code: ---const wxString Filename("Images//TIA Cascode & Bootstrap cropped.sch.png");
const wxBitmap SchematicCascodeBoostBitmap( Filename, wxBITMAP_TYPE_PNG );
--- End code ---
you do not make any sanity check if the bitmap is loaded. This seems to be a bad idea for me. Here it can fail.
You can try to debug...
--- Code: ---The image displayed, but not inside the sizer
--- End code ---
So the image gets displayed but is not inside the sizer, or does not scale properly? Have you checked if the generated code is correct? Is the custom control added to your sizer? Have you set the expand flag? This is all wild guessing without code, image or video...
spflanze:
The project that shows the image outside the sizer:
http://www.mediafire.com/file/rz9prvd1ex8bcs8/TIA_Added_Schematic.zip
In this project I added that image in a wxGenericStaticBitmap object manually using as an example the code generated for the wxStaticBitmap object. This project demonstrates the code I wrote to create the wxBitmap object is working. I suspect image is outside the sizer because the wxs file needs to be edited. I hoped the Custom element would result in doing this for me.
The project that attempts to use the Custom element to add the image:
http://www.mediafire.com/file/f4ggwjkmckyq77y/TIA_Custom_Element.zip
The image does not display in the form.
I appreciate your assistance :)
BlueHazzard:
You have a custom Paint event handler activated for your generic bitmap. Remove the handler, or call the base class paint handler and the image will get displayed...
spflanze:
I found in the code where the paint event handler is activated. I commented out the line with the result that the image did appear as expected in the form.
But the line I commented out is between //(*Initialize(TIAFrame and //*) which means it is Code::Blocks managed code and so that line will be repeatedly restored when Code::Blocks overwrites it as I continue to develop the application. I need to know where to tell Code::Blocks not to include this handler. I do not see a way to do it in the Custom element's Properties tab. In its Events tab the EVT_PAINT event has --None-- for a handler. It is the same for all other events in this tab.
How do I tell Code:Blocks to exclude this handler?
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version