RadioGroup -- Detecting Focus
Moderator: Rathinagiri
-
Red2
- Posts: 282
- Joined: Sat May 18, 2019 2:11 pm
- DBs Used: Visual FoxPro, FoxPro
- Location: United States of America
RadioGroup -- Detecting Focus
HMG's documentation for the RadioGroup control has only one Event, OnChange().
It does not have Events OnGotFocus and OnLostFocus.
At runtime, however, HMG shows focus when I tab into a RadioGroup. My Question:
Is there any way to programmatically capture when
Focus Enters ("Got") and
Focus Leaves ("Lost")
a RadioGroup?
I would really appreciate ideas or guidance anyone might share.
========================================================
Google Spanish:
La documentación de HMG para el control RadioGroup tiene solo un Event, OnChange().
No tiene eventos OnGotFocus y OnLostFocus.
Sin embargo, en el tiempo de ejecución, HMG muestra el foco cuando entro en un RadioGroup.
Mi pregunta:
¿Hay alguna forma de capturar programáticamente cuando
Foco Entra ("Got") y
Hojas de enfoque ("Lost")
un RadioGroup?
Realmente agradecería ideas u orientación que alguien pueda compartir.
Thank you,
Red2
It does not have Events OnGotFocus and OnLostFocus.
At runtime, however, HMG shows focus when I tab into a RadioGroup. My Question:
Is there any way to programmatically capture when
Focus Enters ("Got") and
Focus Leaves ("Lost")
a RadioGroup?
I would really appreciate ideas or guidance anyone might share.
========================================================
Google Spanish:
La documentación de HMG para el control RadioGroup tiene solo un Event, OnChange().
No tiene eventos OnGotFocus y OnLostFocus.
Sin embargo, en el tiempo de ejecución, HMG muestra el foco cuando entro en un RadioGroup.
Mi pregunta:
¿Hay alguna forma de capturar programáticamente cuando
Foco Entra ("Got") y
Hojas de enfoque ("Lost")
un RadioGroup?
Realmente agradecería ideas u orientación que alguien pueda compartir.
Thank you,
Red2
-
Red2
- Posts: 282
- Joined: Sat May 18, 2019 2:11 pm
- DBs Used: Visual FoxPro, FoxPro
- Location: United States of America
Re: RadioGroup -- Detecting Focus
Hello All,
I found very interesting FOCUS code in the following HMG Forum post.
https://www.hmgforum.com/viewtopic.php? ... ber#p61963
Post by serge_girard » Tue May 12, 2020 4:46 am
This code correctly determines which LABEL control has focus by using the mouse cursor’s position. Cool!
Although this code works great with LABEL controls it FAILS when a RADIOGROUP control is substituted. Sad! Here are my three simple alteration to Serge’s code:
1) - I made the FORM a bit wider.
2) - I changed the array’s 2nd row's name to "RadioGrp2".
3) - In the FOR n := 1 TO Len(aLabel) loop I substituted a RADIOGROUP control in iteration #2.
With my iteration #2, if ( n == 2 ), included I get the error that I just cannot understand.
HELP, I'm out of ideas. Does anyone understand why a RADIOGROUP control fails?
OR Can someone give guidance on some way to determine GotFocus and LostFocus on a RADIOGROUP control.
Thank you all!
Red2
I found very interesting FOCUS code in the following HMG Forum post.
https://www.hmgforum.com/viewtopic.php? ... ber#p61963
Post by serge_girard » Tue May 12, 2020 4:46 am
This code correctly determines which LABEL control has focus by using the mouse cursor’s position. Cool!
Although this code works great with LABEL controls it FAILS when a RADIOGROUP control is substituted. Sad! Here are my three simple alteration to Serge’s code:
1) - I made the FORM a bit wider.
2) - I changed the array’s 2nd row's name to "RadioGrp2".
3) - In the FOR n := 1 TO Len(aLabel) loop I substituted a RADIOGROUP control in iteration #2.
With my iteration #2, if ( n == 2 ), included I get the error that I just cannot understand.
Code: Select all
LOCAL aLabel := { { "LABEL1" , NIL } ;
, { "RadioGrp2", NIL } ;
, { "LABEL3" , NIL } }
DEFINE WINDOW MainForm;
WIDTH 400 ;
HEIGHT 260 ;
TITLE "Labels as Buttons";
MAIN;
ON GOTFOCUS MainFormOnGotFocus(aLabel)
//this labels can get focus and process keyboard/mouse messages
FOR n := 1 TO Len(aLabel)
if ( n == 2 ) // RADIOGROUP
DEFINE RADIOGROUP &( aLabel[n][CTRL_NAME] )
ROW 10 + 55 * (n - 1)
COL 20
WIDTH 150
HEIGHT 28
PARENT MainForm
OPTIONS { 'Inches','Milimeters'}
VALUE 1
FONTNAME "Arial"
FONTSIZE 9
FONTBOLD .T.
TOOLTIP "Units of Measure"
FONTBOLD .F.
FONTITALIC .F.
FONTUNDERLINE .F.
FONTSTRIKEOUT .F.
HELPID Nil
TABSTOP .T.
VISIBLE .T.
TRANSPARENT .F.
SPACING 75
BACKCOLOR {255,250,240}
FONTCOLOR NIL
READONLY Nil
HORIZONTAL .T.
END RADIOGROUP
else
DEFINE LABEL &( aLabel[n][CTRL_NAME] )
ROW 10 + 55 * (n - 1)
COL 20
WIDTH 140
HEIGHT 45
VALUE "This is " + aLabel[n][CTRL_NAME]
ALIGNMENT Center
FONTCOLOR BLACK
END LABEL
endif
OR Can someone give guidance on some way to determine GotFocus and LostFocus on a RADIOGROUP control.
Thank you all!
Red2
Re: RadioGroup -- Detecting Focus
No me queda claro que es lo que quieres hacer...
Que acciones harías cuando Pierda / Obtenga el FOCO el Control ???
Ya que su función es que active/desactive al dar Click.
Si quieres desplegar texto, utiliza el TOOLTIP <cToolTipText> ]
Andrés González López
Desde Guadalajara, Jalisco. México.
Desde Guadalajara, Jalisco. México.
- AUGE_OHR
- Posts: 2117
- Joined: Sun Aug 25, 2019 3:12 pm
- DBs Used: DBF, PostgreSQL, MySQL, SQLite
- Location: Hamburg, Germany
Re: RadioGroup -- Detecting Focus
hi Red,
HMG have "RadioGroup" not "RadioButton"
when look into
---
a Tree can have Focus but not a Node of Tree which can be "active"
a Listbox can have Focus but not a Item of Listbox which can be "active"
so the Parent Control can have Focus, but if have Child they can "only" be "active"
HMG have "RadioGroup" not "RadioButton"
when look into
you will findc:\hmg.3.4.4\SOURCE\h_radio.prg
Code: Select all
ControlHandle := InitRadioGroup( ... )
FOR i = 2 TO HMG_LEN( aOptions )
ControlHandle := InitRadioButton( ... )
a Tree can have Focus but not a Node of Tree which can be "active"
a Listbox can have Focus but not a Item of Listbox which can be "active"
so the Parent Control can have Focus, but if have Child they can "only" be "active"
have fun
Jimmy
Jimmy
Re: RadioGroup -- Detecting Focus
Workaround for Got Focus and Lost Focus missing events for RadioGroup (only works with getting / losing focus using the TAB key)
Code: Select all
#include "hmg.ch"
Function Main
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 640 HEIGHT 480 ;
TITLE 'HMG Demo' ;
MAIN ;
FONT 'Arial' SIZE 10
DEFINE RADIOGROUP Radio_1
OPTIONS { 'One' , 'Two' , 'Three', 'Four' }
VALUE 1
WIDTH 100
TOOLTIP 'RadioGroup'
ONCHANGE MsgBalloon( "On Change", "RadioGroup 1" )
READONLY { .F. , .T. , .F. , .T. }
ROW 10
COL 10
END RADIOGROUP
DEFINE RADIOGROUP Radio_2
ROW 10
COL 150
OPTIONS { 'One' , 'Two' , 'Three', 'Four' }
VALUE 1
WIDTH 100
TOOLTIP 'RadioGroup'
ONCHANGE MsgBalloon( "On Change", "RadioGroup 2" )
READONLY { .F. , .T. , .F. , .T. }
END RADIOGROUP
@ 150,10 DATEPICKER Date_1 ;
VALUE CTOD(' / / ') ;
TOOLTIP 'DatePicker Control'
END WINDOW
Form_1.date_1.SetFocus
Form_1.Center
CREATE EVENT PROCNAME cProcRadioGroup()
Form_1.Activate
Return Nil
**********************************************************
Function cProcRadioGroup( )
Local nMsg := EventMSG ()
Local hWnd := EventHWND ()
Local wParam := EventWPARAM ()
Local lParam := EventLPARAM ()
DO CASE
CASE ASCAN ( Form_1.Radio_1.Handle, hWnd ) <> 0 //Handles of Radio_1
DO CASE
CASE nMsg == WM_KEYUP .AND. LoWord ( wParam ) == VK_TAB
MsgBalloon( "Got Focus", "RadioGroup 1" )
CASE nMsg == WM_KEYDOWN .AND. LoWord ( wParam ) == VK_TAB
MsgBalloon( "Lost Focus", "RadioGroup 1" )
ENDCASE
CASE ASCAN ( Form_1.Radio_2.Handle, hWnd ) <> 0 //Handles of Radio_2
DO CASE
CASE nMsg == WM_KEYUP .AND. LoWord ( wParam ) == VK_TAB
MsgBalloon( "Got Focus", "RadioGroup 2" )
CASE nMsg == WM_KEYDOWN .AND. LoWord ( wParam ) == VK_TAB
MsgBalloon( "Lost Focus", "RadioGroup 2" )
ENDCASE
ENDCASE
RETURN Nil
**************************************************************************************--------------------------------------------------------*
Procedure MsgBalloon( cMessage, cTitle )
Default cMessage := "Message", cTitle := "Title"
ShowNotifyInfo( GetActiveWindow(), .T. , Nil, Nil, cMessage, cTitle, .T., .F., .F. )
Do Events
ShowNotifyInfo( GetActiveWindow(), .F. , Nil, Nil, Nil , Nil , .F., .F., .F. )
Return
*************************************************************************************
#pragma BEGINDUMP
//#define _WIN32_IE 0x0500
#define HB_OS_WIN_32_USED
//#define _WIN32_WINNT 0x0400
#include <shlobj.h>
#include <windows.h>
#include <commctrl.h>
#include "hbapi.h"
static void ShowNotifyInfo(HWND hWnd, BOOL bAdd, HICON hIcon, LPSTR szText, LPSTR szInfo, LPSTR szInfoTitle, BOOL bInfo, BOOL bWarning, BOOL bError);
HB_FUNC ( SHOWNOTIFYINFO )
{
ShowNotifyInfo( (HWND) hb_parnl(1), (BOOL) hb_parl(2), (HICON) hb_parnl(3), (LPSTR) hb_parc(4),
(LPSTR) hb_parc(5), (LPSTR) hb_parc(6), (BOOL) hb_parl(7), (BOOL) hb_parl(8), (BOOL) hb_parl(9) );
}
static void ShowNotifyInfo(HWND hWnd, BOOL bAdd, HICON hIcon, LPSTR szText, LPSTR szInfo, LPSTR szInfoTitle, BOOL bInfo, BOOL bWarning, BOOL bError)
{
NOTIFYICONDATA nid;
ZeroMemory( &nid, sizeof(nid) );
nid.cbSize = sizeof(NOTIFYICONDATA);
nid.hIcon = hIcon;
nid.hWnd = hWnd;
nid.uID = 0;
nid.uFlags = NIF_INFO | NIF_TIP | NIF_ICON;
if(bInfo)
nid.dwInfoFlags = NIIF_INFO;
if(bWarning)
nid.dwInfoFlags = NIIF_WARNING;
if(bError)
nid.dwInfoFlags = NIIF_ERROR;
lstrcpy( nid.szTip, TEXT(szText) );
lstrcpy( nid.szInfo, TEXT(szInfo) );
lstrcpy( nid.szInfoTitle, TEXT(szInfoTitle) );
if(bAdd)
Shell_NotifyIcon( NIM_ADD, &nid );
else
Shell_NotifyIcon( NIM_DELETE, &nid );
DestroyIcon( hIcon );
}
#pragma ENDDUMP
-
Red2
- Posts: 282
- Joined: Sat May 18, 2019 2:11 pm
- DBs Used: Visual FoxPro, FoxPro
- Location: United States of America
Re: RadioGroup -- Detecting Focus
Hi All,
Thank you so much EDK for your very generous guidance. I am one step closer!
First, let me explain my purpose. I want to clearly show the user which control has focus.
Using events OnGotFocus() an OnLostFocus() I alter BackColor and FontSize to show Focus. For whatever reason HMG does not implement these Events for the RADIOGROUP control!
This is unfortunate.
Now when TABBING into a RADIOGROUP I can hook into "GotFocus" and "LostFocus". EDK's post clearly states that this "only works with getting / losing focus using the TAB key)".
I'm nearly there but I still have one problem!
When clicking in or out of a RADIOGROUP these hooks simply CANNOT fire!
Thus my focus indicators, BackColor and FontSize, are neither added nor removed.
Worst case, both the old RADIOGROUP and the new control can show as "having Focus".
Can anyone more experienced than I am suggest some additional "mouse clicking" solution.
As always any of your kind guidance is greatly appreciated!
Thank you all!
Red2
Thank you so much EDK for your very generous guidance. I am one step closer!
First, let me explain my purpose. I want to clearly show the user which control has focus.
Using events OnGotFocus() an OnLostFocus() I alter BackColor and FontSize to show Focus. For whatever reason HMG does not implement these Events for the RADIOGROUP control!
This is unfortunate.
Now when TABBING into a RADIOGROUP I can hook into "GotFocus" and "LostFocus". EDK's post clearly states that this "only works with getting / losing focus using the TAB key)".
I'm nearly there but I still have one problem!
When clicking in or out of a RADIOGROUP these hooks simply CANNOT fire!
Thus my focus indicators, BackColor and FontSize, are neither added nor removed.
Worst case, both the old RADIOGROUP and the new control can show as "having Focus".
Can anyone more experienced than I am suggest some additional "mouse clicking" solution.
As always any of your kind guidance is greatly appreciated!
Thank you all!
Red2
Re: RadioGroup -- Detecting Focus
Red2 wrote: ↑Sat Apr 23, 2022 1:14 am Hi All,
First, let me explain my purpose. I want to clearly show the user which control has focus.
Using events OnGotFocus() an OnLostFocus() I alter BackColor and FontSize to show Focus.
Radio_NO_Focus.PNG
For whatever reason HMG does not implement these Events for the RADIOGROUP control!
This is unfortunate.
Yo utilizo lo siguiente con estos controles:
@ <nRow> ,<nCol> RADIOGROUP <ControlName>....... OPTIONS { "&DBF", "&CSV", "&RPT" } VALUE 1 ........ ON CHANGE ( FormActions.TBX_FileTo.SetFocus ) NOTABSTOP
Con NOTABSTOP le estoy indicando que NO se detenga en dicho Control cada vez que oprimo ENTER o TAB
y tengo la opción de dar Click con el mouse o por medio del teclado con ALT-D, ALT-C o ALT-R.
*---------------------------------------------------------------------------------------------------------------------------------------
I use the following with these controls:
@ <nRow> ,<nCol> RADIOGROUP <ControlName>....... OPTIONS { "&DBF", "&CSV" , "&RPT" } VALUE 1 ........ ON CHANGE ( FormActions.TBX_FileTo.SetFocus ) NOTABSTOP
With NOTABSTOP I am telling you NOT to stop at that Control every time I press ENTER or TAB
and I have the option to Click with the mouse or through the keyboard with ALT-D, ALT-C or ALT-R.
.
.
Andrés González López
Desde Guadalajara, Jalisco. México.
Desde Guadalajara, Jalisco. México.
-
Red2
- Posts: 282
- Joined: Sat May 18, 2019 2:11 pm
- DBs Used: Visual FoxPro, FoxPro
- Location: United States of America
Re: RadioGroup -- Detecting Focus
Thank you andyglez. I appreciate your kind suggestion.
Perhaps I do not quite understand its idea however.
HMG, via Events OnGotFocus() and OnLostFocus(), displays my Focus
information nicely for all those controls I am using except RADIOGROUP.
For whatever reason, it has this odd EVENT limitation.
So, with or without NOTABSTOP, RADIOGROUP does not show
my (BackColor and FontSize) FOCUS indication.
I still hope that someone has a creative workaround that could work along with
EDK's great code and address the one remaining limitation (mouse-clicking).
As always, thank you to everyone who has been generous enough
to offer their suggestions! Your help is greatly appreciated!
==============================================================
Google Spanish:
Gracias andyglez. Agradezco su amable sugerencia.
Quizás no entiendo muy bien su idea sin embargo.
HMG, a través de Eventos OnGotFocus() y OnLostFocus(), muestra mi enfoque
información muy bien para todos los controles que estoy usando excepto RADIOGROUP.
Por alguna razón, tiene esta extraña limitación de EVENTO.
Entonces, con o sin NOTABSTOP, RADIOGROUP no muestra
mi (BackColor y FontSize) indicación FOCUS.
Todavía espero que alguien tenga una solución alternativa creativa que pueda funcionar junto con
El excelente código de EDK y aborda la única limitación restante (mouse-clicking).
Como siempre, gracias a todos los que han sido lo suficientemente generosos.
para ofrecer sus sugerencias! ¡Tu ayuda es muy apreciada!
Red2
Perhaps I do not quite understand its idea however.
HMG, via Events OnGotFocus() and OnLostFocus(), displays my Focus
information nicely for all those controls I am using except RADIOGROUP.
For whatever reason, it has this odd EVENT limitation.
So, with or without NOTABSTOP, RADIOGROUP does not show
my (BackColor and FontSize) FOCUS indication.
I still hope that someone has a creative workaround that could work along with
EDK's great code and address the one remaining limitation (mouse-clicking).
As always, thank you to everyone who has been generous enough
to offer their suggestions! Your help is greatly appreciated!
==============================================================
Google Spanish:
Gracias andyglez. Agradezco su amable sugerencia.
Quizás no entiendo muy bien su idea sin embargo.
HMG, a través de Eventos OnGotFocus() y OnLostFocus(), muestra mi enfoque
información muy bien para todos los controles que estoy usando excepto RADIOGROUP.
Por alguna razón, tiene esta extraña limitación de EVENTO.
Entonces, con o sin NOTABSTOP, RADIOGROUP no muestra
mi (BackColor y FontSize) indicación FOCUS.
Todavía espero que alguien tenga una solución alternativa creativa que pueda funcionar junto con
El excelente código de EDK y aborda la única limitación restante (mouse-clicking).
Como siempre, gracias a todos los que han sido lo suficientemente generosos.
para ofrecer sus sugerencias! ¡Tu ayuda es muy apreciada!
Red2
Re: RadioGroup -- Detecting Focus
Los Eventos OnGotFocus() and OnLostFocus() no los tiene el control RADIOGROUP
Las propiedades SIZE, BACKCOLOR y FONTCOLOR deberían de funcionar.
*------------------------------------------------------------------------------------------------------
The OnGotFocus() and OnLostFocus() Events do not have the RADIOGROUP control
The SIZE, BACKCOLOR and FONTCOLOR properties should work.
Por lo que he leído aquí en el Foro, parece ser por el TEMA de Windows...
Muchos controles no funcionan correctamente estando activo.
Si lo pruebas con el tema clásico, te funciona ???
*--------------------------------------------------------------------------------------------
From what I've read here in the Forum, it seems to be because of the Windows THEME...
Many controls do not work properly while active.
If you try it with the classic theme, it works for you ???
https://hmgforum.com/viewtopic.php?f=5& ... eme#p48317
Las propiedades SIZE, BACKCOLOR y FONTCOLOR deberían de funcionar.
*------------------------------------------------------------------------------------------------------
The OnGotFocus() and OnLostFocus() Events do not have the RADIOGROUP control
The SIZE, BACKCOLOR and FONTCOLOR properties should work.
Por lo que he leído aquí en el Foro, parece ser por el TEMA de Windows...
Muchos controles no funcionan correctamente estando activo.
Si lo pruebas con el tema clásico, te funciona ???
*--------------------------------------------------------------------------------------------
From what I've read here in the Forum, it seems to be because of the Windows THEME...
Many controls do not work properly while active.
If you try it with the classic theme, it works for you ???
Post by srvet_claudio » Mon Feb 27, 2017 10:28 am
Is not a bug of HMG is a Windows behavioral, many color property not work with Windows theme active.
https://hmgforum.com/viewtopic.php?f=5& ... eme#p48317
Andrés González López
Desde Guadalajara, Jalisco. México.
Desde Guadalajara, Jalisco. México.
-
Red2
- Posts: 282
- Joined: Sat May 18, 2019 2:11 pm
- DBs Used: Visual FoxPro, FoxPro
- Location: United States of America
Re: RadioGroup -- Detecting Focus
Hi andyglezl,
Gracias por su sugerencia. No he usado THEMEs antes.
No estoy seguro de entender tu sugerencia.
Intenté agregar lo siguiente pero nada cambió.
¿He probado tu sugerencia correctamente?
======================================================
Thank you for your suggestion. I have not used THEMEs before.
I am not sure that I understand your suggestion.
I tried adding the following but nothing changed.
Have I tried your suggestion correctly?
Thanks again,
Red2
Gracias por su sugerencia. No he usado THEMEs antes.
No estoy seguro de entender tu sugerencia.
Intenté agregar lo siguiente pero nada cambió.
¿He probado tu sugerencia correctamente?
======================================================
Thank you for your suggestion. I have not used THEMEs before.
I am not sure that I understand your suggestion.
I tried adding the following but nothing changed.
Have I tried your suggestion correctly?
Code: Select all
SetWindowTheme( ItemEdit.RadioGrp_OALLen.Handle, 0, 0 )
// prior to EDK's
CREATE EVENT PROCNAME cProcRadioGroup()Red2