How to find out the IDs of controls and types?

User avatar
Giovany Vecchi
Posts: 223
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

How to find out the IDs of controls and types?

Post by Giovany Vecchi »

I have a dialog with some controls. Ex:

Code: Select all | Expand

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.
Natter
Posts: 1241
Joined: Mon May 14, 2007 9:49 am

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

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 42520
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

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

Post by Antonio Linares »

Dear Giovany,

giovany.prg

Code: Select all | Expand

#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

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
User avatar
Jimmy
Posts: 1740
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany
Has thanked: 2 times

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

Post 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
greeting,
Jimmy
User avatar
Antonio Linares
Site Admin
Posts: 42520
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

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

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Jimmy
Posts: 1740
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany
Has thanked: 2 times

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

Post 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 :?:
greeting,
Jimmy
paquitohm
Posts: 287
Joined: Fri Jan 14, 2022 8:37 am
Been thanked: 1 time

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

Post by paquitohm »

Hi,

Using oWndFromHwnd() function

Code: Select all | Expand

// Example
oWnd:= oWndFromHwnd( GetActiveWindow() )
 
Regards
User avatar
Jimmy
Posts: 1740
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany
Has thanked: 2 times

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

Post by Jimmy »

hi,
paquitohm wrote:Using oWndFromHwnd() function
thx for Answer

i do want Object of Controls not Object of Windows.
greeting,
Jimmy
User avatar
Antonio Linares
Site Admin
Posts: 42520
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 31 times
Been thanked: 75 times
Contact:

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

Post by Antonio Linares »

Dear Jimmy,

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

Antonio Linares
www.fivetechsoft.com
paquitohm
Posts: 287
Joined: Fri Jan 14, 2022 8:37 am
Been thanked: 1 time

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

Post by paquitohm »

oWndFromHwnd() returns object control too. Try it !
User avatar
Giovany Vecchi
Posts: 223
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

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

Post by Giovany Vecchi »

Antonio Linares wrote:Dear Giovany,

giovany.prg

Code: Select all | Expand

#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

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
User avatar
Giovany Vecchi
Posts: 223
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

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

Post 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

   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
 
User avatar
carlos vargas
Posts: 1721
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

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

Post by carlos vargas »

Umm, if theme Is active, the label control not change color.only ir theme Is not active.
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
Giovany Vecchi
Posts: 223
Joined: Mon Jun 05, 2006 9:39 pm
Location: Brasil

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

Post 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

 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
 
User avatar
karinha
Posts: 7935
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil
Been thanked: 3 times
Contact:

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

Post 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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Post Reply