Page 2 of 2

Re: Set Initial Focus Color

Posted: Tue Oct 27, 2020 6:50 am
by SALINETAS24
Red2 wrote: Mon Oct 26, 2020 10:13 pm Hi SALINETAS24,

Gracias (otra vez). Como mencioné, simplemente estoy examinando un .DBF en una TAB en un FORM.
Este formulario fue creado usando el IDE de HMG. No hay GRID aquí.
Hola Red2, si estas en un TAB entonce debes activar la clausula ON CHANGE en el DEFINE TAB.
Seria algo como esto

Code: Select all

#include "hmg.ch"

Function Main
Local aRows [20] [3]
LOCAL nIdioma:=1
LOCAL sFont:="Arial"
LOCAL sSize:=10
LOCAL gFont:="Arial"
LOCAL gSize:=10
LOCAL aColor[4]
	aColor[1]:=0
	aColor[2]:=0
	aColor[3]:=0
	aColor[4]:=0
	
	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'} 

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 640 HEIGHT 480 ;
		TITLE 'HMG Demo' ;
		MAIN 

		DEFINE MAIN MENU
			DEFINE POPUP 'Test'
				MENUITEM 'Get Grid Header' ACTION MsgInfo ( Form_1.Tab_1(4).Grid_1.Header(1) ) 
				MENUITEM 'Set Grid Header' ACTION Form_1.Tab_1(4).Grid_1.Header(1) := 'New'
				SEPARATOR
				MENUITEM 'Set Grid Cell' ACTION Form_1.Tab_1(4).Grid_1.Cell(1,1) := 'New'
				MENUITEM 'Get Grid Cell' ACTION MsgInfo ( Form_1.Tab_1(4).Grid_1.Cell(1,1) )
				SEPARATOR
			END POPUP
		END MENU

		DEFINE TAB Tab_1 ;
			AT 10,10 ;
			WIDTH 600 ;
			HEIGHT 400 ;
			VALUE 1 ;
			TOOLTIP 'Tab Control' ;
			FONT "COURIER NEW" SIZE 9  ON CHANGE  f_change()

		PAGE 'Page 1' IMAGE "exit.bmp"

			      
			@ 30 , 10 LABEL SAY_02  VALUE IF(nIdioma=1,"Razón social","Company name") TRANSPARENT AUTOSIZE FONT sFont SIZE sSize
			@ 60 , 10 LABEL SAY_03  VALUE IF(nIdioma=1,"Nombre","Name") TRANSPARENT AUTOSIZE FONT sFont SIZE sSize      
			@ 90 , 10 LABEL SAY_04  VALUE IF(nIdioma=1,"Dirección","Adress") TRANSPARENT AUTOSIZE FONT sFont SIZE sSize   
			@ 120, 10 LABEL SAY_05  VALUE IF(nIdioma=1,"Población","Tows") TRANSPARENT AUTOSIZE FONT sFont SIZE sSize   

			@  30,130 TEXTBOX Get_02 VALUE " " WIDTH 250 FONT gFont SIZE gSize MAXLENGTH 35 
			@  60,130 TEXTBOX Get_03 VALUE " " WIDTH 250 FONT gFont SIZE gSize MAXLENGTH 35	
			@  90,130 TEXTBOX Get_04 VALUE " " WIDTH 250 FONT gFont SIZE gSize MAXLENGTH 35	
			@ 120,130 TEXTBOX Get_05 VALUE " " WIDTH 250 FONT gFont SIZE gSize MAXLENGTH 35
				  
				  
			END PAGE

			PAGE 'Page &2' IMAGE "info.bmp"
			

				DEFINE RADIOGROUP R1
					ROW	100
					COL	100
					OPTIONS	{ '1','2','3' }
					VALUE	1
				END RADIOGROUP

			END PAGE

			PAGE 'Page 3' IMAGE "check.bmp"

				@ 100,250 SPINNER Spinner_1 ;
				RANGE 0,10 ;
				VALUE 5 ;
				WIDTH 100 ;
				TOOLTIP 'Range 0,10' ; 
				ON CHANGE PlayBeep() 

			END PAGE

			PAGE 'Page 4' IMAGE "button.bmp"

				@ 50,50 GRID Grid_1 ;
					WIDTH 200 ;
					HEIGHT 330 ;
					HEADERS {'Last Name','First Name','Phone'} ;
					WIDTHS {140,140,140};
					ITEMS aRows ;
					VALUE 1 

			END PAGE

		END TAB

	END WINDOW

	Form_1.Center
	FORM_1.Activate

