Page 2 of 3

Re: RadioGroup -- Detecting Focus

Posted: Tue Apr 26, 2022 9:36 am
by SALINETAS24
Red2 wrote: Wed Apr 20, 2022 1:25 am

La documentación de HMG para el control RadioGroup tiene solo un Event, OnChange().
No tiene eventos OnGotFocus y OnLostFocus. .../ ....

Realmente agradecería ideas u orientación que alguien pueda compartir.

Thank you,
Red2
Hola Red2.

Aquí te comparto mi mi idea, espero que te pueda servir.

Un saludo cordial y una cervecita virtual!!! :lol:

Re: RadioGroup -- Detecting Focus

Posted: Tue Apr 26, 2022 11:20 am
by edk
Hi.

I added OnGotFocus and OnLostFocus event handlers for the RadioGroup control.

The action for events is set using the HMG_RadioGroupSetEvent ( cFormName, cRadioGroupName, cEvent, bAction ) function, where:
cFormName is the name of the form
cRadioGroupName is the name of the RadioGroup control
cEvent is the name of the event, can take the following values: OnGotFocus | OnLostFocus | OnChange
bAction is a code block that is executed on an event.

To enable handling of the above events for RadioGroup controls, call the
HMG_EnableRadioGroupGotLostFocusEvents ( lProccedEachRadioButtonEvent ) function, where:
lProccedEachRadioButtonEvent parameter can assume the value of .T. or .F.

Since RadioGroup is actually a group of individual RadioButton, each individual RadioButton has its own events.

If lProccedEachRadioButtonEvent is set to .T. then the action assigned to the event will be performed on each RadioGroup item.

However, by setting the value of the lProccedEachRadioButtonEvent parameter to .F., the event actions will be performed for the RadioGroup and not its items. Such a solution may have consequences, because the onLostFocus event action may be called non-chronologically to their actual occurrences, e.g. the OnGotFocus event action of another control may be triggered first, and then the RadioGroup control's OnLostFocus action may be triggered.

Code: Select all

#include "hmg.ch"

Function Main

#define aStdColor	 WHITE
#define aActiveColor	 { 020, 210, 040 }

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 640 HEIGHT 480 ;
		TITLE 'HMG Demo' ;
		MAIN ;
		FONT 'Arial' SIZE 10 ;
		BACKCOLOR aStdColor

		DEFINE RADIOGROUP Radio_1 
			OPTIONS	{ 'One' , 'Two' , 'Three', 'Four' } 
			VALUE	1 
			WIDTH	100 
			TOOLTIP	'RadioGroup' 
			ONCHANGE  MsgInfo( "On Change", "Radio 1" )
			READONLY { .F. , .T. , .F. , .T. }
			ROW	10
			COL	10
			BACKCOLOR aStdColor
		END RADIOGROUP

		DEFINE RADIOGROUP Radio_2 
			ROW 10
			COL 150
			OPTIONS { 'A' , 'B' , 'C', 'D' } 
			VALUE 1 
			WIDTH 100 
			TOOLTIP 'RadioGroup' 
			READONLY { .F. , .F. , .F. , .F. }
			BACKCOLOR aStdColor
		END RADIOGROUP
		
		HMG_RadioGroupSetEvent( "Form_1", "Radio_1", "OnGotFocus", { || Form_1.Radio_1.BackColor := aActiveColor } )
		HMG_RadioGroupSetEvent( "Form_1", "Radio_1", "OnLostFocus", { || Form_1.Radio_1.BackColor := aStdColor  } )

		HMG_RadioGroupSetEvent( "Form_1", "Radio_2", "OnGotFocus", { || Form_1.Radio_2.BackColor := aActiveColor } )
		HMG_RadioGroupSetEvent( "Form_1", "Radio_2", "OnLostFocus", { || Form_1.Radio_2.BackColor := aStdColor } )
		HMG_RadioGroupSetEvent( "Form_1", "Radio_2", "OnChange", { || MsgInfo( "On Change", "Radio 2" ) } )
		
		@ 150,10 TEXTBOX Text_1 ;
		VALUE "Some text" ;
		BACKCOLOR aStdColor ;
		ON GOTFOCUS Form_1.Text_1.BackColor := aActiveColor ;
		ON LOSTFOCUS Form_1.Text_1.BackColor := aStdColor 

	END WINDOW

	Form_1.Text_1.SetFocus
	
	Form_1.Center
	
	HMG_EnableRadioGroupGotLostFocusEvents( .F. /* lProccedEachRadioButtonEvent */ )
	
	Form_1.Activate

