Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2008 > Visual Basic 2008 Essentials
|
Visual Basic 2008 Essentials If you are new to Visual Basic programming with version 2008, this is the place to start your questions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2008 Essentials section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 16th, 2009, 03:17 PM
Registered User
 
Join Date: Jan 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Drag and drop copies but doesn't move

I am having a problem figuring out what I've done wrong (or omitted). The code below shows my various drag/drop subs. They do work within their current application but they only "copy" and do not just "move". I don't think I have left any code in there that applies to a copy function, but obviously I am missing something. Can anyone help?

Code:
#Region "Drag/Drop Subs"
    Private MouseIsDown As Boolean = False
    Private Sub Mouse_Down(ByVal sender As Object, ByVal e As MouseEventArgs) _
    Handles PB2.MouseDown
        If Not sender.Image Is Nothing Then
            ' Set a flag to show that the mouse is down.
            MouseIsDown = True
        End If
    End Sub
    Private Sub Mouse_Move(ByVal sender As Object, ByVal e As MouseEventArgs) _
    Handles PB2.MouseMove
        If MouseIsDown Then
            sender.DoDragDrop(sender.Image, DragDropEffects.Move)
        End If
        MouseIsDown = False
    End Sub
    Public Sub Give_Feedback(ByVal sender As SolPicBox.SolPicBox, ByVal e As _
        GiveFeedbackEventArgs) Handles PB2.GiveFeedback
        e.UseDefaultCursors = False
        Dim bmp As Bitmap = New Bitmap(sender.Image)
        Windows.Forms.Cursor.Current = New Cursor(bmp.GetHicon)
    End Sub
    Private Sub Drag_Enter(ByVal sender As SolPicBox.SolPicBox, ByVal e As DragEventArgs) _
    Handles PB1.DragEnter
        If e.Data.GetDataPresent(DataFormats.Bitmap) Then
            If e.KeyState = 9 Then
                e.Effect = DragDropEffects.Move
            Else
                e.Effect = DragDropEffects.Move
            End If
        Else
            e.Effect = DragDropEffects.None
        End If
    End Sub
    Private Sub Drag_Drop(ByVal sender As SolPicBox.SolPicBox, ByVal e As _
        DragEventArgs) Handles PB1.DragDrop
        sender.Image = e.Data.GetData(DataFormats.Bitmap)
        Status1.Text = CType(Status1.Text, Integer) - 1
    End Sub
    Private Sub Query_Continue_Drag(ByVal sender As SolPicBox.SolPicBox, _
#End Region
SolPicBox is a control derived from a standard PictureBox. As of this moment it doesn't have any capabilities not implemented by the standard control.
 
Old January 17th, 2009, 09:37 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hello. Nothing looks bad, or may it look that you copy the control.. Maybe something in the query continue drag???
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
 
Old January 20th, 2009, 12:20 AM
Registered User
 
Join Date: Jan 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Post More information...

It would seem according to research at MSDN that if I want to remove the source image I have to do it within the DragDrop subroutine. However I can't find anything that gives me a clear idea of how to do that when there are multiple sources. I need to be able to tell the program, in some manner, to find the source (PictureBox) and remove the image at that point (PictureBox.Image = Nothing).

I hate to be lost like this . The bulk of the program is finished, but without this function, the rest is useless. Any directions, links, et al will be appreciated.
 
Old January 20th, 2009, 02:53 PM
Registered User
 
Join Date: Jan 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default RESOLVED !!!

I have found the solution to my problem. Like so:

Declare
Code:
SPB As PictureBox
Then in the Mouse_Move sub (outside of the If-Then statement) add
Code:
SPB = sender
Then in the Drag_Drop sub after the main routine add the following:
Code:
 
SPB.Image = Nothing
SPB.SendToBack()
Works perfectly. Thanks for your help.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Drag and Drop batott ASP.NET 2.0 Professional 3 April 26th, 2008 07:59 PM
Drag and drop vpinhao Beginning VB 6 0 September 11th, 2006 01:33 PM
Drag/Drop bmains Javascript 1 September 22nd, 2004 07:29 PM
Drag and Drop from PictureBox hary VS.NET 2002/2003 1 July 25th, 2004 08:49 AM
Drag and drop Clive Astley Access 2 August 15th, 2003 12:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.