I have source for "icon" menus. If there is enough interest I'll post the source and link to it here. The code will work on Win95/98/ME/2000/XP beta... Posted on 2001-02-20 12:37:00 by Xtreme
Allow me to be the first to express interest. :D
_Shawn is interested :D
I am also interested. I want to see how it is done and if I understand it afterwards :P Stefan
Hi, If someone want, I made also a little prog which do that (just with one bitmap, but it the same thing for several items). It is only a window, with a menu, with a bitmap inserted in an item; it does nothing. Vom-bonjour:-() PS;just go on my site (just look above) and download it in the English section (if you're English)
Yeah, i remember checking out Vom-bonjour source code last week, it is very good and easy to understand. I think he was the first. But thats no reason not to post yours. You need to set up a website, and then you can post all your source code on their, like i have at asmsource.8k.com.
Yes I would ove the source XTreme, what are you using Owner Drawn Menus? It would be a good learning example for me anyhow, right now I'm just replacing the check mark bitmaps on the menus which works OK... but not good enough for what I want to accomplish! Thanks, Ben P.S. How's your COM and Web Browser control stuff going?
The sample is up. Download Here The Web Browser stuff is coming along but its not quite prime time yet... Xtreme
Ummm... this example won't run on all OS' it has several OS dependant API calls... Have you tested this on all Windows OS'? My API referenxe says some of your code won't run on NT. - Ben
The following functions are called in this sample. Some functions aren't available to NT 3.1 but it will run on: 95/NT 4.0+/98/ME/2000/XP beta USER32.LIB ---------- MessageBox DispatchMessage TranslateMessage GetMessage ShowWindow MoveWindow GetSystemMetrics CreateWindowEx RegisterClass LoadCursor LoadIcon AppendMenu CreatePopupMenu CheckMenuItem TrackPopupMenuEx ClientToScreen DefWindowProc ReleaseDC LoadBitmap GetDC PostQuitMessage DestroyIcon DrawText DrawIconEx LoadImage GetSysColorBrush GetSysColor GDI32.LIB ----------- GetStockObject CreateFont GetDeviceCaps LineTo MoveToEx CreatePen CreateCompatibleBitmap CreateCompatibleDC DeleteObject PatBlt SetTextColor BitBlt SelectObject SetBkMode
My fault.... NT4 requires service packs to run many of the GetSysColor and GetSysBrush API calls. But it will work according the the VC++ documentation which comes with MSVC++ version 6.0, but the Win32 API reference says it wouldn't... Thanks anyhow! BTW I'm having trouble retrieving the text of the menu's, I'm trying to use it on normal menu's (Not popups) So I simply set the Owner Redraw flag on WM_CREATE and the menu item get's painted properly as far as the icon and stuff but the text doesn't show? Any ideas? I'm working on it now but it appears it only gives the text under certain circumstances. See ya, Ben
Alrighty I believe I've figured it out. It wants at least on of the "parent" menus to be OWNERDRAWN as well. So for example if I want the open command to be owner drawn it also want the heading file to be owner drawn. Make sense? That's the only way it's worked so far... See ya, Ben
An impressive example, some coding tricks in there as well that could be useful to learn.. The 'assume' directive is foriegn to me, but its obvous what its purpose is. Thanx alot NaN
Thanks for the great code! Because I'll be using this in my programs I'd like to contribute too. Here the updated WM_MEASUREITEM routine. It measures the width of the text instead so that it can accomodate (sp?) anything you put in your menus from long URL's to short 3 letter words. I left the height at 20 for a couple reasons but if you want you could use GetSystemMetrics to retrieve the value of SM_CYMENU which is pretty close otherwise use the height of the text! Hope this helps someone!
See ya, Ben
.elseif uMsg == WM_MEASUREITEM .if wParam == 0 mov edi, lParam assume edi:ptr MEASUREITEMSTRUCT invoke lstrlen, .itemData mov .CtlID,eax invoke GetDC, hWnd mov hTempDC, eax invoke GetTextExtentPoint32, hTempDC, .itemData, .CtlID, addr menuSizeStruct invoke ReleaseDC, hWnd, hTempDC m2m .itemWidth, menuSizeStruct.lcx mov .itemHeight, 20 .endif return 1
Ben, Don't forget to select the correct font onto the TempDC so GetTextExtentPoint32 can measure correctly. Also note that menuSizeStruct is of type SIZE which is not defined in the MASM32 toolkit. ...mov hTempDC, eax invoke SelectObject, hTempDC, hMnuFont invoke GetTextExtentPoint32, hTempDC, .itemData, .CtlID, addr menuSizeStruct... PS: When I set the width of my menu items to 0 I can still see the icon and the first letter of each item. Is this normal??? Xtreme This message was edited by Xtreme, on 2/22/2001 3:41:25 AM
Your write about the font, I removed all special font stuff from my program though that's why I didn't use that. The struct size must be defined your self except two problems "SIZE" is a reserved word in masm and the first variable in the structure is name "cx" which is a register. So I made my own structure called SIZESTRUCT which looks like this: SIZESTRUCT STRUCT lcx dd ? lcy dd ? SIZESTRUCT ENDS which is slightly different than the defined structure but works fine. See ya, Ben