How to find out the IDs of controls and types?

How to find out the IDs of controls and types?

Postby Giovany Vecchi » Sat Jan 06, 2024 2:49 am

I have a dialog with some controls. Ex:

Code: Select all  Expand view  RUN
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.
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?

Postby Natter » Sat Jan 06, 2024 7: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
Natter
 
Posts: 1224
Joined: Mon May 14, 2007 9:49 am

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

Postby Antonio Linares » Sat Jan 06, 2024 9:30 am

Dear Giovany,

giovany.prg
Code: Select all  Expand view  RUN
#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  RUN
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
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

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

Postby Jimmy » Sun Jan 07, 2024 6: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
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

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

Postby Antonio Linares » Sun Jan 07, 2024 7: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

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

Postby Jimmy » Tue Jan 09, 2024 7: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
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

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

Postby paquitohm » Tue Jan 09, 2024 8:23 am

Hi,

Using oWndFromHwnd() function

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

Regards
paquitohm
 
Posts: 266
Joined: Fri Jan 14, 2022 8:37 am

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

Postby Jimmy » Tue Jan 09, 2024 8:35 am

hi,
paquitohm wrote:Using oWndFromHwnd() function

thx for Answer

i do want Object of Controls not Object of Windows.
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

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

Postby Antonio Linares » Tue Jan 09, 2024 6:40 pm

Dear Jimmy,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

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

Postby paquitohm » Tue Jan 09, 2024 8:52 pm

oWndFromHwnd() returns object control too. Try it !
paquitohm
 
Posts: 266
Joined: Fri Jan 14, 2022 8:37 am

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

Postby Giovany Vecchi » Tue Jan 09, 2024 10:19 pm

Antonio Linares wrote:Dear Giovany,

giovany.prg
Code: Select all  Expand view  RUN
#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  RUN
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?

Postby Giovany Vecchi » Wed Jan 10, 2024 2: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: Select all  Expand view  RUN
  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
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?

Postby carlos vargas » Wed Jan 10, 2024 3: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)
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?

Postby Giovany Vecchi » Wed Jan 10, 2024 5: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: Select all  Expand view  RUN
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
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?

Postby karinha » Thu Jan 11, 2024 4: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
User avatar
karinha
 
Posts: 7835
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 32 guests