Return Nil



STATIC PROC  f_change()
LOCAL n_value := form_1.tab_1.value
	IF n_value=4
		Form_1.Grid_1.Setfocus
	ENDIF
RETURN


Re: Set Initial Focus Color

Posted: Thu Oct 29, 2020 12:58 pm
by Red2
Hi SALINETAS24,

Thank you so much for your code sample. Tab #4 does initially display the row with focus using the dark blue "selected" BackColor.

Unfortunately:
1)
it's page #4 uses a GRID, not a BROWSE. I need a BROWSE here.
Also
2) Its rows are populated with and array, not directly from a .DBF table. The source must be a WORKAREA.

That said, I am only able to briefly examine the code right now. I'll have to try again later.

Question:
Can you perhaps assist using the two constraints (above)?

Again, thank you for your kind advice and guidance!

Kind Regards,
Red2

Re: Set Initial Focus Color

Posted: Thu Oct 29, 2020 4:20 pm
by franco
Red2,
I played around with this and found the browse to be at top must have value of 0, Grid is 1
I build with..
***
@ECHO OFF
call c:\hmg.3.4.4\build.bat main %
***

Code: Select all

#include "hmg.ch"

Function Main
Local aRows [20] [3]
LOCAL nIdioma:=1
LOCAL sFont:="Arial"
LOCAL sSize:=10
LOCAL gFont:="Arial"
LOCAL gSize:=10
LOCAL aColor[4]
                                    PRIVATE WHERE := 0                 // ADDED
	aColor[1]:=0
	aColor[2]:=0
	aColor[3]:=0
	aColor[4]:=0
	
	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'} 
TABL()

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 600 HEIGHT 480 ;
		TITLE 'HMG Demo' ;
		MAIN ;
		ON RELEASE CLS()


		DEFINE MAIN MENU
			DEFINE POPUP 'Test'
				MENUITEM 'Get Grid Header' ACTION MsgInfo ( Form_1.Tab_1(4).Grid_1.Header(1) ) 
				MENUITEM 'Set Grid Header' ACTION Form_1.Tab_1(4).Grid_1.Header(1) := 'New'
				SEPARATOR
				MENUITEM 'Set Grid Cell' ACTION Form_1.Tab_1(4).Grid_1.Cell(1,1) := 'New'
				MENUITEM 'Get Grid Cell' ACTION MsgInfo ( Form_1.Tab_1(4).Grid_1.Cell(1,1) )
				SEPARATOR
			END POPUP
		END MENU

		DEFINE TAB Tab_1 ;
			AT 10,10 ;
			WIDTH 600 ;
			HEIGHT 400 ;
			VALUE 1 ;
			TOOLTIP 'Tab Control' ;
			FONT "COURIER NEW" SIZE 9  ON CHANGE  f_change()

		PAGE 'Page 1' //IMAGE "exit.bmp"

			      
			@ 30 , 10 LABEL SAY_02  VALUE IF(nIdioma=1,"Razón social","Company name") TRANSPARENT AUTOSIZE FONT sFont SIZE sSize
			@ 60 , 10 LABEL SAY_03  VALUE IF(nIdioma=1,"Nombre","Name") TRANSPARENT AUTOSIZE FONT sFont SIZE sSize      
			@ 90 , 10 LABEL SAY_04  VALUE IF(nIdioma=1,"Dirección","Adress") TRANSPARENT AUTOSIZE FONT sFont SIZE sSize   
			@ 120, 10 LABEL SAY_05  VALUE IF(nIdioma=1,"Población","Tows") TRANSPARENT AUTOSIZE FONT sFont SIZE sSize   

			@  30,130 TEXTBOX Get_02 VALUE " " WIDTH 250 FONT gFont SIZE gSize MAXLENGTH 35 
			@  60,130 TEXTBOX Get_03 VALUE " " WIDTH 250 FONT gFont SIZE gSize MAXLENGTH 35	
			@  90,130 TEXTBOX Get_04 VALUE " " WIDTH 250 FONT gFont SIZE gSize MAXLENGTH 35	
			@ 120,130 TEXTBOX Get_05 VALUE " " WIDTH 250 FONT gFont SIZE gSize MAXLENGTH 35
				  
				  
			END PAGE

			PAGE 'Page &2' //IMAGE "info.bmp"
			

				DEFINE RADIOGROUP R1
					ROW	100
					COL	100
					OPTIONS	{ '1','2','3' }
					VALUE	1
				END RADIOGROUP

			END PAGE

			PAGE 'Page 3' //IMAGE "check.bmp"

				@ 100,250 SPINNER Spinner_1 ;
				RANGE 0,10 ;
				VALUE 5 ;
				WIDTH 100 ;
				TOOLTIP 'Range 0,10' ; 
				ON CHANGE PlayBeep() 

			END PAGE
			PAGE 'Page 4' //IMAGE "button.bmp"


				@ 50,50 Grid Grid_1 ;
					WIDTH 450 ;
					HEIGHT 330 ;
					HEADERS {'Last Name','First Name','Phone'} ;
					WIDTHS {140,140,140};
					ITEMS aRows ;
					ON LOSTFOCUS {WHERE := THIS.VALUE} ;
				        VALUE 1 

			END PAGE
			PAGE 'Page 5' //IMAGE "button.bmp"

				DEFINE  BROWSE B_2 
					ROW 50
					COL 50
					WIDTH 450 
					HEIGHT 330 
					HEADERS {'First Name','Last Name','Phone'} 
					WIDTHS {140,140,140}
					WORKAREA NAME
					FIELDS {'FIRST', 'LAST', 'PHONE'}
					ONLOSTFOCUS {WHERE := THIS.VALUE}
					*VALUE WHERE
					
					 

				END BROWSE


	


			END PAGE


		END TAB

	END WINDOW

	Form_1.Center
	FORM_1.Activate

Return Nil



STATIC PROC  f_change()
LOCAL n_value := form_1.tab_1.value
*WHERE := 0
	IF n_value=4
		IF where = 0
			where := 1
		endif
		form_1.Grid_1.VALUE := WHERE
		Form_1.Grid_1.Setfocus
	ENDIF
	IF n_value=5
		form_1.b_2.VALUE := WHERE
		form_1.b_2.setfocus
	ENDIF
RETURN

FUNCTION CLS
	CLOSE ALL
RETURN

FUNCTION TABL
if ! file('name.dbf')
	CF := {}
	aADD(CF,{'FIRST'       ,'C' , 15,0})
	aADD(CF,{'LAST'       ,'C' , 15,0})
	aADD(CF,{'PHONE'       ,'C' ,15,0})

	DBCREATE( 'NAME.DBF',CF )
	USE
 
   USE NAME EXCLUSIVE NEW 
	*INDEX ON ITEM TO ITEM
	DO WHILE .T.
		NAME->( DBAPPEND())
		NAME->( FIELDPUT(1, 'Homer'))
		NAME->( FIELDPUT(2, 'Simpson'))
		NAME->( FIELDPUT(3, '555-5555'))
		NAME->( DBAPPEND())
		NAME->( FIELDPUT(1, 'Fox'))
		NAME->( FIELDPUT(2, 'Mulder'))
		NAME->( FIELDPUT(3, '324-5892'))
		NAME->( DBAPPEND())
		NAME->( FIELDPUT(1, 'Max'))
		NAME->( FIELDPUT(2, 'Smart'))
		NAME->( FIELDPUT(3, '432-2332'))
	INDEX ON FIRST TO FIRST
	INDEX ON LAST TO LAST
	USE
	EXIT

	ENDDO

ENDIF
 USE NAME SHARED NEW 
 set index to first
RETURN

/[code]

Re: Set Initial Focus Color

Posted: Thu Oct 29, 2020 5:20 pm
by SALINETAS24
Red2 wrote: Thu Oct 29, 2020 12:58 pm Hi SALINETAS24,

Unfortunately:
1)
it's page #4 uses a GRID, not a BROWSE. I need a BROWSE here.
Also
2) Its rows are populated with and array, not directly from a .DBF table. The source must be a WORKAREA.



Kind Regards,
Red2
Hola Red2, pues cambiamos el GRID por un BROWSE y listo. A mi me funciona :P
Saludos y cerveza fresquita...
BROWSE.02.rar
(1.21 MiB) Downloaded 134 times

Re: Set Initial Focus Color

Posted: Fri Oct 30, 2020 1:09 pm
by Red2
Hi SALINETAS24 and Franco,

Thank you for your kind help. I'll work with your suggestions.
Unfortunately for the next few days I have some things and will be otherwise distracted.

Again thanks for your generous assistance!

Red2