|
-
Mar 7th, 2010, 01:18 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Drag and drop question
Hello,
I set a frame's DragMode property to automatic and then wrote the following code into the Form_DragDrop event.
Code:
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
Source.Top = Y
Source.Left = X
End Sub
[/code]
The frame's outline would move, but the frame snapped back to where it was. What can I do?
-
Mar 7th, 2010, 01:31 PM
#2
Re: Drag and drop question
are you trying to move an object? or drag n drop it somewhere?
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Mar 7th, 2010, 01:45 PM
#3
Thread Starter
Hyperactive Member
Re: Drag and drop question
I want to move a frame to anywhere on the screen.
-
Mar 7th, 2010, 02:08 PM
#4
Re: Drag and drop question
The following quick sample should get you started:
Code:
Option Explicit
Dim offsetX As Single
Dim offsetY As Single
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
Frame1.Drag vbEndDrag
Frame1.Move X - offsetX, Y - offsetY
End Sub
Private Sub Frame1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
offsetX = X
offsetY = Y
Frame1.Drag vbBeginDrag
End Sub
-
Mar 7th, 2010, 02:10 PM
#5
Re: Drag and drop question
Use:
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
And then in the Mouse_Down event of the Frame:
ReleaseCapture
SendMessage Frame1.hWnd, &H112, &HF012&, 0
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Mar 7th, 2010, 03:19 PM
#6
Thread Starter
Hyperactive Member
Re: Drag and drop question
I've still got the same problem. The outline moves but snaps back into place.
-
Mar 7th, 2010, 03:26 PM
#7
Fanatic Member
Re: Drag and drop question
Check out link below..."Drag & Drop Game
Alpha Micro: Alpha Basic, AS400 V5r2, EDI (Trusted Link/ Inovis.com),Access AS/400 via VB6, Qbasic for data conversions. A mix of Hardware too. ASCII Table , New Number to Words/66 digits , AS/400(v5r2) VB6 Viewer/Ask for code(ODBC) ^ What Is Transferring? , Check your Ports #Perfect Passwords , *Slide Bar Example , Logoff, Restart, Shut-Down PC *Keep Form On Top , Opaque Form ^ Create Objects at Run Time @ Check Key Caps Locks # GetTickCount(System Up Time) * Convert text to Excel & Collected Icons + Resize: Form/Text box ^ PC GateWay via Shell $ Drag & Drop Game ! PopUpMenu *Print File/no Open# Timer on Mult Forms ~ Splash & Mult Forms & Lots of Comments + Random/Timer/Guess * Dec >Hex >Oct >Bin % Get MAC (NIC) < saving to Registry > Wookiee Cookies \ BackUpDisk / World Conection SpeedTest $ Glossary Commonly Used Terms # phonetic list @ Detailed Computer Scan
When posting Code, Use tags.. [CODE] *Your Code* [/CODE]
-
Mar 7th, 2010, 03:56 PM
#8
Thread Starter
Hyperactive Member
Re: Drag and drop question
Thanks.
Not quite what I need. I need it to stay where I drop it and not snap into another spot.
-
Mar 7th, 2010, 05:35 PM
#9
Re: Drag and drop question
 Originally Posted by GARY MICHAEL
I've still got the same problem. The outline moves but snaps back into place.
New cursor location must be outside of original boundaries so form's DragDrop event is triggered.
Otherwise of course it will as you say "snap back".
-
Mar 7th, 2010, 05:38 PM
#10
Re: Drag and drop question
Use My code.. It doesn't Snap BACK.
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Mar 7th, 2010, 05:44 PM
#11
Re: Drag and drop question
Exactly! Someone overlooked it maybe because it's not posted with the CODE tags...
Anyway, all credits go to some1uk03:
Code:
Option Explicit
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Sub Frame1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SendMessage Frame1.hWnd, &H112, &HF012&, 0
End Sub
-
Mar 7th, 2010, 08:07 PM
#12
Thread Starter
Hyperactive Member
Re: Drag and drop question
Some1UK03,
I did try your code and had the same problem, then I loaded a new form and only used your code and it worked.
Could there be something here that interferes with your code?
Code:
Option Explicit
Option Compare Text
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const EM_LINEFROMCHAR = &HC9
Private Const EM_GETLINECOUNT = &HBA
Private Const EM_LINESCROLL = &HB6
Private Const EM_GETFIRSTVISIBLELINE = &HCE
Private Declare Function OSWinHelp% Lib "user32" Alias "WinHelpA" (ByVal hWnd&, ByVal HelpFile$, ByVal wCommand%, dwData As Any)
Private Sub MultiSearchFrame_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SendMessage MultiSearchFrame.hWnd, &H112, &HF012&, 0
End Sub
-
Mar 8th, 2010, 04:30 AM
#13
Re: Drag and drop question
Have you changed your Drag&Drop properties back to normal? Might be interfering.
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Mar 8th, 2010, 06:57 AM
#14
Thread Starter
Hyperactive Member
Re: Drag and drop question
That was it. I never would have figured that out. Thak you everyone. You guys are good.
Last edited by GARY MICHAEL; Mar 8th, 2010 at 09:40 AM.
Thanks,
GARY
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|