BROWSE: problem with events key K_UP, K_DOWN ..

Moderator: Rathinagiri

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

BROWSE: problem with events key K_UP, K_DOWN ..

Post by PiotrM »

Witam
Używam BROWSE do obsługi DBF ponieważ według mnie jest szybszy niż GRID zwłaszcza do baz o dużej ilości rekordów (100000 i więcej). Jednak obsługa CREATE EVENT.. lub SET CONTROL... do przyrostowego wyszukiwania była problematyczna ponieważ po naciśnięciu klawisza K_UP, K_DOWN, K_PGUP .. a następnie dowolnego klawisza np. S nie powodowała jego obsługi. Prawdopodobnie znalazłem rozwiązanie tego problemu. Należy w pliku h_windows.prg od lini 2520 zablokować polecenie return 1

Code: Select all

					Case GetGridvKey(lParam) == 36 // HOME

						_BrowseHome('','',i)
                                             //Return 1				

					Case GetGridvKey(lParam) == 35 // END

						_BrowseEnd('','',i)
	                                     //Return 1				

					Case GetGridvKey(lParam) == 33 // PGUP

						_BrowsePrior('','',i)
		                             //Return 1				

					Case GetGridvKey(lParam) == 34 // PGDN

						_BrowseNext('','',i)
			                     //Return 1				

					Case GetGridvKey(lParam) == 38 // UP

						_BrowseUp('','',i)
				            //Return 1				

					Case GetGridvKey(lParam) == 40 // DOWN

						_BrowseDown('','',i)

                                            //	Return 1			

					EndCase

					Return 0

Następnie w pliku h_browse w lini 975 zablokować ListView_SetCursel ( _HMG_SYSDATA [3] , s - 1 ) i w lini 1031 ListView_SetCursel ( _HMG_SYSDATA [3] , s + 1 )

Code: Select all

Procedure _BrowseUp ( ControlName , ParentForm , z )
*-----------------------------------------------------------------------------*
Local i , s  , _Alias , _RecNo , _BrowseArea , _BrowseRecMap , _DeltaScroll := { Nil , Nil , Nil , Nil }

	If pcount() == 2
		i := GetControlIndex ( ControlName , ParentForm )
	Else
		i := z
	EndIf

	_DeltaScroll := ListView_GetSubItemRect ( _HMG_SYSDATA [3][i] , 0 , 0 ) 

	_BrowseRecMap := _HMG_SYSDATA [ 32 ] [i] 

	s := LISTVIEW_GETFIRSTITEM ( _HMG_SYSDATA [3] [i] ) 

	If s == 1
		_Alias := Alias()
		_BrowseArea := _HMG_SYSDATA [ 22 ] [i]
		If Select (_BrowseArea) == 0
			Return
		EndIf
		Select &_BrowseArea
		_RecNo := RecNo()
		Go _BrowseRecMap [1]
		Skip - 1
		_BrowseVscrollUpdate( i )
		_BrowseUpdate(ControlName , ParentForm , i )
		ListView_Scroll( _HMG_SYSDATA [3][i] , _DeltaScroll[2] * (-1) , 0 )
		Go _RecNo
		if Select( _Alias ) != 0
			Select &_Alias
		Else
			Select 0
		Endif
		ListView_SetCursel ( _HMG_SYSDATA [3] [i] , 1 )		

	Else
//		ListView_SetCursel ( _HMG_SYSDATA [3] [i] , s - 1 ) //chyba obsługa przez events  bo nie ma return 1 tylko return 0	
		_BrowseVscrollFastUpdate ( i , -1 )
	EndIf

	_BrowseOnChange (i)

