FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to find out the IDs of controls and types?
Posts: 244
Joined: Mon Jun 05, 2006 09:39 PM
How to find out the IDs of controls and types?
Posted: Sat Jan 06, 2024 02:49 AM
I have a dialog with some controls. Ex:
Code (fw): Select all Collapse
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.
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM
Re: How to find out the IDs of controls and types?
Posted: Sat Jan 06, 2024 07:08 AM
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: How to find out the IDs of controls and types?
Posted: Sat Jan 06, 2024 09:30 AM
Dear Giovany,

giovany.prg
Code (fw): Select all Collapse
#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 (fw): Select all Collapse
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
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: How to find out the IDs of controls and types?
Posted: Sun Jan 07, 2024 06:40 AM
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
greeting,

Jimmy
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: How to find out the IDs of controls and types?
Posted: Sun Jan 07, 2024 07:34 AM

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: How to find out the IDs of controls and types?
Posted: Tue Jan 09, 2024 07:56 AM
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 :?:
greeting,

Jimmy
Posts: 318
Joined: Fri Jan 14, 2022 08:37 AM
Re: How to find out the IDs of controls and types?
Posted: Tue Jan 09, 2024 08:23 AM
Hi,

Using oWndFromHwnd() function
Code (fw): Select all Collapse
// Example
oWnd:= oWndFromHwnd( GetActiveWindow() )
Regards
Posts: 1772
Joined: Thu Sep 05, 2019 05:32 AM
Re: How to find out the IDs of controls and types?
Posted: Tue Jan 09, 2024 08:35 AM
hi,
paquitohm wrote:Using oWndFromHwnd() function
thx for Answer

i do want Object of Controls not Object of Windows.
greeting,

Jimmy
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: How to find out the IDs of controls and types?
Posted: Tue Jan 09, 2024 06:40 PM

Dear Jimmy,

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

::aControls[ nAt ]

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 318
Joined: Fri Jan 14, 2022 08:37 AM
Re: How to find out the IDs of controls and types?
Posted: Tue Jan 09, 2024 08:52 PM

oWndFromHwnd() returns object control too. Try it !

Posts: 244
Joined: Mon Jun 05, 2006 09:39 PM
Re: How to find out the IDs of controls and types?
Posted: Tue Jan 09, 2024 10:19 PM
Antonio Linares wrote:Dear Giovany,

giovany.prg
Code (fw): Select all Collapse
#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 (fw): Select all Collapse
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
Posts: 244
Joined: Mon Jun 05, 2006 09:39 PM
Re: How to find out the IDs of controls and types?
Posted: Wed Jan 10, 2024 02:14 PM
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 (fw): Select all Collapse
   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
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
Re: How to find out the IDs of controls and types?
Posted: Wed Jan 10, 2024 03:53 PM

Umm, if theme Is active, the label control not change color.only ir theme Is not active.

Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 244
Joined: Mon Jun 05, 2006 09:39 PM
Re: How to find out the IDs of controls and types?
Posted: Wed Jan 10, 2024 05:18 PM
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 (fw): Select all Collapse
 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
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: How to find out the IDs of controls and types?
Posted: Thu Jan 11, 2024 04:32 PM

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.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341