Ahmet has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
I need help; Not show the icon in popup menu items.
I have Trying 2 days this subject.
OS : Windows 7
Perl : v5.8.8 build 824
Win32::GUI : v1.06
Please help me !use strict; use warnings; use Win32::GUI qw(:all); my $MainIcon = new Win32::GUI::Icon("icon.ico"); my $MainIcon_class = new Win32::GUI::Class( -name => "Iconclass", -icon => $MainIcon, ); my $MainMenu = new Win32::GUI::Menu( 'Popup' => 'Popup', '>icontest' => "icontest", ); $MainMenu->{icontest}->Change( -class => $MainIcon_class ); my $mw = Win32::GUI::Window->new( -title => "icon test", -size => [500,300], -menu => $MainMenu ); $mw->Show(); Win32::GUI::Dialog();
Regards...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32::GUI::Menu icon problem - I need help !
by kejohm (Hermit) on Dec 14, 2010 at 03:23 UTC | |
Win32::GUI doesn't actually allow you to change the icons of menu items directly. Instead you will need to use some Win32 API functions. You can find more information about this method on the Win32::GUI mailing lists here. Unfortunately, this method only works up to Windows XP. For later versions, one method that you could use is owner-drawn menu items. Here is an example:
Update: Link fixed. | [reply] [d/l] |
by Ahmet (Novice) on Dec 14, 2010 at 06:02 UTC | |
Excellent jop. kejohm Thank you very much :) I managed to... These are my codes
But now, not show the "Transparent" png images; i have looked transparent png images in a main window with "AddGraphic" and "AddLabel" modules !!... I changed my mind ! and write this code; Basically i change the popup menu "Color" and "Transparent" problem will be solved... This my idea but not change the popup menu color !!! | [reply] [d/l] [select] |
by kejohm (Hermit) on Dec 14, 2010 at 07:55 UTC | |
The problem might where you are setting the background brush for the menu. You need to pass the handle of the brush, rather than the brush itself. So instead of this:
you need to do this:
| [reply] [d/l] [select] |
by Ahmet (Novice) on Dec 14, 2010 at 10:50 UTC | |
|
Re: Win32::GUI::Menu icon problem - I need help !
by petecm99 (Pilgrim) on Dec 13, 2010 at 20:50 UTC | |
I have not used Win32::GUI classes yet, so I'm not completely sure I know what you're trying to accomplish. However, changing the icon on a window is quite straightforward: $mw->ChangeIcon($MainIcon); Regards, petecm99 | [reply] [d/l] |
by Ahmet (Novice) on Dec 13, 2010 at 23:04 UTC | |
Thanks your answer petecm99.But i know changing the window icon, i know this. http://www.vbaccelerator.com/images/cpopmnum.gif See it this image. I want to do it, but I can not. So adding icon to popup menu item; i trying this !(but I can not). | [reply] |