Return Nil

**********************************************************
Function HMG_RadioGroupSetEvent ( cForm, cControl, cEventName, bNewProc )
LOCAL nControlIndex := GetControlIndex( cControl, cForm )
LOCAL nEvent := 0

IF .Not. hb_isBlock ( bNewProc )
	bNewProc := ""
ENDIF

IF nControlIndex = 0 .OR. _HMG_SYSDATA [ 1 ] [ nControlIndex ] <> "RADIOGROUP"
	Return Nil
ENDIF

DO CASE
	CASE Upper( cEventName ) = "ONLOSTFOCUS"
		nEvent := 10
	CASE Upper( cEventName ) = "ONGOTFOCUS"
		nEvent := 11
	CASE Upper( cEventName ) = "ONCHANGE"
		nEvent := 12
ENDCASE

IF nEvent > 0		//store event action
	_HMG_SYSDATA [ nEvent ] [ nControlIndex ] := bNewProc
ENDIF

Return Nil

**********************************************************
Function HMG_RadioGroupGotLostFocusEvents( lProccedEachRadioButtonEvent )

#define WM_COMMAND		0x0111
#define BN_KILLFOCUS	0x0007
#define BN_SETFOCUS		0x0006

Local nMsg   := EventMSG () 
Local hWnd   := EventHWND ()
Local wParam := EventWPARAM ()
Local lParam := EventLPARAM ()
Local nControlIndex

Static _nLastRadioGroupFocusedIndex := 0

Default lProccedEachRadioButtonEvent := .T.

IF nMsg == WM_COMMAND

	nControlIndex := hb_AScan ( _HMG_SYSDATA [ 3 ], { | xHandle | IF ( hb_isArray ( xHandle ), hb_AScan ( xHandle, lParam, , , .T. ) <> 0 , .F. ) } )
	
	IF nControlIndex > 0 .AND. _HMG_SYSDATA [ 1 ] [ nControlIndex ] == "RADIOGROUP"
	
		DO CASE 
		
			CASE HIWORD( wParam ) == BN_KILLFOCUS .AND. lProccedEachRadioButtonEvent		//Call OnLostFocus action for each radio button
			
				_DoControlEventProcedure( _HMG_SYSDATA [ 10 /* OnLostFocus */ ] [ nControlIndex ], nControlIndex )
				RETURN 0
				
			CASE HIWORD( wParam ) == BN_SETFOCUS		//Call OnGotFocus action
			
				IF lProccedEachRadioButtonEvent
					_DoControlEventProcedure( _HMG_SYSDATA [ 11 /* OnGotFocus */ ] [ nControlIndex ], nControlIndex )
					RETURN 0
					
				ELSEIF _nLastRadioGroupFocusedIndex <> nControlIndex	//Other radiogroup get focus
						IF _nLastRadioGroupFocusedIndex <> 0		//call last radiogroup onLostFocus action 
							_DoControlEventProcedure( _HMG_SYSDATA [ 10 /* OnLostFocus */ ] [ _nLastRadioGroupFocusedIndex ], _nLastRadioGroupFocusedIndex )
						ENDIF
						_nLastRadioGroupFocusedIndex := nControlIndex	//store current radiogroup
						_DoControlEventProcedure( _HMG_SYSDATA [ 11 /* OnGotFocus */ ] [ nControlIndex ], nControlIndex )
						RETURN 0
						
				ENDIF
				
		ENDCASE
		
	ELSE
	
		IF .Not. lProccedEachRadioButtonEvent .AND. _nLastRadioGroupFocusedIndex <> nControlIndex .AND. _nLastRadioGroupFocusedIndex > 0		//Other control type than radiogroup -> call last radiogroup onLostFocus action
			_DoControlEventProcedure( _HMG_SYSDATA [ 10 /* OnLostFocus */ ] [ _nLastRadioGroupFocusedIndex ], _nLastRadioGroupFocusedIndex )
			_nLastRadioGroupFocusedIndex := 0
			RETURN Nil
			
		ENDIF
		
	ENDIF
	
