dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 21

Thread: Cheking Menu State : problem without solution ?

  1. #1
    Join Date
    Mar 2010
    Posts
    37

    Cheking Menu State : problem without solution ?

    I'm writing a program which needs to access to the menu of another application and then check the state (checked or not) of a particular item of this menu.
    I have tried to use GetMenuItemInfo and GetMenuState but none of these functions return the right state of the menu item.
    I have done some research on the web and it seems that the problem is that the state of an item menu is updated only just before the menu is about to be displayed.
    So my question is how can I tell the other app to update it's menu at the moment I want and not only before the menu is about to be displayed because I can not send a message to the other app asking it to display the menu every time I want to check an item. This will be very disturbing for the user.

  2. #2
    Join Date
    Mar 2010
    Posts
    37

    Re: Cheking Menu State : problem without solution ?

    no one please ???

  3. #3
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,381

    Re: Cheking Menu State : problem without solution ?

    I doubt you can achieve it.
    For example the standard way to update menu items in MFC application is to do it in response to WM_INITMENUPOPUP message. So if you could implement the "static" updating of the menus of other application it wouldn't take any affect to the popped up menus!
    Victor Nijegorodov

  4. #4
    Join Date
    Mar 2010
    Posts
    37

    Re: Cheking Menu State : problem without solution ?

    Finally I found the solution !!!
    I know other developers had the same problem, so I give here the solution and the method I used to find it. May be it can be applied to other similar problems.

    Well, I have noticed that when I clic on the menu bar (not on a menu item) just an empty space of the menubar, this was enough to update the menu state.
    So I used spy to see what are the messages sent to the window just between the moments I pushed the mouse button down and up. And then i wrote a program sending all these messages to the window of the other app.
    And it worked !
    So I started to remove the messages from my program one by one until I found the message that make the menu update.
    And this message is : WM_INITMENU !!!
    The first parameter (wParam) is the handle of the menu to be initialized (you can get it with spy) and the second parameter is not used (0).

    One important thing : you have of course to send this message to the window before accessing the menu with GetMenu ( ) !

    Hope this will help other people.

  5. #5
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,381

    Re: Cheking Menu State : problem without solution ?

    Didn't you read my post?
    Then, please, read about WM_INITMENUPOPUP Message and WM_INITMENU Message
    Victor Nijegorodov

  6. #6
    Join Date
    Mar 2010
    Posts
    37

    Re: Cheking Menu State : problem without solution ?

    Oh this thing is going to make me crazy !!!
    it worked just before I posted the message and now it doesn't work, arrrghhhhh !

    Sorry VictorN, I have read your message but I'm not sure I have understand it well.
    If I send the WM_INITMENUPOPUP or WM_INITMENU message to the other app, doesn't this force the other application to update it's menu ?

  7. #7
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,381

    Re: Cheking Menu State : problem without solution ?

    No!
    Victor Nijegorodov

  8. #8
    Join Date
    Mar 2010
    Posts
    37

    Re: Cheking Menu State : problem without solution ?

    so this problem has no solution ?

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,381

    Re: Cheking Menu State : problem without solution ?

    Quote Originally Posted by neoneuf View Post
    so this problem has no solution ?
    Which one?
    And what for?
    Victor Nijegorodov

  10. #10
    Join Date
    Mar 2010
    Posts
    37

    Re: Cheking Menu State : problem without solution ?

    Quote Originally Posted by VictorN View Post
    Which one?
    And what for?
    I'd like to know if a particular menu item of another application is checked or not. Is there any way to achieve this ?

  11. #11
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,381

    Re: Cheking Menu State : problem without solution ?

    Quote Originally Posted by neoneuf View Post
    ... if a particular menu item of another application is checked or not.
    In which moment?
    Victor Nijegorodov

  12. #12
    Join Date
    Mar 2010
    Posts
    37

    Re: Cheking Menu State : problem without solution ?

    Quote Originally Posted by VictorN View Post
    In which moment?
    each second !

  13. #13
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,381

    Re: Cheking Menu State : problem without solution ?

    Quote Originally Posted by neoneuf View Post
    each second !
    Good answer! it's something like "not every 1 millisecond but every second!" Isn't it?

    Well the question is bing the same: what are you trying to achieve with such type "checking" of a "menu item of another application"?
    Victor Nijegorodov

  14. #14
    Join Date
    Mar 2010
    Posts
    37

    Re: Cheking Menu State : problem without solution ?

    I'm writing a new interface to an existing application but I'd like to let the possibility for users to use simultaneously the native interface of this existing application or to use mine. To maintain coherence between both interfaces I need to know if the user has checked a menu item in the other application through it's native interface.
    Of course I don't have the source code of the other application.

  15. #15
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    19,381

    Re: Cheking Menu State : problem without solution ?

    Well, then go back to the post #3
    Victor Nijegorodov

Page 1 of 2 12 LastLast

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)