Results 1 to 9 of 9

Thread: Changing Color of API-Created Context Menu

  1. #1

    Thread Starter
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Arrow 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 !

    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by iPrank; Dec 16th, 2005 at 04:52 PM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  2. #2

    Thread Starter
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Changing Color of API-Created Context Menu

    * Bump *
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  3. #3
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Changing Color of API-Created Context Menu

    I'm not sure what the actual problem is...
    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.

  4. #4

    Thread Starter
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Changing Color of API-Created Context Menu

    Quote Originally Posted by RhinoBull
    I'm not sure what the actual problem is...
    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 ?


    Attached Images Attached Images   
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  5. #5
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    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?

  6. #6

    Thread Starter
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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 ?
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  7. #7

    Thread Starter
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Changing Color of API-Created Context Menu

    BUMP v2.0
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  8. #8
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    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)

    Also tryied to catch WM_PAINT message, but it was never fired , maybe another kind of hook is needed here.
    Last edited by jcis; Jan 9th, 2006 at 08:53 PM.

  9. #9

    Thread Starter
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    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.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width