Return
*-----------------------------------------------------------------------------*
Procedure _BrowseDown ( ControlName , ParentForm , z )
*-----------------------------------------------------------------------------*
Local i , PageLength , s , _Alias , _RecNo , _BrowseArea , _BrowseRecMap , _DeltaScroll := { Nil , Nil , Nil , Nil }

	If pcount() == 2
		i := GetControlIndex ( ControlName , ParentForm )
	Else
		i := z
	EndIf

	_DeltaScroll := ListView_GetSubItemRect ( _HMG_SYSDATA [3][i] , 0 , 0 ) 

	_BrowseRecMap := _HMG_SYSDATA [ 32 ] [i] 

	s := LISTVIEW_GETFIRSTITEM ( _HMG_SYSDATA [3] [i] ) 

	PageLength := LISTVIEWGETCOUNTPERPAGE ( _HMG_SYSDATA [3][i] ) 

	If s == PageLength

		if _HMG_SYSDATA [ 26 ] [i] != 0
			Return
		EndIf

		_Alias := Alias()
		_BrowseArea := _HMG_SYSDATA [ 22 ] [i]
		If Select (_BrowseArea) == 0
			Return
		EndIf
		Select &_BrowseArea
		_RecNo := RecNo()

		Go _BrowseRecMap [1] 
		Skip
		_BrowseUpdate( ControlName , ParentForm , i )
		_BrowseVscrollUpdate( i )
		ListView_Scroll( _HMG_SYSDATA [3][i] , _DeltaScroll[2] * (-1) , 0 )
		Go _RecNo
		if Select( _Alias ) != 0
			Select &_Alias
		Else
			Select 0
		Endif

		ListView_SetCursel ( _HMG_SYSDATA [3] [i] , HMG_LEN(_HMG_SYSDATA [ 32 ] [i]) )		

	Else

//		ListView_SetCursel ( _HMG_SYSDATA [3] [i] , s+1 ) //chyba obsługa przez events  bo nie ma return 1 tylko return 0
		_BrowseVscrollFastUpdate ( i , 1 )

	EndIf

	_BrowseOnChange (i)

Return



i to wszystko

Google translator

Hello
I use BROWSE to use DBF because according to me is faster than GRID especially for databases with a large number of records (100,000 or more). However, support for the CREATE EVENT .. or SET CONTROL ... for incremental search was problematic because when you press K_UP, K_DOWN, K_PGUP .. and then any key eg. S did not cause his service. Probably found a solution to this problem. You should file h_windows.prg on line 2520 block command return 1

Code: Select all

					Case GetGridvKey(lParam) == 36 // HOME

						_BrowseHome('','',i)
                                     //	Return 1				

					Case GetGridvKey(lParam) == 35 // END

						_BrowseEnd('','',i)
	                             //	Return 1				

					Case GetGridvKey(lParam) == 33 // PGUP

						_BrowsePrior('','',i)
		                     //	Return 1				

					Case GetGridvKey(lParam) == 34 // PGDN

						_BrowseNext('','',i)
			             //	Return 1				

					Case GetGridvKey(lParam) == 38 // UP

						_BrowseUp('','',i)
				     //	Return 1				

					Case GetGridvKey(lParam) == 40 // DOWN

						_BrowseDown('','',i)

                                    //		Return 1			

					EndCase

					Return 0

Then, the file h_browse in line 975 to block ListView_SetCursel (_HMG_SYSDATA [3] , s - 1), and line 1031 ListView_SetCursel (_HMG_SYSDATA [3] , s + 1)

Code: Select all

Procedure _BrowseUp ( ControlName , ParentForm , z )
*-----------------------------------------------------------------------------*
Local i , s  , _Alias , _RecNo , _BrowseArea , _BrowseRecMap , _DeltaScroll := { Nil , Nil , Nil , Nil }

	If pcount() == 2
		i := GetControlIndex ( ControlName , ParentForm )
	Else
		i := z
	EndIf

	_DeltaScroll := ListView_GetSubItemRect ( _HMG_SYSDATA [3][i] , 0 , 0 ) 

	_BrowseRecMap := _HMG_SYSDATA [ 32 ] [i] 

	s := LISTVIEW_GETFIRSTITEM ( _HMG_SYSDATA [3] [i] ) 

	If s == 1
		_Alias := Alias()
		_BrowseArea := _HMG_SYSDATA [ 22 ] [i]
		If Select (_BrowseArea) == 0
			Return
		EndIf
		Select &_BrowseArea
		_RecNo := RecNo()
		Go _BrowseRecMap [1]
		Skip - 1
		_BrowseVscrollUpdate( i )
		_BrowseUpdate(ControlName , ParentForm , i )
		ListView_Scroll( _HMG_SYSDATA [3][i] , _DeltaScroll[2] * (-1) , 0 )
		Go _RecNo
		if Select( _Alias ) != 0
			Select &_Alias
		Else
			Select 0
		Endif
		ListView_SetCursel ( _HMG_SYSDATA [3] [i] , 1 )		

	Else
//		ListView_SetCursel ( _HMG_SYSDATA [3] [i] , s - 1 ) // Unless service by events because there is only return 1 return 0
		_BrowseVscrollFastUpdate ( i , -1 )
	EndIf

	_BrowseOnChange (i)

