James:
James Bott wrote:Luis,
Hey, I was wondering what happened to you, Luis. Good to see you on the forum again.
To say I've been busy would be a understatement.
I've worked a ton with splitters, this one just gave me the run for my money.
But in the end, I won
Here's a modified testtree.prg and testtree.rc to show what I was looking for. Note that I assign oWnd:bResized inside the ON INIT block.. this is part of the trick to make sure things paint as they should upon initialization.
**
Antonio::
this
oTree:GetSelected():SetText( Time() )
gpf's (last btnbar action)
using FWH 2.7 from March
**
Code: Select all
// -- testtre2.rc
open BITMAP "../bitmaps/16x16/open.bmp"
close BITMAP "../bitmaps/16x16/close.bmp"
textbox BITMAP "../bitmaps/16x16/textbox.bmp"
folder BITMAP "../bitmaps/16x16/folder.bmp"
fldmask BITMAP "../bitmaps/16x16/fldmask.bmp"
form BITMAP "../bitmaps/16x16/form.bmp"
frmask BITMAP "../bitmaps/16x16/frmmask.bmp"
icon BITMAP "../bitmaps/16x16/icon.bmp"
icoMask BITMAP "../bitmaps/16x16/icomask.bmp"
bitmap BITMAP "../bitmaps/16x16/bitmap.bmp"
bmpMask BITMAP "../bitmaps/16x16/bmpmask.bmp"
#ifdef __FLAT__
1 24 ".\winxp\WindowsXP.Manifest"
#endif
#ifdef __64__
1 24 "WinXP/WindowsXP.Manifest64"
#endif
// --
// -- testtre2.prg
// WinAPI Trees (SysTreeView32) !!!
// Window with a Tree, a Vertical Splitter & a resizable dialog
#include "FiveWin.ch"
#include "Splitter.ch"
//----------------------------------------------------------------------------//
function Main()
local oWnd, oDlg, oBar, oTree, oItem1, oItem2, oImageList, oSplit
DEFINE WINDOW oWnd FROM 3, 6 TO 20, 70 ;
TITLE "Welcome to " + FWVERSION
DEFINE BUTTONBAR oBar OF oWnd _3D
DEFINE BUTTON RESOURCE "open" OF oBar ACTION oTree:aItems[ 1 ]:Expand() ;
TOOLTIP "Expand" NOBORDER
DEFINE BUTTON RESOURCE "close" OF oBar ACTION oTree:aItems[ 1 ]:Colapse() ;
TOOLTIP "Colapse" NOBORDER
DEFINE BUTTON RESOURCE "open" OF oBar ACTION oTree:ExpandAll() ;
TOOLTIP "Expand all items" NOBORDER
DEFINE BUTTON RESOURCE "close" OF oBar ACTION oTree:ColapseAll() ;
TOOLTIP "Colapse all items" NOBORDER
// note: next one gpf
DEFINE BUTTON RESOURCE "textbox" OF oBar ACTION if( oTree:GetSelected() # nil, oTree:GetSelected():SetText( Time() ), nil ) ;
TOOLTIP "Change Text" NOBORDER
oImageList := TImageList():New() // imagelist items are zero-based!
oImageList:Add( TBitmap():Define( "folder",, oWnd ), ; // nImage == 0 (default if not specified)
TBitmap():Define( "fldMask",, oWnd ) )
oImageList:Add( TBitmap():Define( "form",, oWnd ), ; // nImage == 1
TBitmap():Define( "frmMask",, oWnd ) )
oImageList:Add( TBitmap():Define( "icon",, oWnd ),; // nImage == 2
TBitmap():Define( "icoMask",, oWnd ) )
oImageList:Add( TBitmap():Define( "bitmap",, oWnd ),; // nImage == 4
TBitmap():Define( "bmpMask",, oWnd ) )
oTree := TTreeView():New( 2, 0, oWnd )
oTree:bChanged := {|oTree,oItem| ;
oWnd:SetText( If( oTree:GetSelected():GetParent() != nil,;
oTree:GetSelected():GetParent():cPrompt + " + ", "" ) + ;
oTree:GetSelText() ), ;
oItem := oTree:GetSelected(), ;
If( oItem # nil .and. ValType( oItem:cargo ) == "B", Eval( oItem:cargo ), nil ) }
oTree:SetImageList( oImageList )
oItem1 := oTree:Add( "Hello world!" ) // uses folder bmp
oItem1:Add( "xBase & OOPS", 1, {|| Test1( oDlg ) } ) // uses form bmp
oItem2 := oItem1:Add( "Clipper 5" )
oItem2:Add( "Another", 2, {|| Test2( oDlg ) } ) // uses icon bmp
oItem2:Add( "item", 2 )
oItem2 := oItem2:Add( "and..." )
oItem2:Add( "more items", 3 ) // uses bmp bmp
oTree:Add( "FiveWin power!" )
oItem2 := oTree:Add( Time() )
oItem2:Add( Time(), 1 )
SET MESSAGE OF oWnd TO FWVERSION NOINSET CLOCK DATE KEYBOARD
DEFINE DIALOG oDlg OF oWnd ;
STYLE nOR( WS_CHILD, WS_VISIBLE ) ;
@ 29, 200 SPLITTER oSplit ;
VERTICAL _3DLOOK ;
PREVIOUS CONTROLS oTree ;
HINDS CONTROLS oDlg ;
SIZE 4, 200 PIXEL ;
LEFT MARGIN 20 ;
RIGHT MARGIN 25 ;
OF oWnd
ACTIVATE DIALOG oDlg NOMODAL
ACTIVATE WINDOW oWnd ;
ON INIT ( oDlg:Move( 0, oSplit:nRight, oWnd:nWidth, oWnd:nHeight, .f. ), ;
oWnd:bResized := {|| oSplit:AdjClient(), oDlg:SetSize( oWnd:nWidth - oTree:nWidth - oSplit:nWidth - 8, oSplit:nHeight - 1, .t. ) }, ;
oDlg:refresh(.t.), oTree:refresh(.t.) ) // required so that objects around splitter paint correctly on init
oImageList:End()
return nil
//----------------------------------------------------------------------------//
static function CleanSlate( oDlg )
while Len( oDlg:aControls ) > 0
ATail( oDlg:aControls ):end()
end
return nil
//----------------------------------------------------------------------------//
static function Test1( oDlg )
Local oGet1, oGet2
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
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
Return nil
//----------------------------------------------------------------------------//
procedure AppSys // Xbase++ requirement
return
//----------------------------------------------------------------------------//
Regards,
Luis Krause