开发者

Why doesn't wxPerl draw my wxStaticBitmap when I run the program from a Windows shortcut?

开发者 https://www.devze.com 2022-12-16 22:47 出处:网络
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

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 user开发者_StackOverflow中文版s' 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消