Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problems with treeview
Message
From
29/07/2003 12:23:15
 
 
To
29/07/2003 11:17:57
Albert Beermann
Piepenbrock Service Gmbh & Cokg
Osnabrück, Germany
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00814541
Message ID:
00814577
Views:
8
Hi Albert.

>a)
>I don't know how to set the behavior of the treeview to autoexpand !??
>(only the first node is shown and users have to click a lot to expand all nodes)

There is no "auto-expand" feature in a TreeView -- you have to do it yourself. As you add nodes to the TreeView, set their Expanded property to .T.

>b)
>Is it posible to do a drag and drop within the treeview ??
>I want to select an node(some environment for example,the objektid is part of the text and can be extracted) , then start draging the node to another node and do some coding when dropping.

Drag and drop can be started either automatically by setting the TreeView's OLEDragMode property to 1 or manually by calling its OLEDrag method. OLECompleteDrag fires when the drag ends. In the OLEDragOver method, put code like the following to highlight the node the mouse is over:
LPARAMETERS data, effect, button, shift, x, y, state
loNode = This.HitTest(X * This.nTreeFactorX, Y * This.nTreeFactorY)
if vartype(loNode) = 'O'
  loNode.Selected = .T.
endif
nTreeFactorX and nTreeFactorY are custom properties that handle the conversion of twips (the unit used by the TreeView) to pixels (the units used by VFP). Here's the code, usually placed in Init, that sets these properties:
local liHWnd, ;
  liHDC, ;
  liPixelsPerInchX, ;
  liPixelsPerInchY

* Define some constants.

#define cnLOG_PIXELS_X      88
  * From WINGDI.H
#define cnLOG_PIXELS_Y      90
  * From WINGDI.H
#define cnTWIPS_PER_INCH  1440
  * 1440 twips per inch

* Declare some Windows API functions.

declare integer GetActiveWindow in WIN32API
declare integer GetDC           in WIN32API ;
  integer iHDC
declare integer GetDeviceCaps   in WIN32API ;
  integer iHDC, integer iIndex

* Get a device context for VFP.

liHWnd = GetActiveWindow()
liHDC  = GetDC(liHWnd)

* Get the pixels per inch.

liPixelsPerInchX = GetDeviceCaps(liHDC, cnLOG_PIXELS_X)
liPixelsPerInchY = GetDeviceCaps(liHDC, cnLOG_PIXELS_Y)

* Get the twips per pixel.

with This
  .nTreeFactorX = cnTWIPS_PER_INCH/liPixelsPerInchX
  .nTreeFactorY = cnTWIPS_PER_INCH/liPixelsPerInchY
endwith
In OLECompleteDrag, which fires when the drag ends, This.SelectedItem is a reference to the node the user dropped the item on.

Doug
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform