Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #12517

Re: Hotkey Button

From "Jamal" <noooospam@example.com>
Newsgroups comp.lang.clipper.visual-objects
Subject Re: Hotkey Button
Date 2019-06-11 17:08 -0400
Organization albasani.net
Message-ID <qdp58t$iof$1@news.albasani.net> (permalink)
References <f90474eb-9600-4e16-9c91-48d104b88a3a@googlegroups.com> <cb76027a-d091-4c76-9261-8e844524aa11@googlegroups.com> <qdidh2$1dha$1@gioia.aioe.org> <qdo57h$11r3$1@gioia.aioe.org>

Show all headers | View raw


Hi Franz,

The code I posted was tested with other controls on the dialog.

It does not work well. So, I modified the code based on Karl Heinz post:

https://groups.google.com/forum/?nomobile=true#!searchin/comp.lang.clipper.visual-objects/__RegisterHotkeys%7Csort:date/comp.lang.clipper.visual-objects/nwcaIY0Cddw/3iH-x7dTCQAJ

Additional links that you may find useful:

https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-registerhotkey
https://docs.microsoft.com/en-us/windows/desktop/inputdev/virtual-key-codes

Add the following to dialog class. You can subclass the :

METHOD Activate(oEvent) CLASS HotKeyDialog

       SUPER:Activate(oEvent)

       self:__RegisterHotkeys( true )

    RETURN nil


METHOD Deactivate(oEvent) CLASS HotKeyDialog

    SUPER:Deactivate(oEvent)

    self:__RegisterHotkeys( FALSE )

    RETURN nil

METHOD __RegisterHotkeys ( lRegister ) CLASS HotKeyDialog

   // RegisterHotKey in Win32 API:

   // _dll FUNCTION RegisterHotKey(hwnd as ptr, id as int, sfsModifiers as 
DWORD, vk as DWORD) as LOGIC PASCAL:USER32.RegisterHotKey

    IF lRegister
        RegisterHotKey(self:Handle(), 100, 0 , VK_F9)         // F9

        RegisterHotKey(self:Handle(), 101, MOD_ALT, 0x50)     // ALT + P
        RegisterHotKey(self:Handle(), 102, MOD_ALT, 0x53)     // ALT + S

        RegisterHotKey(self:Handle(), 103, MOD_CONTROL, 0x54)  // CTRL + T

        RegisterHotKey(self:Handle(), 104, MOD_SHIFT, 0x58)  // SHIFT + X

    ELSE

        UnregisterHotKey(self:Handle(), 100)
        UnregisterHotKey(self:Handle(), 101)
        UnregisterHotKey(self:Handle(), 102)
        UnregisterHotKey(self:Handle(), 103)
        UnregisterHotKey(self:Handle(), 104)
    ENDIF


    RETURN self

METHOD Dispatch( oEvent ) CLASS  HotKeyDialog

    DO CASE

    CASE oEvent:message == WM_HOTKEY
            self:OnHotKey( oEvent:wparam )
    ENDCASE

    RETURN
SUPER:Dispatch ( oEvent )

METHOD OnHotKey( dwKey ) CLASS HotKeyDialog


    DO CASE
    CASE dwKey == 100
        self:oDCKeyPressedFixedText:Value :=  "F9"
        // call your methods
    case dwKey == 101
        self:oDCKeyPressedFixedText:Value := "ALT + P"
        // call your methods
    case dwKey == 102
        self:oDCKeyPressedFixedText:Value := "ALT + S"
        // call your method of parent class
         IF IsMethodUsual(SELF:owner, #SAVEBUTTON)
                Send(SELF:owner, #SAVEBUTTON)
         ENDIF
    case dwKey == 103
        self:oDCKeyPressedFixedText:Value := "CTRL + T"
        // call your methods
    case dwKey == 104
        self:oDCKeyPressedFixedText:Value := "SHIFT + X"
        // call your methods
    ENDCASE

    RETURN self

Jamal


"Rachbauer"  wrote in message news:qdo57h$11r3$1@gioia.aioe.org...

Hi Jamal,
I tried your dispatch in a dialog win but I don't get WM_SYSKEYUP
message. What could be wrong?

Franz

Am 09.06.2019 um 09:46 schrieb Jamal:
> As I said in my previous message, you can also use the dispatch() option 
> and handle the Alt key and any key pressed.
>
> Here is a working example:
>
> METHOD Dispatch ( oEvent ) CLASS  HotKeyDialog
>
>    LOCAL lAltOn as logic
>
>
>    lAltOn := LOGIC(_cast, _and(GetKeyState(VK_MENU), SHORT(_cast, 
> 0x8000)))
>
>
>    IF oEvent:message ==  WM_SYSKEYUP .and. lAltOn
>
>      if CHR(oEvent:wparam) == "P"
>
>               ? "Alt + P Pressed"
>                // call your method
>               RETURN 1L
>      endif
>
>      if CHR(oEvent:wparam) == "S"
>               ? "Alt + S Pressed"
>               RETURN 1L
>      endif
>    ENDIF
>
>
>    RETURN SUPER:Dispatch ( oEvent )
>
>
> Jamal
>
> "Frank M"  wrote in message 
> news:cb76027a-d091-4c76-9261-8e844524aa11@googlegroups.com...
>
> Am Donnerstag, 6. Juni 2019 10:15:23 UTC+2 schrieb Frank M:
>> Hello,
>> i have noticed that when have a Button with Hotkey (in this sample ALT+P)
>>
>> HyperLabel{#PushButton1,_chr(38)+"Push",NULL_STRING,NULL_STRING}
>>
>> i have only to add Cation from Button '&Push'
>>
>> That work when click ALT+P
>>
>> But that work with only Clicking P , too ?
>>
>> I this a normal behavior? I want that only the Hotkey work with ALT+Key, 
>> not that only click Key (P) without ALT work.
>>
>> VO2.8 2838
>>
>> Regards, Frank
>
>
> Hi Jamal,
> thank you for testing.
>
> It is a lot of work to provide all windows with a menu. Does everyone have 
> the same behavior that is performed on the single key function? There must 
> be a solution for it :-( 

Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Hotkey Button Frank M <frank_muessner@gmx.de> - 2019-06-06 01:15 -0700
  Re: Hotkey Button "Jamal" <nospam@example.com> - 2019-06-07 17:00 -0400
    Re: Hotkey Button "Jamal" <nospam@example.com> - 2019-06-07 17:13 -0400
  Re: Hotkey Button Frank M <frank_muessner@gmx.de> - 2019-06-08 08:25 -0700
    Re: Hotkey Button "Jamal" <nospam@example.com> - 2019-06-09 03:46 -0400
      Re: Hotkey Button Franz Rachbauer <office@rachbauer.org> - 2019-06-11 14:01 +0200
        Re: Hotkey Button "Jamal" <noooospam@example.com> - 2019-06-11 17:08 -0400
        Re: Hotkey Button "Jamal" <noooospam@example.com> - 2019-06-11 22:16 -0400
  Re: Hotkey Button Frank M <frank_muessner@gmx.de> - 2019-06-11 00:29 -0700

csiph-web