Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
OLE Drag and Drop from ListView to TreeView
Message
 
To
08/03/1999 12:34:49
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00195199
Message ID:
00195237
Views:
18
Hi Andrew,

In your form, create the following:

Properties:
-----------
nXTwips
nXTwips
oLastActiveControl

Methods:
--------
PixelsToTwips

*-- Code for PixelToTwips method
LOCAL liHWnd, liHDC, liPixelsPerInchX, liPixelsPerInchY
* Define some constants.

#DEFINE cnLOG_PIXELS_X 88
#DEFINE cnLOG_PIXELS_Y 90
#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.
THISFORM.nXTwips = ( cnTWIPS_PER_INCH / liPixelsPerInchX )
THISFORM.nYTwips = ( cnTWIPS_PER_INCH / liPixelsPerInchY )
RETURN


*-- Form.Load Method
THISFORM.PixelsToTwips( @lnXTwips, @lnYTwips )

*-- Keep track of the last object that had focus.
*-- This is needed so that we can determine where the
*-- drag came from. Create a property on your form
*-- ie: LastActiveControl and in all your form objects'
*-- GotFocus event insert the following code:
THISFORM.LastActiveControl = THIS

*-- Every thing else should be handled by your
*-- TreeView.OleDragDrop Event.
..
oHitTest = THIS.HitTest( x * THISFORM.XTwips, y * THISFORM.YTwips )
*-- Make sure the drag came from the ListView Control
IF THISFORM.LastActiveControl.Name = "ListView"
THIS.DropHighLight = oHitTest
*-- Count the number of selected items in your ListView
m.lnSelected = 0
FOR x = 1 TO THISFORM.ListView.ListItems.Count
IF THISFORM.ListView.ListItems( x ).Selected
*-- Perform you move action here
ENDIF
ENDFOR
ENDIF

Good luck!
Juan L. Romero
gcandela@javanet.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform