07 03 PA2C6SCFGLRVMRYG2AQHY7C6J4VAVZF7LFVLRHY




Visual Basic 6 Programming Blue Book: The Most Complete, Hands-On Resource for Writing Programs with Microsoft Visual Basic 6!:Objects And Classes--Beyond The Basics
function GetCookie (name) { var arg = name + "="; var alen = arg.length; var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i + alen; if (document.cookie.substring(i, j) == arg) { var end = document.cookie.indexOf (";", j); if (end == -1) end = document.cookie.length; return unescape(document.cookie.substring(j, end)); } i = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; } var m1=''; var gifstr=GetCookie("UsrType"); if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; } document.write(m1+m2+m3);            Keyword Title Author ISBN Publisher Imprint Brief Full  Advanced      Search  Search Tips Please Select ----------- Components Content Mgt Certification Databases Enterprise Mgt Fun/Games Groupware Hardware IBM Redbooks Intranet Dev Middleware Multimedia Networks OS Prod Apps Programming Security UI Web Services Webmaster Y2K ----------- New Titles ----------- Free Archive To access the contents, click the chapter and section titles. Visual Basic 6 Programming Blue Book: The Most Complete, Hands-On Resource for Writing Programs with Microsoft Visual Basic 6! (Publisher: The Coriolis Group) Author(s): Peter G. Aitken ISBN: 1576102815 Publication Date: 08/01/98 function isIE4() { return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') ); } function bookMarkit() { var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0"; parent.location.href=url; //var win = window.open(url,"myitk"); //if(!isIE4()) // win.focus(); } Search this book:  














Previous
Table of Contents
Next




The ImageList control’s Overlay method permits you to overlay one image on another. Because all images are the same size, overlaying them does not make much sense unless part of the top image is transparent, so that the bottom image can show through. This is achieved with the ImageList control’s MaskColor property. The color you specify in this property will become transparent in the top image, permitting the second image to show through. Suppose you have an image consisting of a yellow lightning bolt on a green background, and you want to overlay the lightning bolt over another image. First, set the MaskColor property as follows:


ImageList1.MaskColor = vbGreen


Note that vbGreen is one of Visual Basic’s intrinsic constants. You can find more details on intrinsic constants by searching the Help system. Once the mask color is set, call the Overlay method to perform the action. The following code overlays the image with Index 2 over the picture with Index 1 and displays the result in a Picture Box:


Pbox1.Picture = ImageList1.Overlay 1, 2


You could also create the overlay image and add it as a new image in the same ImageList control:



ImageList1.ListImages.Add , “overlaid image”, _
ImageList1.Overlay 1, 2


You could also specify the images to be overlaid by their Key properties, instead of using the Index property.
TreeView Control
The TreeView control lets you display and manipulate items in a hierarchical view. An example that most of us see every day is Windows Explorer, which uses a TreeView control to display folders and file names. You can select single or multiple items, open and close branches on the tree, and control the way items are displayed. Each item in a TreeView can have an icon associated with it, such as the file folder and page icons used in Windows Explorer. You’re not limited to disk-related items, though—a TreeView control can be used for any information that is arranged hierarchically.

To be honest, the TreeView control is not all that easy to understand and use. It is a complicated control, and it doesn’t provide the almost-instant gratification that we Visual Basic programmers have perhaps become too accustomed to. You’ll have to exercise your noggin a bit before you can get a TreeView control doing just what you want it to.
The main reason for the TreeView control’s complexity is its structure. It is not, as are most Visual Basic controls, just a single object with a set of properties and methods. Oh no, that would make life too easy. Let me explain:

•  Each item on a TreeView—each twig on the tree—is a Node object. Each of these Node objects has its own set of properties and methods.
•  All of the Node objects belonging to a particular TreeView are organized in the Nodes collection, which is itself an object with methods and properties. One of the Nodes collection’s methods is Item, which is used to access the individual Node objects in the collection.
•  The TreeView control itself is an object with methods and properties. One of its properties is Nodes, which refers to its Nodes collection.
•  The TreeView object is (optionally) associated with an ImageList object that holds the images to be displayed at the tree nodes.

You can probably see where the confusion comes from. When you want to do something with a TreeView object, it’s not always clear whether you use the methods and properties of the TreeView object itself, or whether you must manipulate its associated Nodes collection or, perhaps, work directly with a Node object.
While the TreeView control by itself can be useful, it really comes into its own when you associate each node in the tree with something else. When TreeView is used for a folder/file display, the association is automatic. What about other associations? I’ll be showing you how to associate a Text Box with each node in a tree, and you can use the same or similar techniques to associate other objects with TreeView nodes. I can’t show all the details of using the TreeView control, but I can get you started so you can explore further on your own. I’ll include a sample application that illustrates the techniques I cover.
Adding Nodes To A Tree
A TreeView object starts its life with no nodes. In form design, you’ll see a few sample nodes displayed on the control, but these are present only so you can view the effect of changing properties that determine how the nodes are displayed. They are not present when you run the program. Nodes exist at various levels. The topmost level is the root. Two nodes at the same level are siblings. A node that is subsidiary to another is the child, while the other is the parent. While a program is executing, the user can open a node, displaying all of its children (if any), or close it, hiding any child nodes. You can also open and close nodes in code, so with a single command, you can perform such useful tasks as opening or closing all branches on a given tree.
Nodes must be added programmatically using the Add method of the Nodes collection. Here’s the syntax:


NewNode = TV.Nodes.Add(relative, relationship, key, text, image,
selectedImage)


TV is the name of the TreeView control. All of the method arguments except one are optional, although it’s pretty rare to use this method without using at least some of the optional arguments. Let’s take a look at them:


•  Relative—Required when you want to insert the new node in a relationship to an existing node. You specify the relative node by either its Index property or Key property (explained in a moment).
•  Relationship—Used only when you specify relative. It determines the relationship that the new node has to the existing node. Your choices are:

•  tvwLast—The new node becomes a sibling of the node named in relative and is placed after all other siblings.
•  tvwNext—The new node becomes a sibling of the node named in relative and is placed immediately after it.
•  tvwPrevious—The new node becomes a sibling of the node named in relative and is placed immediately before it.
•  tvwChild—The node becomes a child node of the node named in relative (this is the default).

•  Key—A unique string that identifies the node. If you specify this argument, you can later refer to specific nodes by using the Item method with the key value.
•  Text—The node label displayed in the TreeView control. This is the only required argument for the Add method.
•  Image—The Key or Index property of the image in the associated ImageList control that will be displayed as part of the node.
•  SelectedImage—Specifies the image that will be displayed when the node is selected. If this argument is omitted, the image specified by image will be displayed, whether the node is selected or not.

Each node added to a tree is automatically assigned a unique Index property. These are nothing more than sequential integers that uniquely identify each node. Each node in a tree, therefore, can always be uniquely identified by its Index property, as well as by its Key property, if you assigned one. As we will see, the Index property provides a method of linking each node to some other object. Note also that each Node object has the Tag property, which can provide another way of both identifying and linking nodes.



Previous
Table of Contents
Next






Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.



Wyszukiwarka

Podobne podstrony:
pwsz kalisz LAM 07 03
2013 07 03 Dec nr 182 MON WOG odznaki
ZL3 07 03
07 03 Azbest
Billboard Singles Chart 07 03 2015 Tracklista
07 03
2013 07 03 NDz, Bauman wie, co robił P Gontarczyk & P Gajkowska
TI 01 07 03 T B M pl(1)
07 03 PAM Zintegrować i rozpalić płomień Diamentowego Promienia
07 03
TI 98 07 03 T pl(1)
TI 03 07 03 T pl

więcej podobnych podstron