Page 5 of 10

Posted: 2006-11-11, 16:30 UTC
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.

Posted: 2006-11-11, 16:56 UTC
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

Posted: 2006-11-11, 16:59 UTC
by Lefteous
2petermad
Is it because it is just a demo
Yes

Posted: 2006-11-11, 18:45 UTC
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.

Posted: 2006-11-12, 18:18 UTC
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.

Posted: 2006-11-12, 18:20 UTC
by Stitscher
Wow, good news. Thanks!

Stitscher

Posted: 2006-11-12, 18:47 UTC
by Lefteous
2ghisler(Author)
Thank you!

Posted: 2006-11-12, 19:04 UTC
by JohnFredC
Yes! Thank you very much for this modernization!

Posted: 2006-11-12, 19:43 UTC
by pdavit
Great news! I guess I can wait for v7.5 until a vertical bar is implemented! :P

Posted: 2006-11-12, 20:08 UTC
by djorge
Thank you. Waiting for TC7 pb2...

Posted: 2006-11-12, 20:13 UTC
by StickyNomad
2ghisler(Author)

Great news, thanks! :D

Posted: 2006-11-12, 20:46 UTC
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

Posted: 2006-11-12, 21:00 UTC
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?

Posted: 2006-11-12, 21:05 UTC
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.

Posted: 2006-11-12, 21:19 UTC
by Stitscher
I have tested it with Opus (I guess it is Opus, SanskritFritz?).
No problems here.

WinXp + SP2

Stitscher