ENDIF

RETURN Nil

*************************************************************************************
Function HMG_EnableRadioGroupGotLostFocusEvents( lProccedEachRadioButtonEvent )
Local cProc := "HMG_RadioGroupGotLostFocusEvents( " + hb_ValToExp ( lProccedEachRadioButtonEvent ) + " )"
Local nIndex := EventCreate( cProc, NIL, NIL )
EventProcessHMGWindowsMessage ( nIndex, .T. )
RETURN Nil

Re: RadioGroup -- Detecting Focus

Posted: Tue Apr 26, 2022 3:26 pm
by Red2
Hello EDK,

Thank you so much for your elegant solution!
Please believe me when I say that I am most grateful.

Your code sample compiled and ran exactly as hoped.
I will now import it into my application.

I believe that this problem is solved!
Thanks again for your kind help and most generous solution.
Red2

Re: RadioGroup -- Detecting Focus

Posted: Wed Apr 27, 2022 9:07 am
by edk
Thx Red2.

New version: some fixes for calling HMG_EnableRadioGroupGotLostFocusEvents with parameter lProccedEachRadioButtonEvent := .F. :
  • no action of the OnLostFocus RadioGroup event when the OnGotFocus event of some other types of controls appears
  • erroneous calls to the action of the OnLostFocus RadioGroup event when other types of events occur, e.g. Repaint
Hope you find it helpful. I do not guarantee correct operation in all cases :lol: 8-) .

Code: Select all

#include "hmg.ch"

Function Main

#define aStdColor		 WHITE
#define aActiveColor	 { 020, 210, 040 }

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 640 HEIGHT 600 ;
		TITLE 'HMG Demo' ;
		MAIN ;
		FONT 'Arial' SIZE 10 ;
		BACKCOLOR aStdColor

		DEFINE RADIOGROUP Radio_1 
			OPTIONS	{ 'One' , 'Two' , 'Three', 'Four' } 
			VALUE	1 
			WIDTH	100 
			TOOLTIP	'RadioGroup' 
			ONCHANGE  addlog( "Radio_1 OnChange" )
			READONLY { .F. , .T. , .F. , .T. }
			ROW	10
			COL	10
			BACKCOLOR aStdColor
		END RADIOGROUP

		DEFINE RADIOGROUP Radio_2 
			ROW 10
			COL 150
			OPTIONS { 'A' , 'B' , 'C', 'D' } 
			VALUE 1 
			WIDTH 100 
			TOOLTIP 'RadioGroup' 
			READONLY { .F. , .F. , .F. , .F. }
			BACKCOLOR aStdColor
		END RADIOGROUP
		
		HMG_RadioGroupSetEvent( "Form_1", "Radio_1", "OnGotFocus", { || (addlog ( "Radio_1 onGotFocus" ),  Form_1.Radio_1.BackColor := aActiveColor )} )
		HMG_RadioGroupSetEvent( "Form_1", "Radio_1", "OnLostFocus", { || (addlog ( "Radio_1 onLostFocus" ),  Form_1.Radio_1.BackColor := aStdColor )}  )

		HMG_RadioGroupSetEvent( "Form_1", "Radio_2", "OnGotFocus", { || (addlog ( "Radio_2 onGotFocus" ),  Form_1.Radio_2.BackColor := aActiveColor )} )
		HMG_RadioGroupSetEvent( "Form_1", "Radio_2", "OnLostFocus", { || (addlog ( "Radio_2 onLostFocus" ),  Form_1.Radio_2.BackColor := aStdColor )} )
		HMG_RadioGroupSetEvent( "Form_1", "Radio_2", "OnChange", { || addlog( "Radio_2 OnChange" ) } )
		
		@ 120,10 TEXTBOX Text_1 ;
		VALUE "Some text" ;
		BACKCOLOR aStdColor ;
		ON GOTFOCUS ( addlog ( "Text_1 onGotFocus" ),  Form_1.Text_1.BackColor := aActiveColor ) ;
		ON LOSTFOCUS ( addlog ( "Text_1 onLostFocus" ),  Form_1.Text_1.BackColor := aStdColor )
		
		@ 150,10 TEXTBOX Text_2 ;
		VALUE "Some text 2" ;
		BACKCOLOR aStdColor ;
		ON GOTFOCUS ( addlog ( "Text_2 onGotFocus" ),  Form_1.Text_2.BackColor := aActiveColor );
		ON LOSTFOCUS ( addlog ( "Text_2 onLostFocus" ),  Form_1.Text_2.BackColor := aStdColor )
		
		@ 180,10 DATEPICKER Date_1 ;
		VALUE DATE() ;
		TOOLTIP 'DatePicker Control' ;
		ON GOTFOCUS addlog ( "Date_1 onGotFocus" ) ;
		ON LOSTFOCUS addlog ( "Date_1 onLostFocus" )
		
		@ 210,10 BUTTON Button_1 CAPTION "Button" WIDTH 100 HEIGHT 24 ;
			ACTION addlog ("Button_1 pressed") ;
			ON GOTFOCUS addlog ( "Button_1 onGotFocus" ) ;
			ON LOSTFOCUS addlog ( "Button_1 onLostFocus" )
		
		@ 240,10 COMBOBOX Combo_1 ;
			WIDTH 100 ;
			ITEMS { '1 | Uno' , '2 | Dos' , '3 | tres' } ;
			VALUE 1 ;
			ON GOTFOCUS addlog ( "Combo_1 onGotFocus" ) ;
			ON LOSTFOCUS addlog ( "Combo_1 onLostFocus" ) ;
			ON ENTER addlog ( "Combo_1 onEnter" )
		
		@ 270,10 EDITBOX Edit_1 ;
			WIDTH 200 ;
			HEIGHT 80 ;
			VALUE 'EditBox!!' ;
			TOOLTIP 'EditBox' ;
			MAXLENGTH 255 ;
			ON GOTFOCUS addlog ( "EditBox_1 onGotFocus" ) ;
			ON LOSTFOCUS addlog ( "EditBox_1 onLostFocus" ) ;
			NOVSCROLL ;
			NOHSCROLL
			
		DEFINE TREE Tree_1 AT 360,10 WIDTH 120 HEIGHT 22 ON EXPAND tree_expand() ITEMIDS
			ON GOTFOCUS addlog ( "Tree_1 onGotFocus" ) 
			ON LOSTFOCUS addlog ( "Tree_1 onLostFocus" ) 
			NODE 'Expand Grid' ID 1
			END NODE
		END TREE
		
		Form_1.Tree_1.Cargo ( 1 ) :=  { | nTreeValue | ShowGrid( nTreeValue ) }
		Form_1.Tree_1.HasButton ( 1 ) :=  .T.
		HMG_ChangeWindowStyle(Form_1.Tree_1.Handle, Nil, 512, .T.,.T.)
		
		@ 10,370 RICHEDITBOX RichEditBox_1 ;
			HEIGHT 420 ;
			WIDTH 250 ;
			VALUE "" ;
			BACKCOLOR aStdColor ;
			ON GOTFOCUS addlog ( "RichEditBox_1 onGotFocus" ) ;
			ON LOSTFOCUS addlog ( "RichEditBox_1 onLostFocus" ) ;
			READONLY ;
			NOTABSTOP

	END WINDOW

	Form_1.Text_1.SetFocus
	
	Form_1.Center
	
	HMG_EnableRadioGroupGotLostFocusEvents( .F. /* lProccedEachRadioButtonEvent */ )
	
	Form_1.Activate

Return Nil
****************************
function tree_expand()
Local xCargo:=Form_1.Tree_1.Cargo ( This.TreeItemValue )
IF xCargo = Nil
	RETURN
ENDIF
EVAL( xCargo, This.TreeItemValue )
RETURN
******************************
Function ShowGrid( nTreevalue )
Form_1.Tree_1.Item( nTreevalue ) := "Collapse Grid"

@ 380,30 GRID Grid_1 OF Form_1 ;
		WIDTH 320 ;
		HEIGHT 170 ;
		HEADERS {'Column 1','Column 2','Column 3'} ;
		WIDTHS {100,100,100};
		ON GOTFOCUS addlog ( "Grid_1 onGotFocus" ) ;
		ON LOSTFOCUS addlog ( "Grid_1 onLostFocus" ) ;
		VIRTUAL ;
		ITEMCOUNT 1000 ;
		ON QUERYDATA QueryTest() 

Form_1.Tree_1.Cargo ( nTreevalue ) :=  { | nTreeValue | HideGrid( nTreeValue ) }

Return
*******************************
Procedure QueryTest()
	This.QueryData := Str ( This.QueryRowIndex ) + ',' + Str ( This.QueryColIndex )
Return
*********************************
Function HideGrid( nTreevalue )
Form_1.Tree_1.Item( nTreevalue ) := "Expand Grid"
Form_1.Grid_1.Release
Form_1.Tree_1.Cargo ( nTreevalue ) :=  { | nTreeValue | ShowGrid( nTreeValue ) }
Return

****************************
function addlog ( ctxt )
form_1.RichEditBox_1.addtext ( len( form_1.RichEditBox_1.value) ) := ctxt + crlf
RETURN

***********************************************************
*   OnGotFocus / OnLostFocus RadioGroup Event Functions   * 
***********************************************************
Function HMG_RadioGroupSetEvent ( cForm, cControl, cEventName, bNewProc )
LOCAL nControlIndex := GetControlIndex( cControl, cForm )
LOCAL nEvent := 0

IF .Not. hb_isBlock ( bNewProc )
	bNewProc := ""
ENDIF

IF nControlIndex = 0 .OR. _HMG_SYSDATA [ 1 ] [ nControlIndex ] <> "RADIOGROUP"
	Return Nil
ENDIF

DO CASE
	CASE Upper( cEventName ) = "ONLOSTFOCUS"
		nEvent := 10
	CASE Upper( cEventName ) = "ONGOTFOCUS"
		nEvent := 11
	CASE Upper( cEventName ) = "ONCHANGE"
		nEvent := 12
ENDCASE

IF nEvent > 0		//store event action
	_HMG_SYSDATA [ nEvent ] [ nControlIndex ] := bNewProc
ENDIF

Return Nil

**********************************************************
Function HMG_RadioGroupGotLostFocusEvents( lProccedEachRadioButtonEvent )

#define WM_COMMAND		0x0111
#define BN_KILLFOCUS	0x0007
#define BN_SETFOCUS		0x0006
#define EN_SETFOCUS     0x0100    
#define CBN_SETFOCUS	0x0003     
#define LBN_SETFOCUS	0x0004     
#define NM_SETFOCUS     (-0x0007)  

Local nMsg   := EventMSG () 
Local hWnd   := EventHWND ()
Local wParam := EventWPARAM ()
Local lParam := EventLPARAM ()
Local nControlIndex

Static _nLastRadioGroupFocusedIndex := 0

Default lProccedEachRadioButtonEvent := .T.

