Obviously I'm doing something wrong here, I can't get my program to respond to a Ctrl + C key press.
The menu is a context (right click menu), and works fine when selecting an option with the mouse, but not the keyboard.
The code here is in a sub classed rich edit control.
case WM_RBUTTONDOWN
POINT cursor2
GetCursorPos(cursor2)
ScreenToClient(w1.hwnd, cursor2)
CONTEXTMENU w1,cursor2.x, cursor2.y
MENUITEM "Cut",0,201
MENUITEM "Copy",0,202
ENDMENU
ADDACCELERATOR w1,@FCONTROL|@FVIRTKEY,ASC("C"),202
Tried adding in the @FSHIFT option but still nothing...
Help any one!
Thanks,
Andy.
Got a work around,
In the rich edit sub class code I have:
case WM_KEYDOWN
IF wParam = 17 'Crtl key
crtl = 1
ENDIF
And...
case WM_KEYUP
IF crtl = 1 and wParam = 67 'C
crtl = 0
CopyStringToClipboard(CutLine)
ENDIF
Is the problem because it's a context menu, or is it that the rich edit control is sub classed?
Thanks,
Andy.
Andy,
For your shortcut key to work correctly, you need a window menu (at the top).
Then you add your Menu accelerators.
After that, you can add your popup menu and map its entries to the corresponding entries in the top menu.
This means that the popup MENUITEM number (the last parameter) must match with the top level MENUITEM number.
If you don't want the top menu to be displayed in your window, you can hide it.
Thanks Hecktor,
I will have a try with it today - much appreciated.
Andy.
Yes, that's the solution.
Thanks very much.
Andy.