General information
Category:
ActiveX controls in VFP
Claudio,
>To help you better, public on this site your OLE DRAG&DROP code and them we can tell you something more.
Before the code, here are the settings for the TreeView control:
OLEDragMode = 1 && Automatic
OLEDropMode = 1 && Manual
Here's the code:
**************************************************
*-- Class: test
*-- ParentClass: olecontrol
*-- BaseClass: olecontrol
*-- OLEObject = C:\WINNT\system32\COMCTL32.OCX
*
DEFINE CLASS test AS olecontrol
Top = 64
Left = 8
Height = 345
Width = 300
Visible = .F.
ZOrderSet = 0
Name = "oleTreeViewOn"
PROCEDURE Expand
*** ActiveX Control Event ***
LPARAMETERS node
Node.EnsureVisible
ENDPROC
PROCEDURE NodeClick
*** ActiveX Control Event ***
LPARAMETERS node
Node.EnsureVisible
This.DropHighlight = .null.
ENDPROC
PROCEDURE MouseDown
*** ActiveX Control Event ***
LPARAMETERS button, shift, x, y
WITH This
oHitTest = .HitTest( x * .nxtwips, Y * .nytwips )
IF TYPE('oHitTest')= 'O' AND !IsNull(oHitTest)
.SelectedItem = oHitTest
ENDIF
.nodx = .SelectedItem
ENDWITH
oHitTest = .null.
ENDPROC
PROCEDURE OLEDragOver
*** ActiveX Control Event ***
LPARAMETERS data, effect, button, shift, x, y, state
oHitTest = This.HitTest( x * This.nxtwips, Y * This.nytwips )
IF TYPE('oHitTest') = 'O'
This.DropHighlight = oHitTest
ENDIF
ENDPROC
PROCEDURE OLEDragDrop
*** ActiveX Control Event ***
LPARAMETERS data, effect, button, shift, x, y
IF Data.Getformat(1) && CF_TEXT
WITH This
IF TYPE('.nodx') = 'O' ;
AND !IsNull(.nodx) ;
AND TYPE('.nodx.parent') = 'O' ;
AND TYPE('.DropHighLight') = 'O' ;
AND !IsNull(.DropHighlight)
loSource = .nodx
loTarget = .DropHighlight
IF loSource.Key # loTarget.key ;
AND TYPE('loSource.Parent') = 'O' ;
AND Left(loTarget.Key,8) == 'company_' ;
AND 'emp_' $ loSource.Key
*-- Verify that we really want to reassign the employee
IF MessageBox('Do you want to move ' + IIF(TYPE('loSource.Text')='C',loSource.Text,'') ;
+ ' ?', 4+32+256, 'Visual FireInfo') # 6
ThisForm.DropHighlights()
RETURN
ENDIF
lcSourceParentKey = loSource.Parent.Key
lcTargetParentKey = loTarget.Key
IF SubStr(lcSourceParentKey,1,AT('_',lcSourceParentKey)-1) == SubStr(lcTargetParentKey,1,AT('_',lcTargetParentKey)-1)
lcSourceKey = IIF(lcSourceParentKey == lcTargetParentKey, '', loSource.Key)
lcSourceText = loSource.Text
*-- Find the node of employee being loaned
LOCAL lcNewKey
*-- Flag the key to denote dirty record
lcNewKey = IIF(Left(lcSourceKey,1) # '*', '*', '') + lcSourceKey
*-- Remove source node
.nodes.Remove(loSource.Index)
*-- Check if node exists already
IF TYPE('.Nodes(lcSourceKey)') # 'O'
oNode = .Nodes.Add(loTarget.Key, This.tvwChild, lcNewKey, lcSourceText, , )
.SelectedItem = oNode
oNode.Image = 3
.Nodes(lcNewKey).ForeColor = ThisForm.GetColor('GREEN')
ENDIF
ENDIF
ENDIF
ENDIF
ENDWITH
ENDIF
*-- Need to nullify the DropHighLight values in order to properly determine what the source is
ThisForm.DropHighlights()
ENDPROC
PROCEDURE Init
**********************************************************************
*-- Init()
**********************************************************************
WITH This
*-- Define some constants
.AddProperty('tvwFirst', 0)
.AddProperty('tvwLast', 1)
.AddProperty('tvwNext', 2)
.AddProperty('tvwPrevious', 3)
.AddProperty('tvwChild', 4)
.AddProperty('cnLOG_PIXELS_X', 88)
.AddProperty('cnLOG_PIXELS_Y', 90)
.AddProperty('cnTWIPS_PER_INCH', 1440)
*-- Node object reference
.AddProperty('nodx', .F.)
.AddProperty('nxtwips', .F.)
.AddProperty('nytwips', .F.)
ENDWITH
ThisForm.PixelToTwips(This)
RETURN
**********************************************************************
ENDPROC
ENDDEFINE
*
*-- EndDefine: test
**************************************************
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only