AVAX-software.com Forums: Drag and Drop - AVAX-software.com Forums

Jump to content

Page 1 of 1

Drag and Drop

#1 User is offline   Martijn Huinink Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 6
  • Joined: 01-October 07
  • Interests:computer programming with Visual Studio .NET

Posted 01 October 2007 - 07:23 PM

Dear sir,

i am testing a program with your .com object and was wundering if i can do the following,
in a form i have got 2 avax-fields (drwaings). Is it possible to drag and drop an object from the left avax-drawing to the right avax drawing ?

explaination off my software
in the left avax-object (drawing) ther are severall object reectangles (wooden panels in reality). The right avax-object (drawing) is the overview off our
wood sawing machine. The user can select 1 panel from the left and place it on the wood sawing machine.

I hope u understand my question.

Greetings From Holland,

Martijn Huinink

#2 User is offline   Athanasios Gardos Icon

  • Administrator
  • Icon
  • Group: Admin
  • Posts: 333
  • Joined: 21-March 05
  • Gender:Male

Posted 02 October 2007 - 02:37 PM

Here it is an Drag and Drop example written in VB6

Option Explicit

Dim StartX, StartY
Dim xMinB As Single, yMinB As Single
Dim g_ClipboardTempFile As String

Private Function pCopyAVAX(o As cAvax) As Boolean
	Dim zMin As Single
	Dim xMax As Single, yMax As Single, zMax As Single
	Dim lMax As Long, h() As Long
	Dim sCopyFile As String, b() As Byte
	Dim iFr As Integer
	lMax = o.GetSelectedHandlesArr(h())
	If lMax = 0 Then Exit Function
	Call cAvax1.GetBoundsSelectedItems(xMinB, yMinB, zMin, xMax, yMax, zMax)
	sCopyFile = g_ClipboardTempFile
	b() = o.Copy_Avax(h(), xMinB, yMinB)
	Call DeleteFile(sCopyFile)
	iFr = FreeFile
	Open sCopyFile For Binary As #iFr
	Put #iFr, , b()
	Close #iFr
	pCopyAVAX = True
End Function
		
Private Function pPasteAVAX(o As cAvax, x As Single, y As Single) As Boolean
	Dim sCopyFile As String
	Dim iFr As Integer
	Dim b() As Byte, hNew() As Long
	sCopyFile = g_ClipboardTempFile
	iFr = FreeFile
	Open sCopyFile For Binary As #iFr
	If LOF(iFr) - 1 > 0 Then
		ReDim b(LOF(iFr) - 1) As Byte
		Get #iFr, , b()
		pPasteAVAX = o.Paste_Avax(x - xMinB, y - yMinB, b(), hNew())
	End If
	Close #iFr
End Function

Private Sub cavax1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
	Dim xMin As Single, yMin As Single, zMin As Single
	Dim xMax As Single, yMax As Single, zMax As Single
	Dim xMinL As Long, yMinL As Long, xMaxL As Long, yMaxL As Long
	If CheckDragEnable.Value <> 0 Then
		Call cAvax1.GetBoundsSelectedItems(xMin, yMin, zMin, xMax, yMax, zMax)
		Call cAvax1.SingleToLong(xMin, yMin, xMinL, yMinL)
		Call cAvax1.SingleToLong(xMax, yMax, xMaxL, yMaxL)
		Picture1.Move cAvax1.Left + ScaleX(xMinL, vbPixels, vbTwips), cAvax1.Top + ScaleY(yMaxL, vbPixels, vbTwips), ScaleX(Abs(xMaxL - xMinL), vbPixels, vbTwips), ScaleY(Abs(yMaxL - yMinL), vbPixels, vbTwips)
		StartX = x
		StartY = y
		Picture1.Drag vbBeginDrag 'Starts drag
	End If
End Sub

Private Sub cAvax2_DragDrop(Source As Control, x As Single, y As Single)
	Dim x1 As Single, y1 As Single, z1 As Single
	If CheckDragEnable.Value <> 0 Then
	   If Source = Picture1 Then
		  If pCopyAVAX(cAvax1) = True Then
			 Call cAvax2.LongToSingle(CLng(ScaleX(x, vbTwips, vbPixels)), CLng(ScaleY(y, vbTwips, vbPixels)), x1, y1)
			 If pPasteAVAX(cAvax2, x1, y1) = True Then
				cAvax1.Command = Unselect_c
				CheckDragEnable.Value = 0
			 End If
		  End If
	   End If
	End If
End Sub

Private Sub CheckDragEnable_Click()
	If CheckDragEnable.Value = 1 Then
	   If cAvax1.isSelected = False Then
		  MsgBox "Please, select some objects first..."
		  CheckDragEnable.Value = 0
	   Else
		  Call cAvax1.SetAvaxProperty(SelectRegionOn_p, False)
	   End If
	Else
	   Call cAvax1.SetAvaxProperty(SelectRegionOn_p, True)
	End If
End Sub

Private Sub Form_Load()
	'The form contains two avax controls, one checkbox and one picturebox
	g_ClipboardTempFile = App.Path & "\~temp.tmp"
	CheckDragEnable.Caption = "Enable Drag - Drop from cAvax1 to cAvax2"
	CheckDragEnable.Value = 0
	Picture1.Visible = False
	Call cAvax1.StartAvax
	Call cAvax2.StartAvax
	Call cAvax1.Add_Rectangle(0, 0, 10, 10)
	Call cAvax1.Add_Rectangle(15, 0, 10, 10)
End Sub

Private Sub Form_Unload(Cancel As Integer)
	Call cAvax1.EndAvax
	Call cAvax2.EndAvax
	Call DeleteFile(g_ClipboardTempFile)
End Sub

Private Sub DeleteFile(sFile As String)
	On Local Error Resume Next
	Kill sFile
End Sub

Athanasios Gardos
Avax-Software.com

#3 User is offline   Martijn Huinink Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 6
  • Joined: 01-October 07
  • Interests:computer programming with Visual Studio .NET

Posted 02 October 2007 - 07:58 PM

Thank you very mich for your reply.

at the moemnt i only have Visual studio .Net installed, and i got a lot of errors while trying your 2 solutions.

i think i have to start-up my old computer and try it there with vb 6.0.

Last question, are there example codes availeble for Visual Studio .NET ???


Thank for your Help.

Greetings from Holland,

Martijn Huinink.

#4 User is offline   Athanasios Gardos Icon

  • Administrator
  • Icon
  • Group: Admin
  • Posts: 333
  • Joined: 21-March 05
  • Gender:Male

Posted 02 October 2007 - 08:08 PM

AvaxCad example in VB.NET
Athanasios Gardos
Avax-Software.com

#5 User is offline   Martijn Huinink Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 6
  • Joined: 01-October 07
  • Interests:computer programming with Visual Studio .NET

Posted 03 October 2007 - 07:39 PM

dear Athanasios Gardos,

thanks very much for your example code in .NET. Worked fine.

By the way, there is an error in the file on line 1271 off the main form. cAvax1.cltRefresh is not a member, cAvax1.Refresh works !!!

i'm now trying to implement the object in my own .Net program. the biggest problem when trying your last 2 examples in .NET are the overload off some functions. When you have this examples in . NET ready i would be very pleased !!. For now i'am trying my own way.

Greetings from Holland,

Martijn Huinink.

#6 User is offline   Martijn Huinink Icon

  • Newbie
  • Pip
  • Group: Members
  • Posts: 6
  • Joined: 01-October 07
  • Interests:computer programming with Visual Studio .NET

Posted 04 October 2007 - 01:33 PM

Dear Athanasios Gardos,

my first problem is that in the Drag % Drop example you use the DragDrop Event, in my Studio .Net program i dont have this event availeble, any solutions ?

I'am using the Avax Vector ActiveX object version 3.3.0.0


Greetings from Holland,

Martijn Huinink

#7 User is offline   Athanasios Gardos Icon

  • Administrator
  • Icon
  • Group: Admin
  • Posts: 333
  • Joined: 21-March 05
  • Gender:Male

Posted 09 October 2007 - 10:20 AM

Drag and Drop implementation in VB.NET is different from VB 6.0.
Check out the MSDN documentation for more details
http://msdn.microsof...sualbasic70.asp
Hope this helps.
Athanasios Gardos
Avax-Software.com

Page 1 of 1


Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users