Check if ID exist in resource

Check if ID exist in resource

Postby Marc Vanzegbroeck » Sun Jan 15, 2012 10:29 am

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  Expand view
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
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Check if ID exist in resource

Postby Antonio Linares » Sun Jan 15, 2012 12:56 pm

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
User avatar
Antonio Linares
Site Admin
 
Posts: 41469
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Check if ID exist in resource

Postby Marc Vanzegbroeck » Sun Jan 15, 2012 7:33 pm

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
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Check if ID exist in resource

Postby IBTC » Sun Jan 15, 2012 7:52 pm

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  Expand view

aControl := aGetDlgControl( cResource )

...

   DEFINE DIALOG oDlg  NAME cResource

...

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


Code: Select all  Expand view
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
User avatar
IBTC
 
Posts: 103
Joined: Sat Oct 18, 2008 8:13 pm
Location: Stuttgart, Germany

Re: Check if ID exist in resource

Postby Marc Vanzegbroeck » Sun Jan 15, 2012 8:06 pm

Thanks Ruediger,

This is working fine!

Regards,
Marc
Regards,
Marc

FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Marc Vanzegbroeck
 
Posts: 1157
Joined: Mon Oct 17, 2005 5:41 am
Location: Belgium

Re: Check if ID exist in resource

Postby Antonio Linares » Sun Jan 15, 2012 10:11 pm

Very good solution :-)
regards, saludos

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 142 guests