Menu With Icons.

Here you can propose new features, make suggestions etc.

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
Lefteous
Power Member
Power Member
Posts: 9535
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2majkinetor !
You don't have to guess. I have explained my solution in detail above. Don't hesitate to ask if that wasn't clear.
User avatar
petermad
Power Member
Power Member
Posts: 14861
Joined: 2003-02-05, 20:24 UTC
Location: Denmark
Contact:

Post by *petermad »

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
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
User avatar
Lefteous
Power Member
Power Member
Posts: 9535
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2petermad
Is it because it is just a demo
Yes
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

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.
Habemus majkam!
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48173
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Post by *ghisler(Author) »

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.
Author of Total Commander
https://www.ghisler.com
User avatar
Stitscher
Power Member
Power Member
Posts: 1058
Joined: 2004-02-17, 12:34 UTC
Location: Hamburg, Germany

Post by *Stitscher »

Wow, good news. Thanks!

Stitscher
User avatar
Lefteous
Power Member
Power Member
Posts: 9535
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2ghisler(Author)
Thank you!
User avatar
JohnFredC
Power Member
Power Member
Posts: 886
Joined: 2003-03-14, 13:37 UTC
Location: Sarasota Florida

Post by *JohnFredC »

Yes! Thank you very much for this modernization!
Licensed, Mouse-Centric, moving (slowly) toward Touch-centric
User avatar
pdavit
Power Member
Power Member
Posts: 1529
Joined: 2003-02-05, 21:41 UTC
Location: Kavala -> Greece -> Europe -> Earth -> Solar System -> Milky Way -> Space
Contact:

Post by *pdavit »

Great news! I guess I can wait for v7.5 until a vertical bar is implemented! :P
"My only reason for still using M$ Window$ as an OS is the existence of Total Commander!"
Christian Ghisler Rules!!!
djorge
Senior Member
Senior Member
Posts: 422
Joined: 2003-07-03, 12:48 UTC
Location: Portugal

Post by *djorge »

Thank you. Waiting for TC7 pb2...
______________________
David Jorge
Personal License #117854
User avatar
StickyNomad
Power Member
Power Member
Posts: 1933
Joined: 2004-01-10, 00:15 UTC
Location: Germany

Post by *StickyNomad »

2ghisler(Author)

Great news, thanks! :D
User avatar
Lefteous
Power Member
Power Member
Posts: 9535
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2ghisler(Author)
I cannot prevent the inverse display of the images so far
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.
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 (...);
The following message handler is placed in the main window message loop. Icon size is 16² in this example.

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);
	}
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
Last edited by Lefteous on 2006-11-12, 23:11 UTC, edited 1 time in total.
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

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?
I switched to Linux, bye and thanks for all the fish!
User avatar
Lefteous
Power Member
Power Member
Posts: 9535
Joined: 2003-02-09, 01:18 UTC
Location: Germany
Contact:

Post by *Lefteous »

2SanskritFritz
The icons are cropped on the right side, maybe a theme issue?
Very strange indeed. I have tested with various themes here and could not reproduce it.
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.
User avatar
Stitscher
Power Member
Power Member
Posts: 1058
Joined: 2004-02-17, 12:34 UTC
Location: Hamburg, Germany

Post by *Stitscher »

I have tested it with Opus (I guess it is Opus, SanskritFritz?).
No problems here.

WinXp + SP2

Stitscher
Post Reply