Menu With Icons.
Moderators: white, Hacker, petermad, Stefan2
2Lefteous
Is it because it is just a demo, or is it not possible to make the icons transparent - on my screen they all have white backgrounds:
http://madsenworld.dk/tcmd/MENU1.png
Is it because it is just a demo, or is it not possible to make the icons transparent - on my screen they all have white backgrounds:
http://madsenworld.dk/tcmd/MENU1.png
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
- majkinetor !
- Power Member
- Posts: 1580
- Joined: 2006-01-18, 07:56 UTC
- Contact:
hm....
I read Valentinos post more carefully. So you guys say that arbitrary bitmap size can be used this way? If so, the difference between overdrawn menus and this solution is flexibility. You see the menu I did is very customizable (not something required for your task though, it was simple fun for me to see possibilities).
Not sure about color depth though. I had problems with 13x13 icons.
I read Valentinos post more carefully. So you guys say that arbitrary bitmap size can be used this way? If so, the difference between overdrawn menus and this solution is flexibility. You see the menu I did is very customizable (not something required for your task though, it was simple fun for me to see possibilities).
Not sure about color depth though. I had problems with 13x13 icons.
Habemus majkam!
- ghisler(Author)
- Site Admin
- Posts: 48173
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
OK, I have now added API bitmaps to the menus. I cannot prevent the inverse display of the images so far, but the background is at least correct. I will have to test this with theming, though.
The feature will be off by default for now, and can be enabled via wincmd.ini.
The feature will be off by default for now, and can be enabled via wincmd.ini.
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
- StickyNomad
- Power Member
- Posts: 1933
- Joined: 2004-01-10, 00:15 UTC
- Location: Germany
2ghisler(Author)
All the side effects which I reported from the previous approach doesn't apply here so I can really recommend to do it this way.
The first code snippet shows that I'm storing the icon id in dwItemData (MIIM_DATA added to mask) for later use.
Setting hbmpItem to HBMMENU_CALLBACK does the trick here. It allows us to draw the icon (and nothing but the icon!) in a owner-draw handler. The rest of the menu item remains unchanged.
The following message handler is placed in the main window message loop. Icon size is 16² in this example.
The last snippet is the owner-drawn handler itself. The same icon is used for selected and normal state. It's also placed in the main window message loop.
This is of course just a demo app. The icons are of course not loaded each time in my app. It's just to make thinks clearer.
I have updated my demo app.
http://www.lefteous.de/tc/archives/iconmenu_demo/iconmenu_demo_winapi.sqx
I found a solution to this problem. The new solution is actually even simpler then the previous because you just have to draw an icon instead of providing a bitmap.I cannot prevent the inverse display of the images so far
All the side effects which I reported from the previous approach doesn't apply here so I can really recommend to do it this way.
The first code snippet shows that I'm storing the icon id in dwItemData (MIIM_DATA added to mask) for later use.
Setting hbmpItem to HBMMENU_CALLBACK does the trick here. It allows us to draw the icon (and nothing but the icon!) in a owner-draw handler. The rest of the menu item remains unchanged.
Code: Select all
MENUITEMINFO mii = {0};
mii.cbSize = sizeof (MENUITEMINFO);
mii.fMask = MIIM_BITMAP | MIIM_DATA;
mii.dwItemData = (ULONG_PTR)iconID;
mii.hbmpItem = HBMMENU_CALLBACK;
SetMenuItemInfo (...);
Code: Select all
case WM_MEASUREITEM:
{
LPMEASUREITEMSTRUCT lpMeasureItem = (LPMEASUREITEMSTRUCT) lParam;
lpMeasureItem->itemWidth = 16;
lpMeasureItem->itemHeight = 16;
}
The last snippet is the owner-drawn handler itself. The same icon is used for selected and normal state. It's also placed in the main window message loop.
Code: Select all
case WM_DRAWITEM:
{
LPDRAWITEMSTRUCT lpDrawItem = (LPDRAWITEMSTRUCT) lParam;
HICON icon = NULL;
ExtractIconEx (iconPath, lpDrawItem->itemData, NULL, &icon, 1);
DrawIconEx (lpDrawItem->hDC, lpDrawItem->rcItem.left, lpDrawItem->rcItem.top, icon, 16, 16, 0, NULL, DI_NORMAL);
}
I have updated my demo app.
http://www.lefteous.de/tc/archives/iconmenu_demo/iconmenu_demo_winapi.sqx
Last edited by Lefteous on 2006-11-12, 23:11 UTC, edited 1 time in total.
- SanskritFritz
- Power Member
- Posts: 3693
- Joined: 2003-07-24, 09:25 UTC
- Location: Budapest, Hungary
2Lefteous
Looks nice! One little problem, see screenshot:
http://img482.imageshack.us/img482/9349/screenshot13rm5.png
The icons are cropped on the right side, maybe a theme issue?
Looks nice! One little problem, see screenshot:
http://img482.imageshack.us/img482/9349/screenshot13rm5.png
The icons are cropped on the right side, maybe a theme issue?
I switched to Linux, bye and thanks for all the fish!
2SanskritFritz
Did you try other themes?
Where can I get the seem you are using?
Another reason could be certain system icon settings. Anyway my demo app is just proof of concept. Things are simplfied (hardcoded) and won't work on all machines for this reason.
Very strange indeed. I have tested with various themes here and could not reproduce it.The icons are cropped on the right side, maybe a theme issue?
Did you try other themes?
Where can I get the seem you are using?
Another reason could be certain system icon settings. Anyway my demo app is just proof of concept. Things are simplfied (hardcoded) and won't work on all machines for this reason.
Last edited by Lefteous on 2006-11-12, 21:19 UTC, edited 1 time in total.