Rightclick and vkmenu in an editbox
-
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?
-
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?
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. <
-
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. <
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