FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour ID exists on dialog!?
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
ID exists on dialog!?
Posted: Thu Sep 18, 2008 01:27 PM

How I can check if a id resource exists on a dialog... from resource!?

Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
ID exists on dialog!?
Posted: Thu Sep 18, 2008 03:11 PM

Try to redefine it and see if it errors out; use a new error codeblock to trap the error and recover.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
ID exists on dialog!?
Posted: Thu Sep 18, 2008 04:39 PM
James Bott wrote:Try to redefine it and see if it errors out; use a new error codeblock to trap the error and recover.

James

James,
Thank you... Really, I want to check if same id resource exists before redefine it! It's possible?
Some like a loop into oDlg:aControls or another thing for test if same id (i.e. 4001) exists...
Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
ID exists on dialog!?
Posted: Thu Sep 18, 2008 04:42 PM

Julio,

You can create the dialog without redefining any control from it:

DEFINE DIALOG oDlg RESOURCE "test"

ACTIVATE DIALOG oDlg ON INIT MsgInfo( GetDlgItem( oDlg:hWnd, nID ) )

if you get a zero, then such ID is not defined.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
ID exists on dialog!?
Posted: Thu Sep 18, 2008 04:53 PM
Antonio Linares wrote:Julio,

You can create the dialog without redefining any control from it:

DEFINE DIALOG oDlg RESOURCE "test"

ACTIVATE DIALOG oDlg ON INIT MsgInfo( GetDlgItem( oDlg:hWnd, nID ) )

if you get a zero, then such ID is not defined.

Antonio,

I have created this function for our application:

FUNCTION getObjById( oDlg, nId )

LOCAL nLin := 0

DEFAULT oDlg := if( getWndDefault() == NIL, getWnd(), getWndDefault() ), ;
        nId  := 0


IF !empty( nId )

   FOR nLin := 1 TO len( oDlg:aControls )

       IF ( ( oDlg:aControls[nLin] ):nId == nId )
          RETURN( oDlg:aControls[nLin] )
       ENDIF

   NEXT

ENDIF

RETURN( NIL )


But, this function GetDlgItem( oDlg:hWnd, nID ) do the same test! Outch!
With this, it's possible to determinate if a id from a resource exists?
Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 445
Joined: Thu Feb 21, 2008 11:58 AM
ID exists on dialog!?
Posted: Thu Sep 18, 2008 05:01 PM
James and Antonio,

I have put a Text objeto from Pelles C into a dialog with id 102!
When I calling msgInfo( getDlgItem( oDlg:hWnd, 102 ) ), this returns 0 to me... It's correct? Or I made the wrong way?
Peace and lighting!

JĂșlio CĂ©sar M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
ID exists on dialog!?
Posted: Thu Sep 18, 2008 06:53 PM

Julio,

Are you calling it from the ON INIT of the dialog ?

ACTIVATE DIALOG oDlg ON INIT msgInfo( getDlgItem( oDlg:hWnd, 102 ) )

So oDlg has a valid Windows handle.

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion