HMG 2.8.3 (Forum Test)

HMG announcements; Latest HMG-related news, releases, fixes and updates.

Moderator: Rathinagiri

User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: About 2.8.3 and Esgici Sample...

Post by Roberto Lopez »

Roberto Lopez wrote: Well... The only problem with the current version is that 'OnChange' is executed twice when you change the row and column (both) with the mouse.
Sorry... I've forgot to mention that a change is needed in 'h_windows.prg' (yet, it was already discussed in this thread by Grigory and me).

The current 2.8.3 'problematic' code is:

Code: Select all

				* Grid Click ...........................

				If GetNotifyCode ( lParam ) == NM_CLICK  

					IF _HMG_SYSDATA [32] [i] == .T.
						aCellData := _GetGridCellData(i)

						IF aCellData [2] <> _HMG_SYSDATA [ 15 ] [i]
							IF aCellData [1] <> _HMG_SYSDATA [ 19 ] [i]
								_DoControlEventProcedure ( _HMG_SYSDATA [ 12 ] [i] , i )
							ENDIF

						ENDIF

						_HMG_SYSDATA [ 15 ] [i]  := aCellData [2]
						LISTVIEW_REDRAWITEMS ( _HMG_SYSDATA [ 3 ] [i] , _HMG_SYSDATA [ 39 ] [i] - 1 , _HMG_SYSDATA [ 39 ] [i] - 1 )

					ENDIF

				EndIf

The main problem with it, is that variables containing the new values for row and column are updated AFTER the OnChange procedure was executed. The 'minor' problem is a wrong check I've attempted to avoid multiple execution (but I've was wrong about it).

It should be replaced by:

Code: Select all

				* Grid Click ...........................

				If GetNotifyCode ( lParam ) == NM_CLICK  

					IF _HMG_SYSDATA [32] [i] == .T.
						aCellData := _GetGridCellData(i)

						IF aCellData [2] <> _HMG_SYSDATA [ 15 ] [i]
							_HMG_SYSDATA [ 15 ] [i]  := aCellData [2]
							LISTVIEW_REDRAWITEMS ( _HMG_SYSDATA [ 3 ] [i] , _HMG_SYSDATA [ 39 ] [i] - 1 , _HMG_SYSDATA [ 39 ] [i] - 1 )
							_DoControlEventProcedure ( _HMG_SYSDATA [ 12 ] [i] , i )
						endif

					ENDIF

				EndIf


Please, remember... the double execution of OnChange still exists with this modification. It arises when you change selected cell row and col with mouse click.

Regards,

Roberto.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: HMG 2.8.3 (Forum Test)

Post by Rathinagiri »

I had reviewed the code and even though I could not follow the logic without knowing which values the internal HMG_SYSDATA variable hold, I had tested the code, after changing h_windows.prg as mentioned by Roberto.

Now, test this code.

Code: Select all

/*
* MiniGUI Grid Demo
* (c) 2009 Roberto Lopez
*/

#include "minigui.ch"

Function Main

Local aRows [40] [3]
	lInit := .T.
	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH  640 ;
		HEIGHT 400 ;
		TITLE 'Mixed Data Type Grid Test' ;
		MAIN 
		
        ON KEY ESCAPE ACTION Form_1.Release
        
		DEFINE MAIN MENU
			DEFINE POPUP 'File'
				MENUITEM 'Set Value To {5,2}'	ACTION Form_1.Grid_1.Value := {5,2}
				MENUITEM 'Set Value To {0,0}'	ACTION Form_1.Grid_1.Value := {0,0}
				MENUITEM 'Get Value'		ACTION GetSelectionValue()
				MENUITEM 'Delete Item 5'	ACTION Form_1.Grid_1.DeleteItem(5)
				MENUITEM 'AddItem'		ACTION Form_1.Grid_1.AddItem({'X','X','X'})
				MENUITEM 'Delete All Items'	ACTION Form_1.Grid_1.DeleteAllItems
			END POPUP
		END MENU

		aRows [1]	:= {'Simpson','Homer','555-5555'}
		aRows [2]	:= {'Mulder','Fox','324-6432'} 
		aRows [3]	:= {'Smart','Max','432-5892'} 
		aRows [4]	:= {'Grillo','Pepe','894-2332'} 
		aRows [5]	:= {'Kirk','James','346-9873'} 
		aRows [6]	:= {'Barriga','Carlos','394-9654'} 
		aRows [7]	:= {'Flanders','Ned','435-3211'} 
		aRows [8]	:= {'Smith','John','123-1234'} 
		aRows [9]	:= {'Pedemonti','Flavio','000-0000'} 
		aRows [10]	:= {'Gomez','Juan','583-4832'} 

		aRows [11]	:= {'Fernandez','Raul','321-4332'} 
		aRows [12]	:= {'Borges','Javier','326-9430'} 
		aRows [13]	:= {'Alvarez','Alberto','543-7898'} 
		aRows [14]	:= {'Gonzalez','Ambo','437-8473'} 
		aRows [15]	:= {'Batistuta','Gol','485-2843'} 
		aRows [16]	:= {'Vinazzi','Amigo','394-5983'} 
		aRows [17]	:= {'Pedemonti','Flavio','534-7984'} 
		aRows [18]	:= {'Samarbide','Armando','854-7873'} 
		aRows [19]	:= {'Pradon','Alejandra','???-????'} 
		aRows [20]	:= {'Reyes','Monica','432-5836'} 

		aRows [21]	:= {'Fernandez','Raul','321-4332'} 
		aRows [22]	:= {'Borges','Javier','326-9430'} 
		aRows [23]	:= {'Alvarez','Alberto','543-7898'} 
		aRows [24]	:= {'Gonzalez','Ambo','437-8473'} 
		aRows [25]	:= {'Batistuta','Gol','485-2843'} 
		aRows [26]	:= {'Vinazzi','Amigo','394-5983'} 
		aRows [27]	:= {'Pedemonti','Flavio','534-7984'} 
		aRows [28]	:= {'Samarbide','Armando','854-7873'} 
		aRows [29]	:= {'Pradon','Alejandra','???-????'} 
		aRows [30]	:= {'Reyes','Monica','432-5836'} 

		aRows [31]	:= {'Fernandez','Raul','321-4332'} 
		aRows [32]	:= {'Borges','Javier','326-9430'} 
		aRows [33]	:= {'Alvarez','Alberto','543-7898'} 
		aRows [34]	:= {'Gonzalez','Ambo','437-8473'} 
		aRows [35]	:= {'Batistuta','Gol','485-2843'} 
		aRows [36]	:= {'Vinazzi','Amigo','394-5983'} 
		aRows [37]	:= {'Pedemonti','Flavio','534-7984'} 
		aRows [38]	:= {'Samarbide','Armando','854-7873'} 
		aRows [39]	:= {'Pradon','Alejandra','???-????'} 
		aRows [40]	:= {'Reyes','Monica','432-5836'} 
		 
		DEFINE GRID Grid_1 
		    ROW             10
		    COL             10 
			WIDTH           500 
			HEIGHT          300 
			HEADERS         {'Column 1','Column 2','Column 3'} 
			WIDTHS          {100,100,100} 
			ITEMS           aRows 
			VALUE           1 
			ALLOWEDIT       .T.
			CELLNAVIGATION  .T. 
            ONCHANGE        msginfo("Here")		  
/*			
			ONCHANGE { ||  IF( ( _IsControlDefined( "spnRow", "Form_1" ) .AND. ; 
                                 _IsControlDefined( "spnCol", "Form_1" ) ) ,; 
                                 ( aCurValue := this.value,;
                                 SetProperty( "Form_1", "spnRow", "Value", aCurValue[ 1 ] ),;
                                 SetProperty( "Form_1", "spnCol", "Value", aCurValue[ 2 ] ) ), '' ) }
*/
		END GRID // Grid_1 
/*            
        @ 13, 520 LABEL lblRow WIDTH 50 VALUE "Row No:"
        @ 53, 520 LABEL lblCol WIDTH 50 VALUE "Col No:"
        			
		DEFINE SPINNER spnRow 
		   ROW   10				
           COL   580 
           WIDTH 50
           RANGEMIN 1 
           RANGEMAX LEN( aRows )   
           VALUE 1 
           ONCHANGE { || aCurValue := GetProperty( "Form_1", "Grid_1", "Value" ),; 
                         aCurValue[ 1 ] :=  this.Value,;
                         SetProperty( "Form_1", "Grid_1", "Value", aCurValue ) }

        END SPINNER // spnRow			

		DEFINE SPINNER spnCol 
		   ROW   50				
           COL   580 
           WIDTH 50
           RANGEMIN 1 
           RANGEMAX 3
           VALUE 1            
           ONCHANGE { || aCurValue := GetProperty( "Form_1", "Grid_1", "Value" ),; 
                         aCurValue[ 2 ] :=  this.Value,;
                         SetProperty( "Form_1", "Grid_1", "Value", aCurValue ) }

        END SPINNER // spnCol			
*/

        DEFINE STATUSBAR 
           STATUSITEM WIDTH 100
        END STATUSBAR 
                
	END WINDOW

 	Form_1.Grid_1.setfocus

	CENTER WINDOW Form_1

	ACTIVATE WINDOW Form_1

Return


Function GetSelectionValue
Local a

	a := Form_1.Grid_1.Value

	MsgInfo( Str (  a [1] ) + ' ' + Str (  a [2] ) )

Return nil


It is the last sample (without Spinners) by esgici.

I had changed the on change event to just a msginfo("Here") to find out how many times the on change event is fired. When run, to my surprise, while using keyboard navigation, row, col values change accordingly and on change event is fired once. In the case of mouse click (in a different row and col), on change event is fired once, but, the col value doesn't change at all. May be this is the reason?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: HMG 2.8.3 (Forum Test)

Post by Roberto Lopez »

rathinagiri wrote:I had reviewed the code and even though I could not follow the logic without knowing which values the internal HMG_SYSDATA variable hold, I had tested the code, after changing h_windows.prg as mentioned by Roberto.
<...>
I guess I've found a solution (five minutes ago).

I've made various test and all appears to be working fine now, but is 01:57 am here and I'm extremely tired (I'm going to bed right now).

So, I'll do some more tests tomorrow and if all still ok, I'll publish a complete package with a demo app to be tested here.

Regards,

Roberto.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: HMG 2.8.3 (Forum Test)

Post by Rathinagiri »

Thanks Roberto.

A famous Tamil proverb says, We can draw a painting if and only if we have a wall. :) So, Take Care of your body too.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
mol
Posts: 3720
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HMG 2.8.3 (Forum Test)

Post by mol »

Hello Roberto, time to get up!!!
:lol:
I'm waiting for your example...
User avatar
sudip
Posts: 1454
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: HMG 2.8.3 (Forum Test)

Post by sudip »

Hi,

I shall be out of station for 3 days. So, when I shall back, get new version of HMG!!! :D

With best regards.

Sudip
With best regards,
Sudip
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: HMG 2.8.3 (Forum Test)

Post by Roberto Lopez »

mol wrote:Hello Roberto, time to get up!!!
:lol:
I'm waiting for your example...
Peae... wait... the morning coffee is not ready yet :)

Regards,

Roberto.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: HMG 2.8.3 (Forum Test)

Post by esgici »

rathinagiri wrote:
I had changed the on change event to just a msginfo("Here") to find out how many times the on change event is fired. When run, to my surprise, while using keyboard navigation, row, col values change accordingly and on change event is fired once. In the case of mouse click (in a different row and col), on change event is fired once, but, the col value doesn't change at all. May be this is the reason?
Hi Rathi

Hearty Thanks for stand up for me :D

When change ONCHANGE line of GRID to

ONCHANGE msginfo("Here"+CRLF+GetSelectionValue())

and RETURN line of GetSelectionValue() to

Return ( Str ( a [1] ) + ' ' + Str ( a [2] ) )

situation can be seen more clear ( without a second step to going menu ).

Thanks a lot

Best Regards

--

Esgici
Viva INTERNATIONAL HMG :D
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: HMG 2.8.3 (Forum Test)

Post by esgici »

esgici wrote: blah, blah, blah ...
And when added spinners to Rathi's example "double execution" can be seen clearly.

Double, because one for row spinner and one for other.

Regards

--

Esgici
Viva INTERNATIONAL HMG :D
User avatar
Roberto Lopez
HMG Founder
Posts: 4004
Joined: Wed Jul 30, 2008 6:43 pm

Re: HMG 2.8.3 (Forum Test)

Post by Roberto Lopez »

esgici wrote:
esgici wrote: blah, blah, blah ...
Interesting comment :)

Regards,

Roberto.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
Post Reply