FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Check if ID exist in resource
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Check if ID exist in resource
Posted: 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 (fw): Select all Collapse
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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Check if ID exist in resource
Posted: 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
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: Check if ID exist in resource
Posted: Sun Jan 15, 2012 07: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
Posts: 103
Joined: Sat Oct 18, 2008 08:13 PM
Re: Check if ID exist in resource
Posted: Sun Jan 15, 2012 07: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 (fw): Select all Collapse
aControl := aGetDlgControl( cResource )

...

   DEFINE DIALOG oDlg  NAME cResource

...

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


Code (fw): Select all Collapse
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
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: Check if ID exist in resource
Posted: Sun Jan 15, 2012 08:06 PM

Thanks Ruediger,

This is working fine!

Regards,
Marc

Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Check if ID exist in resource
Posted: Sun Jan 15, 2012 10:11 PM

Very good solution :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion