Grid: problem with events onkey

Moderator: Rathinagiri

Post Reply
PiotrM
Posts: 15
Joined: Thu May 05, 2016 2:30 pm

Grid: problem with events onkey

Post by PiotrM »

Welcome.
Probably a mistake with support for key events at onkey, create event, etc.
I noticed the lack of EventMSG () == WM_CHAR the keys A S D R U.
Error disappears when you change the end of the function key handling A S D R U file h_windows.prg from the line in 2865 by converting to return 1 return 0. Below accurate description.

....
"Harbour Project"
Copyright 1999-2008, http://www.harbour-project.org/

"WHAT32"
Copyright 2002 AJ Wos <andrwos@aust1.net>

"HWGUI"
Copyright 2001-2008 Alexander S.Kresin <alex@belacy.belgorod.su>
---------------------------------------------------------------------------*/
/*
From line 2865 in structure else .. endif rename return 1 --> return 0 for key A D R S U
add 29-04-2016 Piotr Michalski (bad read key in event onkey)
*/
// #define ALLOW_ONLY_ONE_MESSAGE_LOOP
.....
.....
....


//line 2865
Case GetGridvKey (lParam) == 65 // A

if GetAltState() == -127 ;
.or.;
GetAltState() == -128 // ALT

IF _HMG_SYSDATA [ 40 ] [ i ] [ 12 ] == .T. .AND. VALTYPE(_HMG_SYSDATA [ 40 ] [ i ] [ 10 ] ) == 'C'

DataGridAppend(i)

ENDIF

Else

return 0 //not return 1 ?

EndIf


Case GetGridvKey (lParam) == 68 // D

if GetAltState() == -127 ;
.or.;
GetAltState() == -128 // ALT

IF _HMG_SYSDATA [ 40 ] [ i ] [ 17 ] == .T. .AND. VALTYPE(_HMG_SYSDATA [ 40 ] [ i ] [ 10 ] ) == 'C'

DataGridDelete(i)

ENDIF

Else

return 0

EndIf


Case GetGridvKey (lParam) == 82 // R

if GetAltState() == -127 ;
.or.;
GetAltState() == -128 // ALT

IF _HMG_SYSDATA [ 40 ] [ i ] [ 17 ] == .T. .AND. VALTYPE(_HMG_SYSDATA [ 40 ] [ i ] [ 10 ] ) == 'C'

DataGridReCall(i)

ENDIF

Else

return 0

EndIf


Case GetGridvKey (lParam) == 83 // S

if GetAltState() == -127 ;
.or.;
GetAltState() == -128 // ALT

IF ( _HMG_SYSDATA [ 40 ] [ i ] [ 12 ] == .T. .OR. _HMG_SYSDATA [ 40 ] [ i ] [ 1 ] == .T. ) .AND. ( VALTYPE(_HMG_SYSDATA [ 40 ] [ i ] [ 10 ] ) == 'C' )

DataGridSave(i)

ENDIF

Else

Return 0

EndIf


Case GetGridvKey (lParam) == 85 // U

if GetAltState() == -127 ;
.or.;
GetAltState() == -128 // ALT

IF _HMG_SYSDATA [ 40 ] [ i ] [ 12 ] == .T. .AND. VALTYPE(_HMG_SYSDATA [ 40 ] [ i ] [ 10 ] ) == 'C'

DataGridClearBuffer(i)

ENDIF

Else

Return 0

EndIf


OtherWise

// Return 1 // Remove, december 2014

EndCase

Return 0 // ADD, december 2014

EndIf

EndIf


.....
...
In the Annex the corrected file h windows.prg
I do not know how well I think, but can someone come in handy
greetings
Translated by Google
Attachments
h_windows.zip
(35.24 KiB) Downloaded 193 times
Piotr Michalski
www.infospec.com.pl
User avatar
serge_girard
Posts: 3166
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: Grid: problem with events onkey

Post by serge_girard »

Thanks Rathi!

Serge
There's nothing you can do that can't be done...
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Grid: problem with events onkey

Post by srvet_claudio »

Thanks, I will check!
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: Grid: problem with events onkey

Post by srvet_claudio »

srvet_claudio wrote:Thanks, I will check!
Hi Piotr,
I checked the source code and this is the right correction:

Code: Select all

                     Case GetGridvKey (lParam) == 83 // S
                        if GetAltState() == -127 .or. GetAltState() == -128   // ALT
                           IF ( _HMG_SYSDATA [ 40 ] [ i ] [ 12 ] == .T. .OR. ;      // allowAppend
                                _HMG_SYSDATA [ 40 ] [ i ] [ 17 ] == .T. .OR. ;      // allowDelete
                                _HMG_SYSDATA [ 40 ] [ i ] [ 1 ] == .T. ) .AND. ;    // allowEdit inplace
                                ( VALTYPE(_HMG_SYSDATA [ 40 ] [ i ] [ 10 ] ) == 'C' )
                              DataGridSave(i)
                           ENDIF
                        Else
                           // Return 1
                        EndIf


                     Case GetGridvKey (lParam) == 85 // U
                        if GetAltState() == -127 .or. GetAltState() == -128   // ALT
                           IF ( _HMG_SYSDATA [ 40 ] [ i ] [ 12 ] == .T. .OR. ;      // allowAppend
                                _HMG_SYSDATA [ 40 ] [ i ] [ 17 ] == .T. .OR. ;      // allowDelete
                                _HMG_SYSDATA [ 40 ] [ i ] [ 1 ] == .T. ) .AND. ;    // allowEdit inplace
                                ( VALTYPE(_HMG_SYSDATA [ 40 ] [ i ] [ 10 ] ) == 'C' )
                              DataGridClearBuffer(i)
                           ENDIF
                        Else
                           // Return 1
                        EndIf
Thanks for reporting this bug !
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
Post Reply