2 Attachment(s)
Changing Color of API-Created Context Menu
In the attatched project I've created a small application using Moeur's HookControl OCX. The application can hook into another application's RichTextBox context menu and can add new menu items (non-Ownerdrawn).
I've found RhinoBull's code that changes color of menuitems of main menu bar. But I can not understand how to make it compatible with my app.
If possible, I don't want to add ownerdrawn menus. That will be a overkill for my project.
Is there any way to change color of Only My Format Menu and it's submenus ?
Note: In the zip file, there are 2 projects. Please first compile and run TestExe from the compiled exe.
Then run the ColorMenu project and click on the Hook button.
Now right click on the RTB of TestExe.exe
Thanks in advance ! :)
http://www.vbforums.com/attachment.p...chmentid=43539
Re: Changing Color of API-Created Context Menu
Re: Changing Color of API-Created Context Menu
I'm not sure what the actual problem is... :confused:
Are you having a trouble changing menu backcolor or displaying your own "context menu" instead of default?
Also, not sure what that ocx does but looks like too much code involved.
You may subclass WM_CONTEXTMENU message lso you would pop your menu instead - here is a subclassing sample by Randy Birch .
Once backcolor is changed any poppup menu will appear "dressed" in that color.
2 Attachment(s)
Re: Changing Color of API-Created Context Menu
Quote:
Originally Posted by RhinoBull
I'm not sure what the actual problem is... :confused:
Are you having a trouble changing menu backcolor or displaying your own "context menu" instead of default?
Also, not sure what that ocx does but looks like too much code involved.
You may subclass WM_CONTEXTMENU message lso you would pop your menu instead - here is a subclassing
sample by Randy Birch .
Once backcolor is changed any poppup menu will appear "dressed" in that color.
Thanks RB for your reply. :)
Sorry for not explaining my problem properly.
Here is my problem :
The 'target' window is a compiled application. It is a custom-made Text-To-Speech application, I don't have it it's source. I'm not sure if subclassing will work here. :(
The application displays text in a RTB, but it doesnot uses any formatting. It uses same font and style for all text. It doesn't have any zoom feature.
It is a problem for users with eyesight problem. I want to add Zoom functionality in this RTB. (EM_GETZOOM and EM_SETZOOM).
This application uses RTB's default context menu (AutoVerbMenu), so, IMO if I add more menuitems in that RTB's contextmenu, it will be easier for users to access these new features without switching to MY application window. (Also, IMHO, it will be good idea to not destroy the default contextmenu, as I don't know if the app runs any other code behind it.)
But the problem is, unlike normal TextBox, RTB doesn't uses any WM_CONTEXTMENU message. It uses WM_INITMENOPOPUP instead. The screenshot attatched is the messages I've found in Spy++ when user right-clicks on RTB.
There is no WM_CONTEXTMENU message. So, I hooked the external RTB and when I receive WM_INITMENUPOPUP message, I added my new menuitems by AddMyMenu() sub.
Then I'm tracking which menuitem is clicked. If user clicked one of MY menuitems, I'm executing it's code when I get WM_EXITMENUPOPUP
If you run the code attatched in the first post, you'll see that, it succesfully hooks into RTB and adds new menuitems.
But I want to change the color of "My Format Menu" item ( and it's submenu). And/Or add a bitmap. (pls see the attatched image).
Is it possible ?
http://www.vbforums.com/attachment.p...chmentid=43627
http://www.vbforums.com/attachment.p...chmentid=43628
Re: Changing Color of API-Created Context Menu
Once you've created your new menu item, can't you simply call SetMenuInfo to change its backcolor?
Re: Changing Color of API-Created Context Menu
I don't know how to change back color of (non-ownerdrawn) menu item. :(
What flages I need in MENUITEMINFO structure ?
Re: Changing Color of API-Created Context Menu
Re: Changing Color of API-Created Context Menu
I'm subscribed to this thread from the beggining :) , I tryied many ways to do it with not success, I think the Richtextbox Context menu in the other app doesn't allow you to paint it, or maybe its being painted but menuinfo/menuiteminfo is changed back on the RTB Paint. I think the closer I've got was showing a already colored and "iconed" Menu, but this menu must be present in the caller app (not the one with the rtb), the problem about this is that the first app is focused. It's a shame, because the rich textbox reacts well to events, but it's impossible to close the context menu with right click (that window lost the focus) :cry:
Also tryied to catch WM_PAINT message, but it was never fired :ehh: , maybe another kind of hook is needed here.
Re: Changing Color of API-Created Context Menu
I tried with many other context menus. Like Notepad/Wordpad/Desktop/Taskbar.
But I haven't succeeded to add color/icon in any case. :(