Microsoft TreeView Control 6.0 [message #391800] |
Fri, 13 March 2009 10:04 |
chrisvelarde
Messages: 5 Registered: March 2009
|
Junior Member |
|
|
I'd like to implement a treeview control with checkboxes in every node using Microsoft TreeView Control 6.0 in Forms 6i. I already did the following steps:
1. Download and register OCX (regsvr32 C:\windows\system32\comctl32.ocx)
2. Draw OCX control on form.
3. Right click on OCX control and Insert Object "Microsoft TreeView Control 6.0"
4. Import OLE Library Interfaces "MSComctlLib.TreeCtrl.2"
5. Set Data Block Single Record to YES
6. Set OLE Class of Listview control to "MSComctlLib.TreeCtrl.2"
7. Rename treeview control to "ACX_TREE" and Data Block to "BLK_CONTROLS"
Now I need to populate the treeview adding code to the "WHEN_NEW_FORM_INSTANCE" Trigger, but I donĀ“t see how.
Does someone know how to do this and/or a place where I can find a working example?
|
|
|
Re: Microsoft TreeView Control 6.0 [message #391960 is a reply to message #391800] |
Sun, 15 March 2009 02:38 |
chrisvelarde
Messages: 5 Registered: March 2009
|
Junior Member |
|
|
I found the solution,
First you have to make sure that there is no other item in the TreeView's block, so I renamed the block to "BLK_TREE".
Then you add the code to the ""WHEN_NEW_FORM_INSTANCE" Trigger.
The following lines show an example code, that crates statically one root node and 3 child nodes:
declare
hNodes MSComctlLib_CONSTANTS.iNodes;
hNode MSComctlLib_CONSTANTS.iNode;
-- Error Handler variables
errCode pls_integer;
errSrc varchar2(200);
errDescription varchar2(2000);
errHelpfile varchar2(200);
errHelpContext pls_integer;
begin
-- Show the Expansion Indicators and Lines and Text
MSCOMCTLLIB_ITREEVIEW.Style(:item('BLK_TREE.ACX_TREE').interface,6);
-- Get the Handle to the Nodes Collection
hNodes := MSCOMCTLLIB_ITREEVIEW.nodes(:item('BLK_TREE.ACX_TREE').interface);
-- Add NODES, every node should have a different "key"
-- and should begin with a Alpha Char not a numeric
--ROOT NODE
hNode := MSCOMCTLLIB_iNodes.ole_add
(
interface => hNodes,
Relative => olevar_empty,
Relationship => to_variant(1),
Key => to_variant('Node1'),
Text => to_variant('Node 1')
);
release_obj(hNode);
-- Add child NODES
hNode := MSCOMCTLLIB_iNodes.ole_add
(
Interface => hNodes,
Relative => to_variant('Node1'),
Relationship => to_variant(4),
Key => to_variant('Node 1.1'),
Text => to_variant('Node 1.1')
);
release_obj(hNode);
hNode := MSCOMCTLLIB_iNodes.ole_add
(
Interface => hNodes,
Relative => to_variant('Node1'),
Relationship => to_variant(4),
Key => to_variant('Node 1.2'),
Text => to_variant('Node 1.2')
);
release_obj(hNode);
hNode := MSCOMCTLLIB_iNodes.ole_add
(
Interface => hNodes,
Relative => to_variant('Node1'),
Relationship => to_variant(4),
Key => to_variant('Node 1.3'),
Text => to_variant('Node 1.3')
);
release_obj(hNode);
release_obj(hNodes);
exception
when form_ole_failure then
errCode := last_ole_exception( errSrc,
errDescription,
errHelpfile,
errHelpContext);
message('Error Raised by ->'||errSrc||': '||errDescription);
END;
Enjoy
[Updated on: Sun, 15 March 2009 02:40] Report message to a moderator
|
|
|
|
|
|