Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Rightclick and vkmenu in an editbox

Rightclick and vkmenu in an editbox

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestionhelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rozis
    wrote on last edited by
    #1

    What i try to acomplish: when the user presses VKMENU a textbox is shown. This works fine with one problem. When the editbox is shown it immidiatly also shows a contextmenu containing options for cut, paste, copy and so on. This contextmenu is also shown when you rightclick in the editbox or press vkmenu while you are in the editbox. This is standard windows behaviour. It seems that the key that triggers the code to show the editbox (vkmenu) is somehow routed to the editbox. My question: how to prevend this? Note: When the user presses vkmenu while IN the editbox the contextmenu must still be presented. Note2: When i change the code so that for example Alt-space will show the editbox the problem disappears, but that is not a solution in my case. Note3: I've been experimenting with the returnvalue of the dispatcher, without any succes so far. Any suggestions?

    C 1 Reply Last reply
    0
    • R Rozis

      What i try to acomplish: when the user presses VKMENU a textbox is shown. This works fine with one problem. When the editbox is shown it immidiatly also shows a contextmenu containing options for cut, paste, copy and so on. This contextmenu is also shown when you rightclick in the editbox or press vkmenu while you are in the editbox. This is standard windows behaviour. It seems that the key that triggers the code to show the editbox (vkmenu) is somehow routed to the editbox. My question: how to prevend this? Note: When the user presses vkmenu while IN the editbox the contextmenu must still be presented. Note2: When i change the code so that for example Alt-space will show the editbox the problem disappears, but that is not a solution in my case. Note3: I've been experimenting with the returnvalue of the dispatcher, without any succes so far. Any suggestions?

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      Show some code, how and where did you "catch" VKMENU and how did you handle it? Try adding a message handler for WM_KEYDOWN to your edit box and see if the VKMENU goes thorough there. If yes, you could either set some flag, if the flag is on, VKMENU is swalowed by your handler (does not pass it on to the __super version) and the flag is set off again, if it is off then it is passed along to the __super method. Then, when you "bring up" the edit, set the flag to on. Another aproach would be to clear the messsage queue of any incoming WM_KEYDOWN and/or WM_KEYUP messages targeted to your edit box after it has been created (you could do this using PeekMessage with PM_REMOVE specified). Don't know if any of these are doable or reliable though so if you choose to try them, be carefull... [edit] I did some experimenting, it seems that the local menu is displayed when you release the "VKMENU key" so my guess is that you catch the keydown event, bring up the edit field, set the focus to it, and then when the key is released then the keyup events goes to your edit box and tadaa, it displays the menu. Maybe try displaying your box on keyup instead of keydown if that workds for you.

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <

      R 1 Reply Last reply
      0
      • C Code o mat

        Show some code, how and where did you "catch" VKMENU and how did you handle it? Try adding a message handler for WM_KEYDOWN to your edit box and see if the VKMENU goes thorough there. If yes, you could either set some flag, if the flag is on, VKMENU is swalowed by your handler (does not pass it on to the __super version) and the flag is set off again, if it is off then it is passed along to the __super method. Then, when you "bring up" the edit, set the flag to on. Another aproach would be to clear the messsage queue of any incoming WM_KEYDOWN and/or WM_KEYUP messages targeted to your edit box after it has been created (you could do this using PeekMessage with PM_REMOVE specified). Don't know if any of these are doable or reliable though so if you choose to try them, be carefull... [edit] I did some experimenting, it seems that the local menu is displayed when you release the "VKMENU key" so my guess is that you catch the keydown event, bring up the edit field, set the focus to it, and then when the key is released then the keyup events goes to your edit box and tadaa, it displays the menu. Maybe try displaying your box on keyup instead of keydown if that workds for you.

        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Sometimes you just have to hate coding to do it well. <

        R Offline
        R Offline
        Rozis
        wrote on last edited by
        #3

        Code-o-mat wrote:

        [edit] I did some experimenting, it seems that the local menu is displayed when you release the "VKMENU key" so my guess is that you catch the keydown event, bring up the edit field, set the focus to it, and then when the key is released then the keyup events goes to your edit box and tadaa, it displays the menu. Maybe try displaying your box on keyup instead of keydown if that workds for you.

        That is exactly what happens! Good answer. So either i swalow the VKMENU in the keyup-handler, or i set up the editbox at Keyup. Sounds simple. I'll be back is that's not the solution. Thanks

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups