Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #10322 > unrolled thread
| Started by | Gunter <g.huebner@dsh-anklam.de> |
|---|---|
| First post | 2017-03-22 02:44 -0700 |
| Last post | 2017-03-23 02:36 -0700 |
| Articles | 6 — 4 participants |
Back to article view | Back to comp.lang.clipper.visual-objects
a short question Gunter <g.huebner@dsh-anklam.de> - 2017-03-22 02:44 -0700
Re: a short question Frans Wauters <info@wautersit.com> - 2017-03-22 04:33 -0700
Re: a short question Robert van der Hulst <rjvanderhulst@gmail.com> - 2017-03-22 06:34 -0700
Re: a short question Frans Wauters <info@wautersit.com> - 2017-03-23 16:25 -0700
Re: a short question "Karl-Heinz" <invalid@invalid.invalid> - 2017-03-23 09:16 +0100
Re: a short question Gunter <g.huebner@dsh-anklam.de> - 2017-03-23 02:36 -0700
| From | Gunter <g.huebner@dsh-anklam.de> |
|---|---|
| Date | 2017-03-22 02:44 -0700 |
| Subject | a short question |
| Message-ID | <128a2508-a92e-4dcd-862b-08b5bb3fd113@googlegroups.com> |
Hi, how can I catch a function key pressed in a dialog window without any edit control? Many thanks
[toc] | [next] | [standalone]
| From | Frans Wauters <info@wautersit.com> |
|---|---|
| Date | 2017-03-22 04:33 -0700 |
| Message-ID | <f52f14bf-e6b9-4158-9fb9-fba5a2d03971@googlegroups.com> |
| In reply to | #10322 |
Hi Gunter,
I used long time ago something as BeforeDispatch() from the App CLASS and extending a Windows CLASS with a AppKeyTrap() method.
In the App CLASS ( Start module ):
METHOD BeforeDispatch( hWnd, uMsg, wParam, lParam ) CLASS App
LOCAL oWindow AS OBJECT
LOCAL aToetsen AS ARRAY
* Opvangen van toetsaanslagen voor verwerking in andere windows.
* Die windows moeten evenwel een AppKeyTrap() methode krijgen.
*
* Nota: Best geen pushbutton als default in de WED instellen. Na de VK_RETURN
* aanroep zou die default pushbutton ook geactiveert worden.
*
* Nota: VK_F1 = Activate Help System
* VK_F10 = Activate Menu
*
* Zie : VO IDE -> Win32 API Libray -> WinUser voor de verschillende VK_'s
aToetsen := {}
AAdd( aToetsen, VK_F1 ) // F1
AAdd( aToetsen, VK_INSERT ) // Insert
AAdd( aToetsen, VK_DELETE ) // Delete
AAdd( aToetsen, VK_ESCAPE ) // Escape
AAdd( aToetsen, VK_RETURN ) // Return
AAdd( aToetsen, 36 /* VK_HOME */ ) // Home
AAdd( aToetsen, 33 /* VK_UP */ ) // PageUp
AAdd( aToetsen, 34 /* VK_DOWN */ ) // PageDown
AAdd( aToetsen, 35 /* VK_END */ ) // End
AAdd( aToetsen, VK_PAUSE ) // Pause
AAdd( aToetsen, VK_SNAPSHOT ) //
AAdd( aToetsen, VK_TAB ) // Tab
* IF uMsg == WM_KEYDOWN // for visual value and test purpose
* ? wParam
* ENDIF
IF uMsg == WM_KEYDOWN .AND. AScan( aToetsen, wParam ) > 0
IF ( oWindow := GetObjectByHandle( GetParent( hWnd ) ) ) != NULL_OBJECT
IF IsInstanceOf( oWindow, #__FormdialogWindow )
oWindow := oWindow:owner:owner
ENDIF
IF IsMethod( oWindow, #AppKeyTrap )
Send( oWindow, #AppKeyTrap, wParam )
ENDIF
ELSE
ENDIF
ENDIF
RETURN TRUE
Add in the Window CLASS where you want to catch a key:
METHOD AppKeyTrap( wToetsaanslag ) CLASS Mijn_Window
DO CASE
CASE wToetsaanslag == VK_ESCAPE
SELF:pbn_Exit()
CASE wToetsaanslag == 34 /* VK_DOWN */
SELF:pbn_Next()
CASE wToetsaanslag == 33 /* VK_UP */
SELF:pbn_Previous()
ENDCASE
// Laat editeringen niet interfereren met acties van knoppen
IF FormMode == FORM_READONLY
DO CASE
CASE wToetsaanslag == VK_RETURN
SELF:pbn_Edit()
CASE wToetsaanslag == VK_INSERT
SELF:pbn_Add()
CASE wToetsaanslag == VK_DELETE
SELF:pbn_Delete()
CASE wToetsaanslag == 35 /* VK_END */
SELF:pbn_Bottom()
CASE wToetsaanslag == 36 /* VK_HOME */
SELF:pbn_Top()
ENDCASE
ENDIF
RETURN NIL
Maybe this helps.
Kind regards,
Frans
[toc] | [prev] | [next] | [standalone]
| From | Robert van der Hulst <rjvanderhulst@gmail.com> |
|---|---|
| Date | 2017-03-22 06:34 -0700 |
| Message-ID | <e783a68f-dea1-4b69-81fd-f9d4343132c1@googlegroups.com> |
| In reply to | #10323 |
Frans,
Do you realize that for EVERY event in your app (so every mousemove, button click, keyboard entry etc) you are creating this aToetsen array.
Not very efficient I would say. This will stress the garbage collector a lot.
I would suggest to create the array as a (static) global or so, so you create it once and do not have to create it over and over again.
Or at least limit the creation of the array to events of type WM_KEYDOWN.
Robert
> Hi Gunter,
>
>
> I used long time ago something as BeforeDispatch() from the App CLASS and extending a Windows CLASS with a AppKeyTrap() method.
>
>
> In the App CLASS ( Start module ):
>
>
>
> METHOD BeforeDispatch( hWnd, uMsg, wParam, lParam ) CLASS App
>
> LOCAL oWindow AS OBJECT
> LOCAL aToetsen AS ARRAY
>
> * Opvangen van toetsaanslagen voor verwerking in andere windows.
> * Die windows moeten evenwel een AppKeyTrap() methode krijgen.
> *
> * Nota: Best geen pushbutton als default in de WED instellen. Na de VK_RETURN
> * aanroep zou die default pushbutton ook geactiveert worden.
> *
> * Nota: VK_F1 = Activate Help System
> * VK_F10 = Activate Menu
> *
> * Zie : VO IDE -> Win32 API Libray -> WinUser voor de verschillende VK_'s
>
> aToetsen := {}
> AAdd( aToetsen, VK_F1 ) // F1
> AAdd( aToetsen, VK_INSERT ) // Insert
> AAdd( aToetsen, VK_DELETE ) // Delete
> AAdd( aToetsen, VK_ESCAPE ) // Escape
> AAdd( aToetsen, VK_RETURN ) // Return
> AAdd( aToetsen, 36 /* VK_HOME */ ) // Home
> AAdd( aToetsen, 33 /* VK_UP */ ) // PageUp
> AAdd( aToetsen, 34 /* VK_DOWN */ ) // PageDown
> AAdd( aToetsen, 35 /* VK_END */ ) // End
> AAdd( aToetsen, VK_PAUSE ) // Pause
> AAdd( aToetsen, VK_SNAPSHOT ) //
> AAdd( aToetsen, VK_TAB ) // Tab
>
> * IF uMsg == WM_KEYDOWN // for visual value and test purpose
> * ? wParam
> * ENDIF
>
> IF uMsg == WM_KEYDOWN .AND. AScan( aToetsen, wParam ) > 0
> IF ( oWindow := GetObjectByHandle( GetParent( hWnd ) ) ) != NULL_OBJECT
>
> IF IsInstanceOf( oWindow, #__FormdialogWindow )
> oWindow := oWindow:owner:owner
> ENDIF
>
> IF IsMethod( oWindow, #AppKeyTrap )
> Send( oWindow, #AppKeyTrap, wParam )
> ENDIF
>
> ELSE
> ENDIF
> ENDIF
>
> RETURN TRUE
>
>
>
> Add in the Window CLASS where you want to catch a key:
>
>
>
> METHOD AppKeyTrap( wToetsaanslag ) CLASS Mijn_Window
>
> DO CASE
> CASE wToetsaanslag == VK_ESCAPE
> SELF:pbn_Exit()
> CASE wToetsaanslag == 34 /* VK_DOWN */
> SELF:pbn_Next()
> CASE wToetsaanslag == 33 /* VK_UP */
> SELF:pbn_Previous()
> ENDCASE
>
> // Laat editeringen niet interfereren met acties van knoppen
> IF FormMode == FORM_READONLY
>
> DO CASE
> CASE wToetsaanslag == VK_RETURN
> SELF:pbn_Edit()
> CASE wToetsaanslag == VK_INSERT
> SELF:pbn_Add()
> CASE wToetsaanslag == VK_DELETE
> SELF:pbn_Delete()
> CASE wToetsaanslag == 35 /* VK_END */
> SELF:pbn_Bottom()
> CASE wToetsaanslag == 36 /* VK_HOME */
> SELF:pbn_Top()
> ENDCASE
>
> ENDIF
>
> RETURN NIL
>
>
> Maybe this helps.
> Kind regards,
>
> Frans
[toc] | [prev] | [next] | [standalone]
| From | Frans Wauters <info@wautersit.com> |
|---|---|
| Date | 2017-03-23 16:25 -0700 |
| Message-ID | <2aff63c4-0fb3-4e3d-aedf-e53e0ff0ac65@googlegroups.com> |
| In reply to | #10324 |
Hi Robert, Yes, a bit ineffective but this was testcode from a point-of-concept job. And as quickly program is never a good idea it was more to show a customer that some things are realy possible ... also a way to get a new ordering. Regards, Frans
[toc] | [prev] | [next] | [standalone]
| From | "Karl-Heinz" <invalid@invalid.invalid> |
|---|---|
| Date | 2017-03-23 09:16 +0100 |
| Message-ID | <ejhejrF2933U1@mid.individual.net> |
| In reply to | #10322 |
Hi Gunter,
> how can I catch a function key pressed in a dialog window without any edit
> control?
Here´s a sample how to trap e.g. the key F9. Each time the window is
activated the key will be registered, otherwise unregistered.
----------------
METHOD Dispatch ( oEvent ) CLASS YourDlg
DO CASE
CASE oEvent:message == WM_HOTKEY
SELF:OnHotKey ( oEvent:wparam )
ENDCASE
RETURN SUPER:Dispatch ( oEvent )
------------------
METHOD OnHotKey ( dwKey ) CLASS YourDlg
DO CASE
CASE dwKey ==101
? "Hotkey F9 pressed"
ENDCASE
RETURN SELF
METHOD Activate(oEvent) CLASS YourDlg
SUPER:Activate(oEvent)
SELF:__RegisterHotkeys( TRUE )
RETURN NIL
------------------
METHOD Deactivate(oEvent) CLASS YourDlg
SUPER:Deactivate(oEvent)
SELF:__RegisterHotkeys( FALSE )
RETURN NIL
-------------------------------
METHOD __RegisterHotkeys ( lRegister ) CLASS YourDlg
IF lRegister
RegisterHotKey(SELF:Handle(), 101, 0 , VK_F9)
ELSE
UnregisterHotKey(SELF:Handle(), 101)
ENDIF
RETURN SELF
regards
Karl-Heinz
[toc] | [prev] | [next] | [standalone]
| From | Gunter <g.huebner@dsh-anklam.de> |
|---|---|
| Date | 2017-03-23 02:36 -0700 |
| Message-ID | <f25b74cc-151b-4e8a-96be-6ef384f4ebd2@googlegroups.com> |
| In reply to | #10322 |
Am Mittwoch, 22. März 2017 10:44:09 UTC+1 schrieb Gunter: Hi Frans, The BeforeDispatch method is exactly what I need. Works flawlessly. According to the note from Robert, I have changed it as follows: ... symWin := ClassName( oWindow) IF symWin == #dlgEdit2 IF InList( wParam, VK_F6, VK_INSERT, VK_DELETE) Send( oWindow, #AppKeyTrap, wParam ) ENDIF ELSEIF symWin == #dtaKundenKarten ... Thanks Gunter
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.clipper.visual-objects
csiph-web