I figured out how to create ownerdraw popup menu, by processing WM_MEASUREITEM and WM_DRAWITEM messages. However now I'd like to create ownerdraw menubar with ownerdraw menu items. Somthing like Office XP has, or Opera browser.
I have no clue how can this be done. Also if I am not wrong, that menubar is created as custom window which is docked right below window title bar? Is this only way to make menu bar owner draw (since its basically custom control and involves a lot of work) or I can create regular menu bar (CreateMenu) and just draw on it?
Posted on 2003-11-17 11:58:38 by Mikky
As far as I know the idea is to use a toolbar as a menu. There is an example at MSDN that apparently works though I have never managed to get it to pull down the menus properly on a mouse move. I have an example that shows it, but would have a hard time finding it because I just ended up archiving it somewhere. I'll look around.

I did manage to find the link to the example that I used at MSDN but it seems my test is gone, too bad it was nearly complete but I lost it to the blaster worm and did not have a backup.

Posted on 2003-11-17 12:29:14 by donkey
Hay doneky,
Thanks for the reference, I never did create toolbar so I need little time to work on in first.
What was the problem with your code with those menus?
Do you mean on showing menus when mouse is first clicked on one menu and then moved over others?
Posted on 2003-11-18 17:59:09 by Mikky
The only thing I had left to figure out was when a menu was down and the user moved the mouse to another menu it would dismiss the first menu and pull down the second automatically. This is not an easy thing to do, you can see in software such as Mozilla they have given up trying to get it to work. I was very close - damn blaster worm. Besides that I had every thing working perfectly, I think that Roticv saw it, I am not sure if he noticed any other problems with it. I am still hopefull of finding it on some archive soemwhere, if I do I will post the source as the only source available that did what I had managed is pay-to-see.
Posted on 2003-11-18 19:07:53 by donkey
Hi Mikky,

No luck at all in finding it, I went through all of my archives and it is lost. I was working on it at about the same time I got the Blaster worm and at the time I only backed up once a month so it is not on any of my disks. Sorry, I may rewrite it one day but not soon.
Posted on 2003-11-19 04:03:37 by donkey
Donkey thanks for the effort anyway, I see this is not that easy task so I might reconsider doing it at all. But if I do, I will post questions here since you have experience with this :)
Posted on 2003-11-19 04:42:32 by Mikky
Hi Mikky,

I threw this together from memory, it will help you get started if you want to tackle it. For the most part it works but it's still a little buggy.

See the next post for the proggie
Posted on 2003-11-19 07:50:40 by donkey
Hi Mikky,

Well, I had a bit of time over lunch to fix it up a bit. This will demonstrate some of the things you can do with a toolbar as menu application. It's pretty nice. With this there are bitmaps in the menu bar, you can move a menu with shift-drag and double clicking the menu bar will open a customize dialog. Also because this is a toolbar you can put in any type of child control you like :)

<edit>Forgot to relay the results of TrackPopupMenu to WM_COMMAND, not much of a change...</edit>

See my website for the example
Posted on 2003-11-19 12:37:45 by donkey
Hiya Donkey,
This is awesome, I think I'll never use regular menus again :)
Combined with owner-drawn menus the result should look very cool.
Right now I dont have much time but I will defenetelly study your code tomorrow.
Is it possible to make this toolbar act completelly like real menu, like invoking it on ALT button, moving through it with arrow keys on keyboard etc...?
Posted on 2003-11-19 15:30:07 by Mikky
Yes, all that is detailed in the MS article I referenced but as I said I built this from memory so I did not get around to rewriting the code for that part. This is the exact type of toolbar menu that MS uses in *all* of it's marquee software, Outlook, FrontPage, Word, IE etc... So as you can see from those programs it can react so much like a normal menu that it is difficult to notice the difference. For the keyboard I think you have only to check for the WM_MENUCHAR message in the DLL's message hook.

If you want to see something really cool, try changing the style of the toolbar:

[b]In CreateToolBar proc[/b]

invoke GetWindowLong,hToolBar,GWL_STYLE
invoke SetWindowLong,hToolBar,GWL_STYLE,eax

Menus on the bottom of Windows ! You can also make them vertical left or right ! Put them into a ReBar and have multiple menus on the same line etc...
Posted on 2003-11-19 16:42:43 by donkey
donkey, "lost it to the blaster worm"? I thought the blaster worm wasn't destructive? :confused:
Posted on 2003-11-19 17:11:41 by f0dder

donkey, "lost it to the blaster worm"? I thought the blaster worm wasn't destructive? :confused:

It wasn't - after they had discovered what it was. I got it before it became widely known and had uploads to do so I deleted all infected files just in case. I thought I had backups anyway so it turned out to be just another case of my un-natural stupidity merging with a lack of available information. If you remember around the time it came out I had posted that I already had gotten it :mad:
Posted on 2003-11-19 17:23:05 by donkey
Ah, sorry to hear that :(
I noticed a lot of connection requests on my firewall, so I set up a honeypot and analyzed the exploit code before it was widely known - then sent the trojan code off to a couple of friends, went partying, and found one of my friends analysis on bugtraq a couple of days later :)
Posted on 2003-11-19 17:35:24 by f0dder

Is it possible to make this toolbar act completelly like real menu, like invoking it on ALT button, moving through it with arrow keys on keyboard etc...?

Hi Mikky,

This one has the start of a few keyboard commands. I can't figure out how to underline the accelerators when you press ALT but the menus have accelerators 0,1,2 and 3. Left and right keys move the current hot item, escape dismisses the menu and F10 activates the menu bar at position 0. They all work but need a bit of tweaking to get them up to 100%. I put in code (commented out) to allow you to use the toolbar menu without a DLL, but the escape key does not work if you do and neither will anything else you decide to do in the DLL. Just check the comments in the source to find out which lines to change. I also colored the menus a bit for a cooler look.

It' been fun coming back to this, I had originally planned on using it in ToolBar Paint but in the end thought it was too much for 3 menus :)

See my website for the example
Posted on 2003-11-20 02:06:49 by donkey