April 20, 2024, 10:32:04 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Accelerator question

Started by Andy, April 05, 2020, 03:49:29 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

April 05, 2020, 03:49:29 AM Last Edit: April 05, 2020, 03:51:22 AM by Andy
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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

h3kt0r

April 08, 2020, 08:13:34 PM #2 Last Edit: April 08, 2020, 08:18:37 PM by h3kt0r
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.

Andy

Thanks Hecktor,

I will have a try with it today - much appreciated.

Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

Yes, that's the solution.

Thanks very much.
Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.