Return
*-----------------------------------------------------------------------------*
Procedure _BrowseDown ( ControlName , ParentForm , z )
*-----------------------------------------------------------------------------*
Local i , PageLength , s , _Alias , _RecNo , _BrowseArea , _BrowseRecMap , _DeltaScroll := { Nil , Nil , Nil , Nil }

	If pcount() == 2
		i := GetControlIndex ( ControlName , ParentForm )
	Else
		i := z
	EndIf

	_DeltaScroll := ListView_GetSubItemRect ( _HMG_SYSDATA [3][i] , 0 , 0 ) 

	_BrowseRecMap := _HMG_SYSDATA [ 32 ] [i] 

	s := LISTVIEW_GETFIRSTITEM ( _HMG_SYSDATA [3] [i] ) 

	PageLength := LISTVIEWGETCOUNTPERPAGE ( _HMG_SYSDATA [3][i] ) 

	If s == PageLength

		if _HMG_SYSDATA [ 26 ] [i] != 0
			Return
		EndIf

		_Alias := Alias()
		_BrowseArea := _HMG_SYSDATA [ 22 ] [i]
		If Select (_BrowseArea) == 0
			Return
		EndIf
		Select &_BrowseArea
		_RecNo := RecNo()

		Go _BrowseRecMap [1] 
		Skip
		_BrowseUpdate( ControlName , ParentForm , i )
		_BrowseVscrollUpdate( i )
		ListView_Scroll( _HMG_SYSDATA [3][i] , _DeltaScroll[2] * (-1) , 0 )
		Go _RecNo
		if Select( _Alias ) != 0
			Select &_Alias
		Else
			Select 0
		Endif

		ListView_SetCursel ( _HMG_SYSDATA [3] [i] , HMG_LEN(_HMG_SYSDATA [ 32 ] [i]) )		

	Else

//		ListView_SetCursel ( _HMG_SYSDATA [3] [i] , s+1 ) // Unless service by events because there is only return 1 return 0
		_BrowseVscrollFastUpdate ( i , 1 )

	EndIf

	_BrowseOnChange (i)

Return

this is all

Greetings to all
Attachments
X_Browse.zip
(45.76 KiB) Downloaded 292 times
Piotr Michalski
www.infospec.com.pl
PiotrM
Posts: 15
Joined: Thu May 05, 2016 2:30 pm

Re: BROWSE: problem with events key K_UP, K_DOWN ..

Post by PiotrM »

Witam
Niestety po większej ilości prób okazało się, że metoda nie jest doskonała. Klawisze PgDn, PgUp,Home,End są dobrze obsługiwane po poprawce, jednak klawisz Up i Down już nie. Po naciśnięciu tych klawiszy zmienia się wiersz jednak nie zmienia się rekord w bazie (jest jakby z wiersza poprzedniego). Pomimo wielu poszukiwań nie udało mi się znaleźć funkcji związanej z klawiszem Up i Down, która jest wywoływana po którymś uruchomieniu EVENTS w pliku h_windows.prg. Próbowałem wielu sztuczek ale nic z tego. Potrzebuję pomocy kogoś kto lepiej zna sposoby obsługi w zdarzeniach klawisza Up i Down (przypuszczam, że obsługa jest związana z obsługą Grid). Proponuję powrócić do oryginalnej postaci plików h_browse.prg i h_windows.prg i niestety po naciśnięciu tych klawiszy pierwsze naciśnięcie klawisza innego nie będzie obsługiwane. Jeżeli ktoś potrafi mi pomóc w rozwązanie tego problemu będę wdzięczny.
Pozdrawiam Wszystkich
Piotr

Google translator

Hello
Unfortunately, the greater number of times, it turned out that this method is not perfect. Keys PgDn, PgUp, Home, End, are well supported the amendment, but the key Up and Down anymore. When you press these keys changes to the line but does not change the record in the database (it is as if the previous row). Despite many searches, I could not find the function associated with the button Up and Down, which is called after any run EVENTS file h_windows.prg. I have tried many tricks, but none of that. I need the help of someone who knows better ways of handling events in key Up and Down (I suppose that the service is associated with a service Grid). I suggest you go back to the original file h_browse.prg and h_windows.prg and unfortunately when you press these keys, the first pressing of another is not supported. If someone can help me in considering this issue, I will be grateful.
All Yours
Piotr
Piotr Michalski
www.infospec.com.pl
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: BROWSE: problem with events key K_UP, K_DOWN ..

