Professional Documents
Culture Documents
version 6.5
www.4GL.fr
This freeware is delivered as "as-is" software and no responsibility can be assumed in any case of malfunctions.
If you want to be informed of new versions and updates, you just need to subscribe to the 4GL mailing list.
The 4GLTreeview is an Active-x control developed by Marcel FONDACCI (m.fondacci@4gl.fr) from 4GL. It is an 'easy to use' OCX
Treeview based on VirtualTreeview. This control is not richer than other similar commercial controls, but in many cases, the problem to
be solved is quite simple… and the complexity of these controls becomes THE problem.
You'll find it easier to use and efficient with reasonable (and understandable) code to get a good result.
You can change size, font, color, image list, node expansion... Based on code well understood by PROGRESS users (like variable lists), it's
easy to integrate within your PROGRESS application.
You'll find demo programs (to use with a sports database): *.w to show the basics.
The use of this control is free. You can distribute freely your applications with this control.
This freeware is delivered as "as-is" software and no responsibility can be assumed in any case of malfunctions.
Marcel
Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
either express or implied. See the License for the specific language governing rights and limitations under the
License.
The initial developer of the original code is digital publishing AG (Munich, Germany, www.digitalpublishing.de),
most code was written by Mike Lischke 2000-2009 (public@soft-gems.net, www.soft-gems.net)
2
www.4GL.fr TREEVIEW4GL
History of changes:
3
www.4GL.fr TREEVIEW4GL
❖ 16-jan-2005:
Added properties: fontName and fontSize are accessible at run-time to change the value of the standard font.
Alternate image list with new icons has been added.
4
www.4GL.fr TREEVIEW4GL
64bit considerations
The major problem with the 64 bits version is that the 'node handle' which is a 32 bits integer becomes a 64 bits
integer.
Example:
DEF VAR A AS CHAR NO-UNDO.
DEF VAR ChildrenNumber AS INT NO-UNDO.
A = {&hTreeview}:GetSelectedNode().
5
www.4GL.fr TREEVIEW4GL
TreeView LOADING :
Parameters :
<Char variable> is a ~n delimited variable.
Each node of the treeview is separated by a "~n", each tree line is a list delimited by tabs (~t).
General Format :
A = "<Line 1 attributes>~n<Line 2 attributes> …………………".
Line Format :
Each attribute line is a tab delimited field wich contains :
With the 2.3 version, it's possible to set a second image number in the normal image index. If you specify a second image
number, then Treeview4GL.ocx will display this 2nd image when the node is expanded and return to the first one if the
node is collapsed.
Example :
Def var A as char no-undo.
a = substring(a, 2).
chTreeView:TreeView4GL:clear().
chTreeView:TreeView4GL:addnodes(a).
Note :
• The state image number is a number between –1 and 16.
• This kind of structure level,title,index1,index2,index3,private-data is a common structure to TreeView4GL.
• Important performance issue ( jul-2000): if the number of nodes added by a single addnodes() is important, you may
encounter an excessive response time due to the splitting of this large area into individual entries. This would be updated
in future versions but at this time, use the following :
chTreeView.Treeview4GL:TreeRefresh = False.
For each … … /* file to load */
… … /* Node constitution in A */
chTreeview.Treeview4GL:addnodes( A ). /* a single node at a time */
end.
chTreeView.Treeview4GL:TreeRefresh = True.
6
www.4GL.fr TREEVIEW4GL
TreeView CLEAR :
<Component-Handle frame>:TreeView4GL:clear().
Parameters :
None.
Parameters :
Return parameter is a character variable with the following format :
Node number
Chr(1)
Node Handle
Chr(1)
<Tab> separated list. Same format as AddNodes() :
The level
The title
The Normal image numbers
The selected image number
The state image number
The 'PRIVATE-DATA'
Level (1 to n) MANDATORY
Title MANDATORY
Normal image numbers MANDATORY
Selected image number MANDATORY
State image number OPTIONAL
'PRIVATE-DATA' OPTIONAL
The return parameter NodeInfo gives the node information of the newly created node.
Since the version 3.2, the nodenumber returned in the output nodeInfo parameter has a node number of ''. You have to
explicitly insert a gethNode( <node handle> ) to retrieve it.
Note :
The level determines how the new node is inserted:
- When Level = <#SelectedNode> level, add of a new BROTHER node
- When Level > <#SelectedNode> level, add of a new CHILD node
- When Level = 1, add of a new root node
7
www.4GL.fr TREEVIEW4GL
Change a node :
<Component-Handle frame>:TreeView4GL:changeNode(
<#SelectedNode>,
<Node Description>
).
8
www.4GL.fr TREEVIEW4GL
Return value :
Node Number from 0,
Chr(1)
Node Handle,
Chr(1)
NodeAttributes (See the Node Attributes format in addnodes() )
Goto Node :
< Component-Handle frame>:TreeView4GL:GotoNode( <NodeNumber> ).
Node delete :
<Component-Handle frame>:TreeView4GL:DeleteNode( <NodeNumber> ).
Note :
DeleteNode frees the memory allocated to the node with his 'PRIVATE-DATA' extension. But in case of
a parent node, the children are deleted too, without freeing the PRIVATE-DATA area of the sub-nodes.
At this time, it's your responsibility to delete all the children first.
9
www.4GL.fr TREEVIEW4GL
It is very easy to manipulate the TreeView. Note that all the following methods use node handles, not node numbers.
Navigation :
<Integer variable> =
<Component-Handle frame>:TreeView4GL:FirstChild( <NodeHandle> ).
<Integer variable> =
<Component-Handle frame>:TreeView4GL:LastChild( <NodeHandle> ).
<Integer variable> =
<Component-Handle frame>:TreeView4GL:NextSibling( <NodeHandle> ).
Returns the Handle of the next sibling node for this level.
(zero if not available);
A sequential navigation in all the Treeview can be done, using the absolute node number:
do i = 1 to chChTreeview:TreeView4GL:ChildrenNumber( 0 ):
a = chChTreeview:TreeView4GL:GetNode( I - 1). /* Node number is relative
to 0 */
message "Node number" entry(1, a, chr(1)) skip
"Private Data" entry(6, a, "~t")
skip(1)
"Do you wish to continue ?" view-as alert-box QUESTION
buttons yes-no update OK.
OR
message "Node number" { nodeNumber.i a } skip
"Private Data" { nodeprivate.i a }
skip(1)
"Do you wish to continue ?" view-as alert-box QUESTION
buttons yes-no update OK.
if not ok then leave.
end.
<Character variable> =
<Component-Handle frame>:TreeView4GL:getParent( <NodeHandle>).
10
www.4GL.fr TREEVIEW4GL
If you want to reduce a particular handle set the Expanded attribute to TRUE, a FALSE value collapses the
arborescence of this node.
Or in a on-off mode :
chChTreeview:TreeView4GL:Expanded( hNode ) =
NOT chChTreeview:TreeView4GL:Expanded( hNode ).
Programming note :
The expand attribute controls the expand or collapse of a node handle, not of the depending sub-nodes. So
if you expand a previously collapsed node, the sub-nodes remains in the state they had before.
Treeview4GL does a refresh after each call. If you plan to expand a large amount of nodes, set the
TreeRefresh attribute to false before, then set it to true after your procedure.
chChTreeview:TreeView4GL:TreeRefresh = FALSE.
do i = 1 to chChTreeview:TreeView4GL:ChildrenNumber(0) :
a = chChTreeview:TreeView4GL:GetNode( I - 1).
hNode = int(entry(2, a, chr(1))). /* Get the node handle */
/* OR hNode = {nodenumber.i a }. */
If Not chChTreeview:TreeView4GL:Expanded( hNode ) then
chChTreeview:TreeView4GL:Expanded( hNode ) = true.
end.
chChTreeview:TreeView4GL:TreeRefresh = TRUE.
11
www.4GL.fr TREEVIEW4GL
…but don't forget to reset this attribute to TRUE after your procedure, or the treeview will not be updated on the
screen.
< ImagePath > is added to the current image list. If you plan to constitute your own image list, you have to
clear the image list with ClearImages().
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 3
Default image list
12
www.4GL.fr TREEVIEW4GL
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
WARNING : this method clears the entire image list and you have to fill the image list with new images of the
corresponding size (or they'll be truncated).
WARNING : this method keeps the current size of your image list. If you want to return to the original size, use a
imageSize method(16,16) before resetImages().
13
www.4GL.fr TREEVIEW4GL
Display Lines :
<Component-Handle frame>:TreeView4GL:Lines = true/false.
Display/hide the connection lines (Default = true).
Display buttons :
<Component-Handle frame>:TreeView4GL:Buttons = true/false.
Display/hide the + and - buttons (Default = true).
Track Display:
<Component-Handle frame>:TreeView4GL:Track = true/false.
Display a hot spot on mouse over node event
Display AboutBox :
<Component-Handle frame>:TreeView4GL:AboutBox ( ).
14
www.4GL.fr TREEVIEW4GL
PROGRAMMING NOTES
About the node number :
The node number is relative to zero and indicates at any time the real sequence of nodes.
The node number is not stable. Its value is changing in accord with all Treeview updates (deletes and adds).
If the Treeview is subject to changes, the right method is to use invariant Node handles.
The access to a specific node is more efficient by handles.
With the version 2.3, you can set two normal images numbers: one for a normal (collapsed) node, one for opened
node. You can also manually program what you want in OnExpanded and OnCollapsed events. For example, on
expanded, change the node (ChangeNode() ) to set different images, texts or private-data.
Example:
IF {nodePrivate.i } begins "MyMode" then do:
……
end.
A different field than p-NodeInfo can be specified:
IF { Nodelevel.i myNode } = "3" then …
15
www.4GL.fr TREEVIEW4GL
Events
OnChange
DEFINE INPUT PARAMETER p-NodeInfo AS CHARACTER NO-UNDO.
OnNodeClick (similar to Onchange but triggered even if the node has not changed)
DEFINE INPUT PARAMETER p-NodeInfo AS CHARACTER NO-UNDO.
OnExpanded
DEFINE INPUT PARAMETER p-NodeInfo AS CHARACTER NO-UNDO.
OnCollapsed
DEFINE INPUT PARAMETER p-NodeInfo AS CHARACTER NO-UNDO.
OnKeyPress
DEFINE INPUT-OUTPUT PARAMETER p-Key AS INTEGER NO-UNDO.
If the key is combined with CTRL, the character can be obtained by using:
OnRightClick
DEFINE INPUT PARAMETER p-NodeInfo AS CHARACTER NO-UNDO.
16