Page 1 of 2

How to find out the IDs of controls and types?

PostPosted: Sat Jan 06, 2024 2:49 am
by Giovany Vecchi
I have a dialog with some controls. Ex:

Code: Select all  Expand view
P_EDITAL_EMISSAO_INI DIALOGEX DISCARDABLE 6, 18, 325, 96
STYLE WS_POPUP|DS_MODALFRAME|DS_CONTEXTHELP|DS_3DLOOK|WS_CAPTION|WS_SYSMENU|WS_VISIBLE
CAPTION "Dialog"
FONT 10, "Tahoma", 0, 0, 1
{
  CONTROL "Edit", 331, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 74, 40, 44, 12
  CONTROL "Edit", 332, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 74, 54, 243, 12
  CONTROL "Imprimir", 351, "Button", WS_TABSTOP, 162, 72, 76, 17
  CONTROL "Cancelar", 359, "Button", WS_TABSTOP, 241, 72, 76, 17
  CONTROL "TFolderEx", 301, "TSBBARINFO", 0x00000000, 0, 0, 325, 31
  CONTROL "Data da Intimação:", 4001, "Static", SS_RIGHT|WS_GROUP, 6, 42, 67, 8
  CONTROL "Quem assina/Cargo:", 4002, "Static", SS_RIGHT|WS_GROUP, 1, 56, 72, 8
}
 


Is there any way to identify the controls of this dialog automatically?
Some function that returns controls without them being called by the Redefine SAY, Button, Get, etc. commands.

Re: How to find out the IDs of controls and types?

PostPosted: Sat Jan 06, 2024 7:08 am
by Natter
What is
identify the controls of this dialog automatically
?
If I understood the question correctly then for example:
1. each control has an ID - :nId.
2. You can specify the control ID in :Cargo

Re: How to find out the IDs of controls and types?

PostPosted: Sat Jan 06, 2024 9:30 am
by Antonio Linares
Dear Giovany,

giovany.prg
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

    local oDlg

    DEFINE DIALOG oDlg RESOURCE "test"

    ACTIVATE DIALOG oDlg CENTERED ;
       ON INIT EnumChildWindows( oDlg:hWnd,;
          { | hChild | MsgInfo( GetClassName( hChild ), GetDlgCtrlID( hChild ) ) } )

return nil  


giovany.rc
Code: Select all  Expand view
Test DIALOGEX DISCARDABLE 6, 18, 325, 96
STYLE WS_POPUP|DS_MODALFRAME|DS_CONTEXTHELP|DS_3DLOOK|WS_CAPTION|WS_SYSMENU|WS_VISIBLE
CAPTION "Dialog"
FONT 10, "Tahoma"
{
  CONTROL "Edit", 331, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 74, 40, 44, 12
  CONTROL "Edit", 332, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 74, 54, 243, 12
  CONTROL "Imprimir", 351, "Button", WS_TABSTOP, 162, 72, 76, 17
  CONTROL "Cancelar", 359, "Button", WS_TABSTOP, 241, 72, 76, 17
  CONTROL "Data da Intimação:", 4001, "Static", SS_RIGHT|WS_GROUP, 6, 42, 67, 8
  CONTROL "Quem assina/Cargo:", 4002, "Static", SS_RIGHT|WS_GROUP, 1, 56, 72, 8
}

Re: How to find out the IDs of controls and types?

PostPosted: Sun Jan 07, 2024 6:40 am
by Jimmy
hi,

Question : how can i get Object of Child when EnumChildWindows() :?:

i think about OOP Environment where i need a Object instead of a Handle

Re: How to find out the IDs of controls and types?

PostPosted: Sun Jan 07, 2024 7:34 am
by Antonio Linares
Dear Jimmy,

Those control objects don't exist until you redefine them.

When we use Windows API EnumChildWindows() we are working at the Windows API level, not at the FWH level

Re: How to find out the IDs of controls and types?

PostPosted: Tue Jan 09, 2024 7:56 am
by Jimmy
hi Antonio,
Antonio Linares wrote:Those control objects don't exist until you redefine them.

i understand but how if Control Object does exist :?:

how e.g. "re-size" a Windows with Control using EnumChildWindows() where i need Object :?:

Re: How to find out the IDs of controls and types?

PostPosted: Tue Jan 09, 2024 8:23 am
by paquitohm
Hi,

Using oWndFromHwnd() function

Code: Select all  Expand view
// Example
oWnd:= oWndFromHwnd( GetActiveWindow() )
 

Regards

Re: How to find out the IDs of controls and types?

PostPosted: Tue Jan 09, 2024 8:35 am
by Jimmy
hi,
paquitohm wrote:Using oWndFromHwnd() function

thx for Answer

i do want Object of Controls not Object of Windows.

Re: How to find out the IDs of controls and types?

PostPosted: Tue Jan 09, 2024 6:40 pm
by Antonio Linares
Dear Jimmy,

nAt = AScan( ::aControls, { | oControl | oControl:hWnd == hChild } )
::aControls[ nAt ]

Re: How to find out the IDs of controls and types?

PostPosted: Tue Jan 09, 2024 8:52 pm
by paquitohm
oWndFromHwnd() returns object control too. Try it !

Re: How to find out the IDs of controls and types?

PostPosted: Tue Jan 09, 2024 10:19 pm
by Giovany Vecchi
Antonio Linares wrote:Dear Giovany,

giovany.prg
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

    local oDlg

    DEFINE DIALOG oDlg RESOURCE "test"

    ACTIVATE DIALOG oDlg CENTERED ;
       ON INIT EnumChildWindows( oDlg:hWnd,;
          { | hChild | MsgInfo( GetClassName( hChild ), GetDlgCtrlID( hChild ) ) } )

return nil  


giovany.rc
Code: Select all  Expand view
Test DIALOGEX DISCARDABLE 6, 18, 325, 96
STYLE WS_POPUP|DS_MODALFRAME|DS_CONTEXTHELP|DS_3DLOOK|WS_CAPTION|WS_SYSMENU|WS_VISIBLE
CAPTION "Dialog"
FONT 10, "Tahoma"
{
  CONTROL "Edit", 331, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 74, 40, 44, 12
  CONTROL "Edit", 332, "Edit", ES_AUTOHSCROLL|WS_BORDER|WS_TABSTOP, 74, 54, 243, 12
  CONTROL "Imprimir", 351, "Button", WS_TABSTOP, 162, 72, 76, 17
  CONTROL "Cancelar", 359, "Button", WS_TABSTOP, 241, 72, 76, 17
  CONTROL "Data da Intimação:", 4001, "Static", SS_RIGHT|WS_GROUP, 6, 42, 67, 8
  CONTROL "Quem assina/Cargo:", 4002, "Static", SS_RIGHT|WS_GROUP, 1, 56, 72, 8
}


Antonio, that's right.
I'm going to improve my application's skin routine.
As we often do not declare "STATIC" controls, which would be SAY in FWH, I needed to know how to find the IDs of these controls.
When it's ready I'll post the class and an example here again.

Thank you very much

Re: How to find out the IDs of controls and types?

PostPosted: Wed Jan 10, 2024 2:14 pm
by Giovany Vecchi
I can't change the colors of the controls found.
I need a function that returns the control's properties as well.
Here's an example of how I'm doing it.

Code: Select all  Expand view
  EnumChildWindows( f_oDlgContainer:hWnd,;
                     { | _hChild | AAdd( lc_aCtrlsAllApi, { GetClassName( _hChild ), GetDlgCtrlID( _hChild ), _hChild } ) } )
   
   For lc_iFor := 1 To Len(lc_aCtrlsAllApi)
      If Upper(lc_aCtrlsAllApi[lc_iFor,1]) == "STATIC"
         If hb_AScan(lc_aIDsAllFwh,lc_aCtrlsAllApi[lc_iFor,2]) == 0 ;               //Static Api > SAY Fwh not declared
            .and. lc_aCtrlsAllApi[lc_iFor,2] != 65535                               //Static borland or null IDs
            SetTextColor(GetDc(lc_aCtrlsAllApi[lc_iFor,3]), CLR_WHITE)
            SetBkColor(GetDc(lc_aCtrlsAllApi[lc_iFor,3]), CLR_CYAN)
         EndIf
      EndIf
 

Re: How to find out the IDs of controls and types?

PostPosted: Wed Jan 10, 2024 3:53 pm
by carlos vargas
Umm, if theme Is active, the label control not change color.only ir theme Is not active.

Re: How to find out the IDs of controls and types?

PostPosted: Wed Jan 10, 2024 5:18 pm
by Giovany Vecchi
carlos vargas wrote:Umm, if theme Is active, the label control not change color.only ir theme Is not active.


Even removing the themes still doesn't work.
These functions work perfectly on the fivewin ComboBox and RadioButtons controls:
SetWindowTheme(GetDc(lc_aCtrlsAllApi[lc_iFor,3]), "", "" )
Ctl3DLook(GetDc(lc_aCtrlsAllApi[lc_iFor,3]), .F.)

Code: Select all  Expand view
EnumChildWindows( f_oDlgContainer:hWnd,;
                     { | _hChild | AAdd( lc_aCtrlsAllApi, { GetClassName( _hChild ), GetDlgCtrlID( _hChild ), _hChild } ) } )
   
   For lc_iFor := 1 To Len(lc_aCtrlsAllApi)
      If Upper(lc_aCtrlsAllApi[lc_iFor,1]) == "STATIC"
         If hb_AScan(lc_aIDsAllFwh,lc_aCtrlsAllApi[lc_iFor,2]) == 0 ;               //Static Api > SAY Fwh not declared
            .and. lc_aCtrlsAllApi[lc_iFor,2] != 65535                               //Static borland or null IDs
            SetWindowTheme(GetDc(lc_aCtrlsAllApi[lc_iFor,3]), "", "" )
            Ctl3DLook(GetDc(lc_aCtrlsAllApi[lc_iFor,3]), .F.)
            SetTextColor(GetDc(lc_aCtrlsAllApi[lc_iFor,3]), CLR_WHITE)
            SetBkColor(GetDc(lc_aCtrlsAllApi[lc_iFor,3]), CLR_CYAN)
         EndIf
      EndIf
 

Re: How to find out the IDs of controls and types?

PostPosted: Thu Jan 11, 2024 4:32 pm
by karinha
Can Giovany make a complete and functional example of this example?

¿Puede Giovany hacer un ejemplo completo y funcional de este ejemplo?

Gracias, tks.

Regards, saludos.