Post by mol »

Ja długo walczyłem z gridem do obsługi dbfów i się poddałem. Teraz wszędzie używam browse.
Monitowałem wielokrotnie, że coś jest nie tak z gridem, ale nikt mnie nie słuchał...
PiotrM
Posts: 15
Joined: Thu May 05, 2016 2:30 pm

Re: BROWSE: problem with events key K_UP, K_DOWN ..

Post by PiotrM »

Witaj
Ja do grida podchodziłem wiele razy. Obecnie piszę program do obsługi hurtowni i też próbowałem zastosować grida. Używałem HMG 3.4.2 i udało mi się tak ustawić grida że spełniał moje wymagania (wyszukiwanie przyrostowe (zmieniłem zachowanie klawiszy A,S,...opis w temacie Grid i onkeyevent) i przełączanie orderów w zależności od tego w jakiej jestem kolumnie). Chodziło to w miarę. Ale pokazała się wersja 3.4.3 i tutaj Grid bardzo spowolnił. W wersji 3.4.2 Grid nie chodzi pod WinXP wywala się przy naciśnięciu myszką na pierwszej kolumnie. Błąd w wesji HMG 3.4.3 jest poprawiony ala na WinXP jest zjawisko, że przy przesunięciu klawiszem Down rekord bazy jest przesunięty względem wiersza wskazanego w siatce. Myślę że podobny przypadek jak w Browse przy zmianie obsługi klawiszy Up i Down którą opisałem powyżej. Mam bazy o 250,000 rekordów i otwieranie ich w Gridzie trwa długo bez względu czy mam włączone buforowanie czy nie.
To tyle moich wypocin
Pozdrawiam
Piotr

Google translator
Hello
I do grid approached many times. I am currently writing a program for warehousing and also tried to use the grid. I used HMG 3.4.2 and I managed to set the grid that meets my requirements (incremental search (I changed the behavior of the keys A, S, ... a description of the topic Grid and onkeyevent) and switching orders depending on what I'm column). The idea is to measure. But showed up version 3.4.3 and here very Grid slowed. In version 3.4.2 Grid is not under WinXP crashes when you press the mouse on the first column. Error in Versions Users HMG 3.4.3 is improved ala on WinXP is the phenomenon that the shift button Down database record is offset from the line indicated in the grid. I think a similar case as in Browse by changing the operating keys Up and Down which I described above. I have a database of 250,000 records and opening them in the Grid takes a long time regardless of whether I have caching enabled or not.
So much of my scribbles
Regards
Piotr
Piotr Michalski
www.infospec.com.pl
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: BROWSE: problem with events key K_UP, K_DOWN ..

Post by andyglezl »

I have a database of 250,000 records and opening them in the Grid takes a long time regardless of whether I have caching enabled or not.
Hola Piotr
Ya revisaste este post ?
-------------------------------------
Hello Piotr
Already checked this post?


viewtopic.php?f=5&t=3939&p=36875&hilit=andyglezl#p36875
Andrés González López
Desde Guadalajara, Jalisco. México.
trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: BROWSE: problem with events key K_UP, K_DOWN ..

Post by trmpluym »

Piotr & Marek

I discovered the same problems over here...

Did you find a solution ?

Theo
trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: BROWSE: problem with events key K_UP, K_DOWN ..

Post by trmpluym »

Piotr & Marek,

I found a solution for the navigation keys problem with the quick search in the browse control!

My solution also requires modification on the "c:\hmg.3.4.3\SOURCE\h_windows.prg" source (comment out the navigation key lines), see:
2017-01-08 13_29_31-h_windows.prg - SynWrite.png
2017-01-08 13_29_31-h_windows.prg - SynWrite.png (8.08 KiB) Viewed 5320 times
I use the same lines again in the custom EVENT prcedure (see attachement).

Now the quick search also works after using one of the navigation keys :D

Theo
Attachments
browse_search3.zip
(1.55 MiB) Downloaded 293 times
huiyi_ch
Posts: 172
Joined: Sat May 21, 2016 5:27 am

Re: BROWSE: problem with events key K_UP, K_DOWN ..

Post by huiyi_ch »

Very good!
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: BROWSE: problem with events key K_UP, K_DOWN ..

Post by bpd2000 »

+1
BPD
Convert Dream into Reality through HMG
Post Reply