Hello everybody:
I'm using the TreeView class (SysTreeView32) for the first time and I'm trying to deploy something similar to what you have when you open
a chm help file:
a) a tree on the left
b) a splitter on the middle
c) a nonmodal dialog or a tpanel or whatever works to display info on the right side.
So far I'm stumped so I'm asking for a bit of help here. I'm using testtree.prg from the samples folders as a start, but neither of the following works. Any hints?
....
oPanel := TPanel():New( 0, 0, 75, 300, oWnd )
@ 29, 200 SPLITTER oSplit ;
VERTICAL _3DLOOK ;
PREVIOUS CONTROLS oTree ;
;//HINDS CONTROLS oPanel ;
SIZE 4, 200 PIXEL ;
LEFT MARGIN 20 ;
RIGHT MARGIN 25 ;
OF oWnd
oPanel:oLeft := oSplit
ACTIVATE WINDOW oWnd ;
ON RESIZE oSplit:AdjClient()
nor:
...
DEFINE DIALOG oDlg OF oWnd ;
STYLE nOR( WS_CHILD, WS_VISIBLE ) ;
COLOR CLR_WHITE, CLR_BLUE // color just to see where it's painting
@ 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 RESIZE oSplit:AdjClient()
...
Any ideas and experience with the native Windows tree class is very much appreciated.
Regards,
Luis Krause
TreeView & Splitters
- Luis Krause
- Posts: 59
- Joined: Tue Oct 11, 2005 1:39 am
- Location: Vancouver, Canada
TreeView & Splitters
"May the Source be with GNU"
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Luis Krause
- Posts: 59
- Joined: Tue Oct 11, 2005 1:39 am
- Location: Vancouver, Canada
Antonio:
Thanks for the quick reply.
That sample actually answered another question I had, which was how to assign different bmp to different branches in the tree. So thanks for reading my mind before I even posted the question
What I'm still battling is how to place a TDialog or TPanel object to the
*right* of the vertical splitter, so that I have a sort of canvar on which to deploy whatever text or graphics I might need.
In the past I've embeded a dialog with no caption inside a window to which I place controls on. Whenever the windows is resized, I automatically resize the embeded dlg with something like
oWnd:bResized := {|| ;
oDlg:Move( 0, 0, oIFWnd:nWidth, oWnd:nHeight, .t. ) }
I'm trying to achive a similar thing but I seem to have hit a wall!
I'm sure the answer is right in front of me, but I just can't see it.
Thanks for the quick reply.
That sample actually answered another question I had, which was how to assign different bmp to different branches in the tree. So thanks for reading my mind before I even posted the question
What I'm still battling is how to place a TDialog or TPanel object to the
*right* of the vertical splitter, so that I have a sort of canvar on which to deploy whatever text or graphics I might need.
In the past I've embeded a dialog with no caption inside a window to which I place controls on. Whenever the windows is resized, I automatically resize the embeded dlg with something like
oWnd:bResized := {|| ;
oDlg:Move( 0, 0, oIFWnd:nWidth, oWnd:nHeight, .t. ) }
I'm trying to achive a similar thing but I seem to have hit a wall!
I'm sure the answer is right in front of me, but I just can't see it.
Antonio Linares wrote:Luis,
You may review samples\re.prg
"May the Source be with GNU"
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Luis,
Hey, I was wondering what happened to you, Luis. Good to see you on the forum again.
You must be close to seeing the fall colors up there?
James
Hey, I was wondering what happened to you, Luis. Good to see you on the forum again.
Resizing is handled by the splitter. Take a look at the syntax in the splitter examples testspl1.prg - testspl6.prg.In the past I've embeded a dialog with no caption inside a window to which I place controls on. Whenever the windows is resized, I automatically resize the embeded dlg with something like...
You must be close to seeing the fall colors up there?
James
- Luis Krause
- Posts: 59
- Joined: Tue Oct 11, 2005 1:39 am
- Location: Vancouver, Canada
James:
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
**
Regards,
Luis Krause
To say I've been busy would be a understatement.James Bott wrote:Luis,
Hey, I was wondering what happened to you, Luis. Good to see you on the forum again.
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
//----------------------------------------------------------------------------//
Luis Krause
"May the Source be with GNU"
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Luis Krause
- Posts: 59
- Joined: Tue Oct 11, 2005 1:39 am
- Location: Vancouver, Canada
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Luis,
This change is needed in source\winapi\treeview.c. Now it works fine:
This change is needed in source\winapi\treeview.c. Now it works fine:
Code: Select all
#ifdef __HARBOUR__
CLIPPER TVSETITEMTEXT( PARAMS ) // ( hWnd, hItem, cText )
#else
CLIPPER TVSETITEMT( PARAMS ) // EXT( hWnd, hItem, cText )
#endif
{
HWND hWnd = ( HWND ) _parnl( 1 );
TV_ITEM tvi;
BOOL bResult;
BYTE buffer[ 100 ];
tvi.hItem = ( HTREEITEM ) _parnl( 2 );
tvi.mask = TVIF_TEXT;
tvi.pszText = ( char * ) buffer;
tvi.cchTextMax = sizeof( buffer );
bResult = TreeView_GetItem( hWnd, &tvi );
if( bResult )
{
tvi.mask = TVIF_TEXT;
tvi.hItem = ( HTREEITEM ) _parnl( 2 );
tvi.pszText = _parc( 3 );
tvi.cchTextMax = _parclen( 3 );
TreeView_SetItem( hWnd, &tvi );
}
}
- Luis Krause
- Posts: 59
- Joined: Tue Oct 11, 2005 1:39 am
- Location: Vancouver, Canada