|
-
Oct 26th, 2001, 04:16 AM
#1
Thread Starter
Lively Member
Using 'SendMessage' to manually drag a form
Hi,
I have managed to allow a form to be dragged by using the _MouseDown Sub that is triggered with a picturebox upon mouse down...
It works quite well, however 'ReleaseCapture' is also used, and this prevents _MouseUp from being triggered.
Why is this important you may ask?
Becuase on _MouseDown, 'pic_Caption.BackColor = 255' is used (pic_Caption is the picturebox name) changing the color of the picturebox to red, which signified that the user is dragging the window.
So I need something to be triggered when the user has stopped dragging the form to return pic_Caption.BackColor to it's original color, which is black.
'pic_Caption.BackColor = 0'
Please take a look at the source included and share your idea's/solutions.
Thanks,
Sphynx
-
Oct 26th, 2001, 06:24 AM
#2
I use the following code to simulate a mouseover/mouseleave event. When the mouse is over my command button, I change the backcolor to cyan, and when the mouse has left my button I change it back to the standard gray
VB Code:
If (X < 0) Or (Y < 0) Or (X > cmdAbout.Width) Or (Y > cmdAbout.Height) Then ' the MOUSELEAVE pseudo-event
ReleaseCapture ' the mouse is no longer over the button, change backcolor to gray
cmdAbout.BackColor = &HC0C0C0
ElseIf GetCapture() <> cmdAbout.hWnd Then ' the MOUSEENTER pseudo-event
SetCapture cmdAbout.hWnd ' the mouse is over the button, change backcolor to cyan
cmdAbout.BackColor = vbCyan
End If
Problem: When a user clicks the button it remained cyan even after the mouse had left. Solution: I put
VB Code:
ReleaseCapture
cmdAbout.BackColor = &HC0C0C0
in the buttons click event. So, my suggestion would be to change your mouseevent to the following
VB Code:
Private Sub pic_Caption_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
pic_Caption.BackColor = 255
If Button = 1 Then On Error Resume Next: FormDrag Me
ReleaseCapture
pic_Caption.BackColor = 0
End Sub
PS: I did this on your form and it worked like a champ.
-
Oct 27th, 2001, 07:23 AM
#3
Thread Starter
Lively Member
Manual Dragging.. AND Resizing :)
Hey, thanks for the help Hack.
I've added some more code and come across a new problem, I wanted to allow the window to be resized manually.
See if you can help me out and check out the code attached.
Thanks,
Sphynx
Last edited by sphynx; Oct 27th, 2001 at 01:25 PM.
-
Oct 27th, 2001, 01:25 PM
#4
Thread Starter
Lively Member
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
|