ERROR ON TREEVIEW CPROMPT

ERROR ON TREEVIEW CPROMPT

Postby Silvio » Wed Mar 17, 2010 8:04 am

I try to run this sample test
I cannot show the bmps on each tree and
when I click on option tree it make error on CPROMPT

why ????

some help please

Code: Select all  Expand view

#include "FiveWin.ch"
#include "Splitter.ch"

//----------------------------------------------------------------------------//
STATIC aResize := {}
function Main()

   local oWnd, oDlg, oBar, oTree, oItem1, oItem2, oImageList, oSplit

   DEFINE WINDOW oWnd FROM 3, 6 TO 20, 70 ;
      TITLE "System Configuration "  COLOR "N/W"


   oImageList = TImageList():New()

   oBmp1 = TBitmap():Define( "open",, oWnd )
   oBmp2 = TBitmap():Define( "close",, oWnd )

   oImageList:Add( oBmp1, oBmp2 )



   oTree := TTreeView():New( 2, 0, oWnd )
   oTree:nWidth := 100

   oTree:bChanged := { | oItem | oItem := oTree:GetSelected(), If( ValType( oItem:Cargo ) == "B", Eval( oItem:Cargo ),) }




   oTree:SetImageList( oImageList )




   oTree:Add( "Generale", 1 ):Cargo = {|| Test1( oDlg ) }
   oTree:Add( "Collegamento", 1 ):Cargo = {|| Test2( oDlg ) }
   oTree:Add( "Licenza", 1 ):Cargo = {|| Test2( oDlg ) }
   oTree:Add( "Page - 4", 1 ):Cargo = {|| Test2( oDlg ) }
   oTree:Add( "Page - 5", 1 ):Cargo = {|| Test2( oDlg ) }





   DEFINE DIALOG oDlg OF oWnd ;
      STYLE nOR( WS_CHILD, WS_VISIBLE ) ;

   @ 29, 100 SPLITTER oSplit ;
      VERTICAL _3DLOOK ;
      PREVIOUS CONTROLS oTree ;
      HINDS CONTROLS oDlg ;
      SIZE 4, 100 PIXEL ;
      LEFT MARGIN 20 ;
      RIGHT MARGIN 25 ;
      OF oWnd

   ACTIVATE DIALOG oDlg NOMODAL

   ACTIVATE WINDOW oWnd ;
      ON INIT Wnd_Init(oWnd, oDlg, oSplit, oTree)

    oImageList:End()
   oBmp1:End()
   oBmp2:End()
return nil

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

static function Wnd_Init(oWnd, oDlg, oSplit, oTree)
   oDlg:Move( 0, oSplit:nRight, oWnd:nWidth, oWnd:nHeight, .f. )
   //oDlg:bResized := {|| Dlg_Resize(oDlg) }
   oWnd:bResized := {|| Wnd_Resize(oWnd, oDlg, oSplit, oTree) }
   oDlg:refresh(.t.)
   oTree:refresh(.t.) // required so that objects around splitter paint correctly on init
return .t.

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

static function Wnd_Resize(oWnd, oDlg, oSplit, oTree)
   oSplit:AdjClient()
   oDlg:SetSize( oWnd:nWidth - oTree:nWidth - oSplit:nWidth - 8, oSplit:nHeight - 1,.t.)
   Button_Aligment(oDlg)
return .t.

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

static function Button_Aligment(oDlg)
   local n := 1
   local oControl, oRadMenu
   local i, lbul:=.f.

   if Len( oDlg:aControls ) > 0 .and. Len(Aresize) > 0

         //MsgInfo (Len( oDlg:aControls ))

      while n <= Len( oDlg:aControls )
         oControl := oDlg:aControls[ n ]
//         MsgInfo(oDlg:aControls[ n ]:nID)
//         MsgInfo(oDlg:aControls[ n ]:cVarName)
//         If Upper( oDlg:aControls[ n ]:ClassName() ) == 'TBUTTON'
         for i:=1 to len(aResize)
            if aResize[i]=oControl:nID
               lbul=.t.
               exit
            endif
         next i
         if lbul
            If Upper( oControl:ClassName() ) == 'TBUTTON'
               oControl:nTop := oDlg:nHeight-30
            elseIf Upper( oControl:ClassName() ) == 'TGROUP'
               oControl:nTop := oDlg:nHeight-40
               oControl:nBottom := oDlg:nHeight-40
               oControl:nWidth := oDlg:nWidth
           endif
           oControl:refresh(.t.)
         endif
         n++
         //MsgInfo(n)
      end
      //MsgInfo("Bitti")

   end
return .t.

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

static function CleanSlate( oDlg )

   while Len( oDlg:aControls ) > 0
      ATail( oDlg:aControls ):end()
   end
   if len(aResize) > 0
      aResize := {}
   endif

return nil

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

static function Test1( oDlg )
   Local oGet1, oGet2, oBtnOK, oBtnCancel, oGrp
   Local cGet1 := PadR( "Type something!", 50 )
   Local cGet2 := PadR( "Type something else!", 50 )

   CleanSlate( oDlg )
   @ 5,10 Say "Some data:" Of oDlg Pixel
   @ 3,70 Get oGet1 Var cGet1 Of oDlg Pixel ;
      Size 150,22

   @ 30,10 Say "Other data:" Of oDlg Pixel
   @ 28,70 Get oGet2 Var cGet2 Of oDlg Pixel ;
      Size 150,22
  @ 0, 0 GROUP oGrp TO 0,0 PROMPT "" Pixel
  oGrp:nClrText := CLR_BLACK


  @ 100, 10 BUTTON oBtnOK PROMPT "&Salva" Of oDlg Pixel Size 100,25
  @ 100,120 BUTTON oBtnCancel PROMPT "&Annulla" Of oDlg Pixel Size 100,25

   add_AResize(oBtnCancel:nId)
   add_AResize(oBtnOK:nId)
   add_AResize(oGrp:nId)

   Button_Aligment(oDlg)

Return nil

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

static function Test2( oDlg )
   Local oCbx1, oChk1
   Local cCbx1 := "", lChk1 := .t.

   CleanSlate( oDlg )

   @ 5,10 Say "Choose:" Of oDlg Pixel

   @ 3,70 Combobox oCbx1 Var cCbx1 Of oDlg Pixel ;
      Items { "Uno", "Dos", "Tres", "Mambo!" } ;
      Size 80,18

   @ 28,70 Checkbox oChk1 Var lChk1 Of oDlg Pixel ;
      Prompt "Tick tock tick tock" ;
      Size 150,22

   @ 0, 0 GROUP oGrp TO 0,0 PROMPT "" Pixel

   oGrp:nClrText := CLR_BLACK


   @ 100, 10 BUTTON oBtnOK PROMPT "OK" Of oDlg Pixel Size 100,25
   @ 100,120 BUTTON oBtnCancel PROMPT "Cancel" Of oDlg Pixel Size 100,25


   add_AResize(oBtnCancel:nId)
   add_AResize(oBtnOK:nId)
   add_AResize(oGrp:nId)
   Button_Aligment(oDlg)

Return nil

//----------------------------------------------------------------------------//
procedure add_aresize(xp1)
   local i, lbul:=.f.
   for i:=1 to len(aResize)
      if aResize[i]=xp1
         lbul=.t.
         exit
      endif
   next i
   if !lbul
      aadd(aResize, xp1)
   endif
return

 




the rc file

open BITMAP "bmp1.bmp"
close BITMAP "bmp2.bmp"
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 100 guests