Check if ID exist in resource

Post Reply
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Check if ID exist in resource

Post by Marc Vanzegbroeck »

Hi,

Is there a way to check if an ID exist in a resource.
I want to use the same program for different customers, and some customers don't a some input-fields (option).
I can offcource add the field in the resource of all customers, an hide, or disable it if it is not available, but sometimes I want to use
that place for something else for that customer.
So I want someting like:

Code: Select all

IF existid(201)
    REDEFINE GET test   ID 201 OF oDlg
ENDIF
 
Is this possible?

Thanks,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Check if ID exist in resource

Post by Antonio Linares »

Marc,

You could use:

GetDlgItem( hDlg, nID ) --> hControl

hControl will be zero if such control does not exist.

The problem with this function is that you can not use it until you have the hWnd of the dialog, in other words: it will only work from the ON INIT clause:

ACTIVATE DIALOG oDlg ON INIT CheckControlsAndRedefineThem()
regards, saludos

Antonio Linares
www.fivetechsoft.com
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Re: Check if ID exist in resource

Post by Marc Vanzegbroeck »

Antonio,

GetDlgItem( hDlg, nID ) allways returned 0 but oDlg:getitem(nID) is working fine.
The only problem I have now is to redefine a control in the function called in the ON INIT,it doesn't work.
Is it an other syntax I have to use?

Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
User avatar
IBTC
Posts: 103
Joined: Sat Oct 18, 2008 8:13 pm
Location: Stuttgart, Germany
Contact:

Re: Check if ID exist in resource

Post by IBTC »

Hi Marc,
Marc Vanzegbroeck wrote: The only problem I have now is to redefine a control in the function called in the ON INIT,it doesn't work.
Maybe this will be a solution: first find out what controls are there, put it in e.g. aControl and use this information in the Redefine-section.

Code: Select all

aControl := aGetDlgControl( cResource )

...

   DEFINE DIALOG oDlg  NAME cResource

...

IF ASCAN( aControl, 3002 )>0
    REDEFINE ... ID 3002 OF oDlg
ENDIF
 

Code: Select all

FUNCTION aGetDlgControl( cResource )

   local oDlg
   local aControl := {}

   DEFINE DIALOG oDlg NAME cResource

   oDlg:Hide()

   ACTIVATE DIALOG oDlg;
         ON INIT( aControl := _aGetControl( oDlg:hWnd ), oDlg:End() )

return aControl

function _aGetControl( hDlg )

   local hCtrl    := GetWindow( hDlg, GW_CHILD )
   local aControl := {}

   while hCtrl != 0 .and. GetParent( hCtrl ) == hDlg
      AADD( aControl, GetWindowLong( hCtrl, GWL_ID ) )
      hCtrl = GetWindow( hCtrl, GW_HWNDNEXT )
   end

return aControl
 
Best Regards,
Ruediger Alich

---
HMG 3.1.3 | FTDN/FWH 13.12 | Harbour 3.2 | BCC/MinGW | Windows XP/Vista/7/8/10 (32/64-Bit), Wine (Linux/Mac) - started 1999 with FW, 1989 with Clipper
Marc Vanzegbroeck
Posts: 1102
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium
Contact:

Re: Check if ID exist in resource

Post by Marc Vanzegbroeck »

Thanks Ruediger,

This is working fine!

Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Check if ID exist in resource

Post by Antonio Linares »

Very good solution :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply