Menu With Icons.
Moderators: Hacker, petermad, Stefan2, white
2Valentino
Thanks you very much for this information. These are really great news. I never thought Iit would be possible to increase the width and height this way. I will update my demo program.
Thanks you very much for this information. These are really great news. I never thought Iit would be possible to increase the width and height this way. I will update my demo program.
Last edited by Lefteous on 2006-11-10, 14:07 UTC, edited 1 time in total.
- StickyNomad
- Power Member
- Posts: 1933
- Joined: 2004-01-10, 00:15 UTC
- Location: Germany
- majkinetor !
- Power Member
- Posts: 1580
- Joined: 2006-01-18, 07:56 UTC
- Contact:
Some notes to all interested:
1. Menu with icons is OVERDRAWN menu. Not the BITMAP menu or STRING menu
2. For overdrawn menu, Windows calls 2 times your application - first time to return width and height of the item rectangle and second time to draw it in it.
3. You can draw anything that you like in it - large icons, small icons, per item text colors, named separators etc.
4. It is very easy to do, I even managed to make it in AHK.
5. Forget about 13 pixel bitmpas. Its for checkboxes only, not important for this.
Screenshots:
www.r-moth.com/_/menu/_clip1.png (with new hot menu break feature)
www.r-moth.com/_/menu/_clip2.png (with new hot only icons menu)
For those who want to see the code, it will be available as open source AHK soon on its forum. I am creating this as general command to be used instead AHK menu command.
This is interface I created for the new menu command
1. Menu with icons is OVERDRAWN menu. Not the BITMAP menu or STRING menu
2. For overdrawn menu, Windows calls 2 times your application - first time to return width and height of the item rectangle and second time to draw it in it.
3. You can draw anything that you like in it - large icons, small icons, per item text colors, named separators etc.
4. It is very easy to do, I even managed to make it in AHK.
5. Forget about 13 pixel bitmpas. Its for checkboxes only, not important for this.
Screenshots:
www.r-moth.com/_/menu/_clip1.png (with new hot menu break feature)
www.r-moth.com/_/menu/_clip2.png (with new hot only icons menu)
For those who want to see the code, it will be available as open source AHK soon on its forum. I am creating this as general command to be used instead AHK menu command.
This is interface I created for the new menu command
Code: Select all
#SingleInstance force
;set the constants
INIT_Menu()
;create submenus
ships := Menu_Create()
Menu_Set( ships, "s64, RFF00FF, ,L20, HFF, FArial:s14", "icons\ode.ico")
Menu_Add( ships, "Infiltrator","icons\sw\Infiltrator.ico" )
Menu_Add( ships, "Starfighter", "icons\sw\naboo.ico", "s128" )
Menu_Add( ships, "X100 - Recomended by Obi","icons\sw\obi.ico" )
Menu_Add( ships, "Imperial shuttle","icons\sw\Imperial_shuttle.ico", "B" )
Menu_Add( ships, "X-Wing", "icons\sw\xwing.ico" )
Menu_Add( ships, "Slave i-b", "icons\sw\slave.ico" )
mercs := Menu_Create()
Menu_Set( mercs, "s128, L40", "")
Menu_Add( mercs, "", "icons\sw\DarthVader.ico")
Menu_Add( mercs, "", "icons\sw\r2-d2.ico" )
Menu_Add( mercs, "", "icons\sw\BobaFett.ico" )
swords := Menu_Create()
Menu_Set( swords, "s92, h0FF0FF", "icons\back.ico")
Menu_Add( swords, "s1", "icons\sw\Qui-Gon.ico" )
Menu_Add( swords, "s2", "icons\sw\Obisaber.ico" )
Menu_Add( swords, "s3", "icons\sw\Maul2.ico" )
;create main menu -----------
SWshop := Menu_Create()
Menu_Set( swshop, "h0F11FF, cA7A7A7, m20, FVerdana:s12 bold")
Menu_Add( swshop, "Find hotel room", "icons\home.ico", "s92, i101" )
Menu_Add( swshop, "Send an e-mail", "icons\pen_red.ico" ,"S32, F :s12 italic underline" )
Menu_Add( swshop, "Enter chat", "icons\chat.ico" ,"s48, F :s12 italic underline" )
Menu_Add( swshop, "By gear", "icons\gear.ico" ,"s92" )
;Add submenu
Menu_Add( swshop, "Choose service", "" ,"D, cFFFFFF, FXirod:s12", 1 )
Menu_Add( swshop, "Buy a Ship", "icons\sw\xwing.ico" ,"FCourier New:s12 bold, s128, M" ships, 2 )
Menu_Add( swshop, "Hire a Mercenary","icons\sw\BobaFett.ico" ,"FCourier New:s12 bold, s92, M" mercs, 3 )
Menu_Add( swshop, "Buy a Sword", "icons\sw\maul.ico" ,"FCourier New:s12 bold, s92, M" swords,4 )
Menu_Add( swshop, "Other", "" ,"D, cFFFFFF, FXirod:s12", 5 )
; Menu_Delete(swshop, 5)
; Menu_Delete(swshop, 1)
return
!m::
Menu_Show( swshop, 50, 50, "MyMenuHandler")
return
MyMenuHandler:
; MsgBox Title:`t%M_Title% `nID:`t%M_ID%`nMenu:`t%M_Menu%
return
#include Menu.ahk
Habemus majkam!
I just updated my little demo program:
http://www.lefteous.de/tc/archives/iconmenu_demo/iconmenu_demo_winapi.sqx
There is no logic behind the checkmarks. There are placed morer less randomly.
Menus can be loaded with right click on the window.
Some technical remarks.
This version doesn't use VCL just directly Windows API calls and it uses standard menus (_not_ owner-drawn menus) as Valentino suggested. There are some minor drawing glitches which shouldn't be difficult to solve in a real world application. I'm not that experienced in bitmap handling. Maybe someone has a tip? Anyway it's just a demo app.
Some important things I discovered:
- A submenu needs a dummy bitmap in the same size as the other menu items. Otherwise the menu item is not resized and submenu arrow might be drawn into the text.
- The bitmap size in this example is 20x16. This is done because the distance between bitmaps and menu caption is too small by when using larger bitmaps then 13².
An alternative solution is to prepend a space character to the menu captions.
- AFAIK it won't work on Windows 95 but on all newer Windows versions.
http://www.lefteous.de/tc/archives/iconmenu_demo/iconmenu_demo_winapi.sqx
There is no logic behind the checkmarks. There are placed morer less randomly.
Menus can be loaded with right click on the window.
Some technical remarks.
This version doesn't use VCL just directly Windows API calls and it uses standard menus (_not_ owner-drawn menus) as Valentino suggested. There are some minor drawing glitches which shouldn't be difficult to solve in a real world application. I'm not that experienced in bitmap handling. Maybe someone has a tip? Anyway it's just a demo app.
Some important things I discovered:
- A submenu needs a dummy bitmap in the same size as the other menu items. Otherwise the menu item is not resized and submenu arrow might be drawn into the text.
- The bitmap size in this example is 20x16. This is done because the distance between bitmaps and menu caption is too small by when using larger bitmaps then 13².
An alternative solution is to prepend a space character to the menu captions.
- AFAIK it won't work on Windows 95 but on all newer Windows versions.
Last edited by Lefteous on 2006-11-11, 11:13 UTC, edited 1 time in total.
- majkinetor !
- Power Member
- Posts: 1580
- Joined: 2006-01-18, 07:56 UTC
- Contact:
Icons can be only done in overdrawn menus. Anything else is a wrong topic.
Inform yourself better Leftious.
Standard menus can not have icons, only checkmarks that you can change (like Favmenu has currently) at it works ok but you can have only 13x13 icons at most... stupid. The menu api is not designed to use icons in this part at all...
You can ofcoruse do some strange things like the one u are doing here...
BTW, your demo eats 100% CPU here, and I don't see any icons.
Inform yourself better Leftious.
Standard menus can not have icons, only checkmarks that you can change (like Favmenu has currently) at it works ok but you can have only 13x13 icons at most... stupid. The menu api is not designed to use icons in this part at all...
You can ofcoruse do some strange things like the one u are doing here...
BTW, your demo eats 100% CPU here, and I don't see any icons.
Habemus majkam!
2majkinetor !
There is a function SetMenuItemBitmaps where you can two bitmaps for checked and unchecked states. This is also the function Ghisler referred to the msdn documentation of this function as he wrote that monochrome bitmaps should be used.
This is not the function which I'm using in my demo application.
As Valentino suggested I'm using SetMenuitemInfo instead. In the MSDN documentation you can find 3 bitmap members in the associated structure MENUITEMINFO.
These two members seem to be the same as in SetMenuItemBitmaps although there is nothing mentioned here about color depth limitations. Anyway I'm not using these members in my demo app. I just set MFS_CHECKED. In other words I'm not using custom checkmarks.
BTW: I'm not using radio checkmarks but that's of course no problem to add.
This is the bitmap which can be used for displaying an icon. This is not really something new (introduced in Windows 98 ) but I didn't know that the menu automatically resizes to fit its content when assigned a bitmap larger than 13² pixels. Thanks to Valentino for providing this information.
Conclusion:
The only difference in my menu to the current implementation in TC is that I'm assigned a bitmap to the hbmpItem member.
There is a function SetMenuItemBitmaps where you can two bitmaps for checked and unchecked states. This is also the function Ghisler referred to the msdn documentation of this function as he wrote that monochrome bitmaps should be used.
This is not the function which I'm using in my demo application.
As Valentino suggested I'm using SetMenuitemInfo instead. In the MSDN documentation you can find 3 bitmap members in the associated structure MENUITEMINFO.
Code: Select all
HBITMAP hbmpChecked;
HBITMAP hbmpUnchecked;
BTW: I'm not using radio checkmarks but that's of course no problem to add.
Code: Select all
HBITMAP hbmpItem;
Conclusion:
The only difference in my menu to the current implementation in TC is that I'm assigned a bitmap to the hbmpItem member.
Last edited by Lefteous on 2006-11-11, 13:53 UTC, edited 1 time in total.
Sorry for thatyour demo eats 100% CPU here

http://www.lefteous.de/tc/archives/iconmenu_demo/iconmenu_demo_winapi.sqx
BTW: It wasn't related to the menu at all.
Please make sure you are starting the demo app from within TC 7.I don't see any icons.
I'm using %COMMANDER_PATH% and %COMMANDER_INI% intensively.
Now I know what was the problem!Lefteous wrote:Please make sure you are starting the demo app from within TC 7.I don't see any icons.
I'm using %COMMANDER_PATH% and %COMMANDER_INI% intensively.
You use it too intensively, I believe

I was running it from within TC7, but I have unusual TC folder organisation.
Solved by running it from clean TC7 installation.
I thought they're built into your app.Lefteous wrote:2m^2You expect my demo app to display icons although there are no icons. Well I cannot conjure the command iconsSo that's it. I have no Wcmicons.dll![]()
Why did you delete the icon library? Are there any other files that you deleted? Maybe Totalcmd.exe
Why shuldn't I detete wcmicons? I use 2 of them and don't need the rest.
- majkinetor !
- Power Member
- Posts: 1580
- Joined: 2006-01-18, 07:56 UTC
- Contact:
Hm...
I guess you used this:
I uploaded AHK code for you so you can check out the AHK source if you are interested and see how things work in real life.
Here
Run MenuTest.ahk and use ALT M shortcut. Take a look at "For Chris" folder and about.txt for some notes about the code.
I guess you used this:
ITs similar solution like with checkboxes, with possible little variations.... How large bitmaps can you set using this ?fType
Unsigned integer that contains the menu type. This can be one of the following values.
IMFT_RADIOCHECK
Displays checked menu items using a radio button mark instead of a check mark if the hbmpChecked member is NULL.
I uploaded AHK code for you so you can check out the AHK source if you are interested and see how things work in real life.
Here
Run MenuTest.ahk and use ALT M shortcut. Take a look at "For Chris" folder and about.txt for some notes about the code.
Habemus majkam!