Antonio, tFolder():Initiate não executa

Post Reply
Rossine
Posts: 343
Joined: Tue Oct 11, 2005 11:33 am

Antonio, tFolder():Initiate não executa

Post by Rossine »

Olá Antonio,

Como faço para que o método INITIATE de TFOLDER seja executado no programa abaixo:

Code: Select all

// Dinamically building a folder ontop of a Dinamic DialogBox

#include "FiveWin.ch"

static oDlg, oFld

//----------------------------------------------------------------------------//

function Main()

   DEFINE DIALOG oDlg TITLE "FiveWin Dynamic folders" ;
      FROM 5, 5 TO 20, 50

   ACTIVATE DIALOG oDlg CENTERED on init INICIO()

return nil

static function INICIO

   @ 0.5, 1 FOLDER oFld PROMPT "&xBase", "&And OOP", "&Power" ;
      OF oDlg SIZE 160, 90 && design

   @ 1, 1 BUTTON "&Hello" OF oFld:aDialogs[ 1 ] ;
     ACTION MsgInfo( "Hello world!" )

return nil

//----------------------------------------------------------------------------//

Gracias,

Rossine.
User avatar
karinha
Posts: 4882
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Post by karinha »

// Dinamically building a folder ontop of a Dinamic DialogBox

#include "FiveWin.ch"

//----------------------------------------------------------------------------//

function Main()

LOCAL oDlg, oFld

DEFINE DIALOG oDlg TITLE "FiveWin Dynamic folders" ;
FROM 5, 5 TO 20, 50

ACTIVATE DIALOG oDlg CENTERED on init INICIO( oDlg, oFld )

return nil

static function INICIO( oDlg, oFld )

@ 0.5, 1 FOLDER oFld PROMPT "&Primeiro", "&Segundo", "&Terceiro" ;
OF oDlg SIZE 160, 90 && design

@ 1, 1 BUTTON "&Hello" SIZE 60,16 OF oFld:aDialogs[ 1 ] ;
ACTION MsgInfo( "Hello world!" )

return nil
João Santos - São Paulo - Brasil
Rossine
Posts: 343
Joined: Tue Oct 11, 2005 11:33 am

Post by Rossine »

Olá João,

Isto não funcionou :cry: Para simular o problema, dentro do fonte FOLDER.PRG no método "INITIATE" coloque um "msgstop( "parando" )",
e você vai ver que ele não é executado.

Agora se voce executrar o programa abaixo, aí funciona.

Code: Select all

// Dinamically building a folder ontop of a Dinamic DialogBox 

#include "FiveWin.ch" 

static oDlg, oFld 

//----------------------------------------------------------------------------// 

function Main() 

   DEFINE DIALOG oDlg TITLE "FiveWin Dynamic folders" ; 
      FROM 5, 5 TO 20, 50


   @ 0.5, 1 FOLDER oFld PROMPT "&xBase", "&And OOP", "&Power" ; 
      OF oDlg SIZE 160, 90 && design 

   @ 1, 1 BUTTON "&Hello" OF oFld:aDialogs[ 1 ] ; 
     ACTION MsgInfo( "Hello world!" ) 

 
   ACTIVATE DIALOG oDlg CENTERED

return nil 

//----------------------------------------------------------------------------// 
Obrigado,

Rossine.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Rossine,

El método Initiate() sólo se ejecuta para controles redefinidos ó para controles que se crean antes de activar el diálogo. En tu ejemplo, el diálogo ya está creado, por eso no se llama a initiate().

Para que necesitas llamar a Initiate() ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
Rossine
Posts: 343
Joined: Tue Oct 11, 2005 11:33 am

Post by Rossine »

Olá Antonio,

O problema é que eu estava fazendo chamada a certas funções dentro do método "initiate", mas fiz as mudanças necessárias e funcionou 100% :lol:

Code: Select all

METHOD New( nTop, nLeft, aPrompts, aDialogs, oWnd, nOption, nClrFore,;
            nClrBack, lPixel, lDesign, nWidth, nHeight, cMsg, lAllWidth,;
            oFont, cMultline, aBitmaps ) CLASS TFolder       && cMultline, aBitmaps = by Rossine

...

   ::Register()

   if ! Empty( oWnd:hWnd )
      #ifdef __CLIPPER__
         ::Create()
      #else
         ::Create( "SysTabControl32" )
         if ! ::aBitmaps == nil   && by Rossine && 15/02/07
            ::SetImageList()      && by Rossine && 15/02/07
         endif                    && by Rossine && 15/02/07
         ::SetPrompts( ::aPrompts )
      #endif
      if oFont != nil
         ::SetFont( oFont )
      elseif oWnd != nil .and. oWnd:oFont != nil
         ::SetFont( oWnd:oFont )
      else
         ::GetFont()
      endif
      oWnd:AddControl( Self )
   else
      oWnd:DefControl( Self )
   endif

   for n = 1 to Len( ::aDialogs )
      DEFINE DIALOG oDlg OF Self STYLE WS_CHILD  ;
         FROM 0, 0 TO ::nHeight() - ::nFdHeight - 5, ::nWidth() - 6 PIXEL ;
         FONT Self:oFont color nClrFore, nClrBack
      ::aDialogs[ n ] = oDlg
      oDlg:cVarName = "Page" + AllTrim( Str( n ) )
   next

   if ! Empty( oWnd:hWnd )
      ::Default()
   endif

   if lDesign
      ::CheckDots()
   endif

   SetWndDefault( oWnd )

   ::AdjustRect()  && 15/02/07          && by Rossine

return Self

Code: Select all

METHOD Initiate( hDlg ) CLASS TFolder

   local n, oBmp := { }
   local aRect

   Super:Initiate( hDlg )

   ::Default()

   #ifndef __CLIPPER__
*           if ! ::aBitmaps == nil   && by Rossine
*             ::SetImageList()      && by Rossine
*           endif                    && by Rossine
*           ::SetPrompts( ::aPrompts )
*           ::AdjustRect()           && by Rossine
   #else
           for n = 1 to Len( ::aDialogs )
              #ifdef __CLIPPER__
                 ::aDialogs[ n ]:SetSize( ::nWidth() - 6,;
                                          ::nHeight() - ::nFdHeight - 5 )
              #else
                 ::aDialogs[ n ]:SetSize( ::nWidth() - 5,;
                                          ::nHeight() - ::nFdHeight - 4 )
              #endif
           next
   #endif

return nil
Gracias,

Rossine.
Post Reply