IF nMsg == WM_COMMAND

	nControlIndex := hb_AScan ( _HMG_SYSDATA [ 3 ], { | xHandle | IF ( hb_isArray ( xHandle ), hb_AScan ( xHandle, lParam, , , .T. ) <> 0 , .F. ) } )
	
	IF nControlIndex > 0 .AND. _HMG_SYSDATA [ 1 ] [ nControlIndex ] == "RADIOGROUP"
	
		DO CASE 
		
			CASE HIWORD( wParam ) == BN_KILLFOCUS .AND. lProccedEachRadioButtonEvent		//Call OnLostFocus action for each radio button
				_DoControlEventProcedure( _HMG_SYSDATA [ 10 /* OnLostFocus */ ] [ nControlIndex ], nControlIndex )
				RETURN 0
				
			CASE HIWORD( wParam ) == BN_SETFOCUS		//Call OnGotFocus action
			
				IF lProccedEachRadioButtonEvent
					_DoControlEventProcedure( _HMG_SYSDATA [ 11 /* OnGotFocus */ ] [ nControlIndex ], nControlIndex )
					RETURN 0
					
				ELSEIF _nLastRadioGroupFocusedIndex <> nControlIndex	//Other radiogroup got focus
						IF _nLastRadioGroupFocusedIndex <> 0		//call last radiogroup onLostFocus action
							_DoControlEventProcedure( _HMG_SYSDATA [ 10 /* OnLostFocus */ ] [ _nLastRadioGroupFocusedIndex ], _nLastRadioGroupFocusedIndex )
						ENDIF
						_nLastRadioGroupFocusedIndex := nControlIndex	//store current radiogroup
						_DoControlEventProcedure( _HMG_SYSDATA [ 11 /* OnGotFocus */ ] [ nControlIndex ], nControlIndex )
						RETURN 0
						
				ENDIF
				
		ENDCASE
		
	ELSE
		IF .Not. lProccedEachRadioButtonEvent .AND. ;
				( HIWORD( wParam ) == BN_SETFOCUS .OR. ;
				  HIWORD( wParam ) == EN_SETFOCUS .OR. ;
				  HIWORD( wParam ) == CBN_SETFOCUS .OR. ;
				  HIWORD( wParam ) == LBN_SETFOCUS ) .AND. ;
				  _nLastRadioGroupFocusedIndex > 0		//Other control type than radiogroup got focus -> call last radiogroup onLostFocus action
			_DoControlEventProcedure( _HMG_SYSDATA [ 10 /* OnLostFocus */ ] [ _nLastRadioGroupFocusedIndex ], _nLastRadioGroupFocusedIndex )
			_nLastRadioGroupFocusedIndex := 0
			RETURN Nil
			
		ENDIF
		
	ENDIF
	
ELSEIF nMsg == WM_NOTIFY .AND. .Not. lProccedEachRadioButtonEvent .AND. _nLastRadioGroupFocusedIndex > 0 .AND. GetNotifyCode ( lParam ) = NM_SETFOCUS		//Other control type than radiogroup got focus -> call last radiogroup onLostFocus action  
	_DoControlEventProcedure( _HMG_SYSDATA [ 10 /* OnLostFocus */ ] [ _nLastRadioGroupFocusedIndex ], _nLastRadioGroupFocusedIndex )
	_nLastRadioGroupFocusedIndex := 0
ENDIF

RETURN Nil

*************************************************************************************
Function HMG_EnableRadioGroupGotLostFocusEvents( lProccedEachRadioButtonEvent )
Local cProc := "HMG_RadioGroupGotLostFocusEvents( " + hb_ValToExp ( lProccedEachRadioButtonEvent ) + " )"
Local nIndex := EventCreate( cProc, NIL, NIL )
EventProcessHMGWindowsMessage ( nIndex, .T. )
RETURN Nil


Re: RadioGroup -- Detecting Focus

Posted: Thu Apr 28, 2022 3:26 pm
by Red2
Thank you EDK!
Your generous update is really appreciated.

===================================================
I found one unintended RADIOGROUP side-effect.
----
Encontré un efecto secundario no deseado de RADIOGROUP.
===================================================

Note: This happens only with a RADIOGROUP control.
It happens when either TABing or mouse CLICKing a RADIOGROUP.
This happens twice:
- once as RADIOGROUP gets focus
- and again as it loses focus.

The Side-Effect:
Whenever a RADIOGROUP Gets or Loses focus the GRID "Flickers".
Each of a grid's rows are annoyingly repainted.
Unfortunately this "Flickering" is quite noticeable.

The Grid "Flickering":
Happens on both:
- a GRID on the same form
OR
- a GRID on a Parent Form that is below a (modal) form editing a Grid row.

Question:
Is some code tweak possible to eliminate the GRID repainting/Flickering?
Thanks again,
Red2

Re: RadioGroup -- Detecting Focus

Posted: Thu Apr 28, 2022 3:46 pm
by edk
Hi. I have no way of checking now, but it seems to me that the flickering effect is caused by the RadioGroup background color changing, not by acquiring or losing focus. From what I remember, while browsing the RadioGroup code, I noticed that repaint is called just at the time of color change.
Try to do the test with On Key event to change the color of RadioGroup and see if this repaint effect occurs.

Re: RadioGroup -- Detecting Focus

Posted: Thu Apr 28, 2022 3:59 pm
by Red2
Thank you for the quick response.

I'll try looking at "On Key" event.
I'll let you know what I find (although likely it won't be today).

Thanks again,
Red2

Re: RadioGroup -- Detecting Focus

Posted: Fri Apr 29, 2022 7:19 am
by edk
Hi.
So it's just what I thought. Gaining / losing RadioGroup focus does not affect the redraw of other controls. Redraw is triggered on color change, unfortunately it's done on the C core level and I can't help it.

Re: RadioGroup -- Detecting Focus

Posted: Fri Apr 29, 2022 2:01 pm
by Red2
Hello,

Again, thank you so much for all of your help and efforts with RADIOGROUP.
I will use your great solution going forward. It is still a positive improvement!

In Visual FoxPro we had a very useful property, LOCKSCREEN.
========================================================
En Visual FoxPro teníamos una propiedad muy útil, LOCKSCREEN.
=========================================================
See:
http://www.yaldex.com/fox_pro_tutorial/ ... 708591.htm

Question:
Does anyone know if HMG has any similar ability?
Locking the Parent Form (below) might be a workaround for the "Flicker".

Thanks again,
Red2

Re: RadioGroup -- Detecting Focus

Posted: Wed May 25, 2022 3:08 pm
by Red2
Hello all,

I found a workaround that eliminates the annoying Grid "flickering" in
the Parent form's Grid while my Child form edits the Grid row.

Google Spanish:
Encontré una solución que elimina el molesto "flickering" de Parent form's Grid
que mi Child form edita la fila de la Grid.

HMG has no command LockScreen like in VFP. But, thanks to some HMG code
in "Jimmy's "Resize.ZIP", I was able to mimic the same thing. See:
https://www.hmgforum.com/viewtopic.php? ... ate#p65286
AUGE_OHR » Tue Feb 16, 2021 3:38 pm

My Workaround:

Code: Select all

#include "dll.ch"
#xtranslate DllCall => HMG_CallDLL	// Lock and Unlock form
* - - - - - - - - - - - - - -
procedure StateEdit_OnInit()
//
local lcFormName := "DataBrowse"
local pnLockwHDL := GetFormHandle( lcFormName )
// Lock parent form "DataBrowse"
DllCall( "user32.dll", DLL_OSAPI, "LockWindowUpdate", pnLockwHDL )	
....
return

========================

#include "dll.ch"
#xtranslate DllCall => HMG_CallDLL	// Lock and Unlock form
* - - - - - - - - - - - - - -
function StateEdit_OnRelease()
//
local llRetVal := .T.
// Unlock parent form "DataBrowse"
DllCall( "user32.dll", DLL_OSAPI, "LockWindowUpdate", 0 )
....
return llRetVal
I do not recall where I found a copy of the include file "dll.ch" but I will
post it if requested. I hope my workaround may help someone else.

Again, thanks to everyone in the HMG community for all of your
generous help in successfully solving this RADIOGROUP Focus problem!
Red2