Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
TreeView Control - Disable node
Message
From
05/08/2003 09:35:27
 
 
To
05/08/2003 07:28:49
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00816771
Message ID:
00816824
Views:
30
Paco,

This isn't something available natively in the control. However, it can (to a certain extent) be emulated.

1] Create a new form with a treeview called oleTreeView and an Imagelist called oleImageList.

2] Load 2 images into oleImageList and use the Key field to index each image. Call the enabled image RED and the disabled image GREY (I created 2 bitmaps 16x16 and filled them with RGB(255, 0, 0) and RGB(192, 192, 192).

3] Set the oleTreeView.HotTracking propert to .T.

Enter the following code into the Init of the form.
LOCAL lnHWnd								
LOCAL lnHDC									
LOCAL lnPixelsPerInchX						
LOCAL lnPixelsPerInchY						

#define LOG_PIXELS_X		88				
#define LOG_PIXELS_Y      	90				
#define TWIPS_PER_INCH	    1440			


declare integer GetActiveWindow	in WIN32API
declare integer GetDC		in WIN32API integer lnHDC
declare integer GetDeviceCaps	in WIN32API integer lnHDC, integer lnCapIndex

if version(5) > 700
   lnHWnd = This.HWnd
else
   lnHWnd = GetActiveWindow()
endif && version(5) > 700

lnHDC = GetDC(lnHWnd)

lnPixelsPerInchX = GetDeviceCaps(lnHDC, LOG_PIXELS_X)
lnPixelsPerInchY = GetDeviceCaps(lnHDC, LOG_PIXELS_Y)

with ThisForm
   .nTwipsX = TWIPS_PER_INCH / lnPixelsPerInchX
   .nTwipsY = TWIPS_PER_INCH / lnPixelsPerInchY

   .oleTreeView.ImageList = .oleImageList

   *!* Create the treeview nodes.
   loRootNode = ThisForm.oleTreeView.Nodes.Add(, 1, "_ROOT_", "Root Node", 0, 0)
   loRootNode.Expanded = .T.
	
   for lnLoop = 1 to 10
      if lnLoop % 3 = 0
         loChild = ThisForm.oleTreeView.Nodes.Add(loRootNode, 4, "NODE" + transform(lnLoop), "Child Node " + transform(lnLoop), "GREY", "GREY")  
         loChild.ForeColor = rgb(192, 192, 192)
      else			
         loChild = ThisForm.oleTreeView.Nodes.Add(loRootNode, 4, "NODE" + transform(lnLoop), "Child Node " + transform(lnLoop), "RED", "RED")
      endif
   endfor 
endwith 
Enter the following code into the oleTreeView.MouseMove event.
LOCAL loNode

loNode = This.HitTest(x * ThisForm.nTwipsX, y * ThisForm.nTwipsY)

if vartype(loNode) == "O"
   if loNode.Image = "GREY"
      This.MousePointer = 2  && ccCross
   else
      This.MousePointer = 0  && ccDefault
   endif
else
   This.MousePointer = 0  && ccDefault
endif 
Enter the following code into the oleTreeView.nodeClick event.
if node.Image = "GREY"
   This.SelectedItem = This.Nodes.Item(1)
endif 
As you can see you can get close to simulating a disabled treeview node.

HTH
Neil
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform