Question

I've made a wxPerl application which presents just a simple frame which only contains a wxMenuBar, wxPanel, wxTextCtrl and a wxStaticBitmap. The development and deployment platform is Windows XP and beyond.

The image is added to the form like this:

my $logoData = Wx::Bitmap->new(App::Resource::Images::getLogoPath(), wxBITMAP_TYPE_BMP);
my $logo = Wx::StaticBitmap->new($self, -1, $logoData);

I've had no problems displaying the image. I've made an installer with Inno Setup that adds a icon to the users' desktop. If the application gets started using that shortcut the window doesn't draw my wxStaticBitmap. Only when the application loses focus and some other window is being moved over it, only then will my wxStaticBitmap be drawn.

When starting the application from the start menu, quick start, or directly after compiling it with wxpar, or just with the perl interperter displays my wxStaticBitmap fine.

The only thing I've found is calling Refresh() and Update() on my wxFrame. After creating this wxFrame I call Show(1) and right after that Refresh() and Update(). But so far have had no luck with it.

Was it helpful?

Solution

wxStaticBitmap is derived from wxWindow, so it has both Update and UpdateWindowUI methods. What happens when you call one of those on $logo immediately after creating it?

Edit: I just tried it, and the Update* methods don't help. However, what does force it to repaint is to call SetBitmap after creating the object. Here's what I did:

my $bmp = Wx::Bitmap->new("./testcard.bmp", wxBITMAP_TYPE_BMP);
my $logo = Wx::StaticBitmap->new($frame, wxID_ANY, $bmp);
$logo->SetBitmap($bmp);

$frame is a Wx::Frame, and I just put a button in a sizer and the above code in its event handler callback.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top