ID exists on dialog!?

ID exists on dialog!?

Postby JC » Thu Sep 18, 2008 1: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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby James Bott » Thu Sep 18, 2008 3:11 pm

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

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby JC » Thu Sep 18, 2008 4: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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby Antonio Linares » Thu Sep 18, 2008 4: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby JC » Thu Sep 18, 2008 4: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:

Code: Select all  Expand view
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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby JC » Thu Sep 18, 2008 5: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
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Postby Antonio Linares » Thu Sep 18, 2008 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
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 74 guests