Moving a shaped borderless form in real time?? 
Author Message
 Moving a shaped borderless form in real time??

Hi,

Ive created a form that has a circular shape and i have removed the
border and titlebar. I wish to be able to move the form in real time
when the user clicks and drags on the form. I had some code that enabled
be to trick the form into thinking you had clicked the MOVE command in
the control box in the corner of the form, but this brings up the border
of the actual form and ruins the circle effect, and the form doesn't
actually move until you release the mouse button. I would like the form
to follow the mouse all the time it is being dragged.

Any help would be great.

-Cheers



Sun, 23 Dec 2001 03:00:00 GMT  
 Moving a shaped borderless form in real time??
Hi Aaron,
Here is a code snipet that might get you started...
nCurX and nCurY are form level varibles...

Private Sub frmCursor_MouseDown(Button As Integer, Shift As Integer, x As
Single, y As Single)

    If Button = vbLeftButton Then
        nCurX = x
        nCurY = y
    End If

End Sub

Private Sub frmCursor_MouseMove(Button As Integer, Shift As Integer, x As
Single, y As Single)

    If Button = vbLeftButton Then
        With frmCursor
            .Left + x - nCurX < 0 Then x = nCurX
            .Left + .Width + x - nCurX > Screen.Width Then x = nCurX
            .Top + y - nCurY < 0 Then y = nCurY
            .Top + .Height + y - nCurY > Screen.Height Then y = nCurY
            .Move .Left + x - nCurX, .Top + y - nCurY
        End With
        DoEvents
    End If

End Sub

--

Have a good day.
Don

Quote:

>Hi,

>Ive created a form that has a circular shape and i have removed the
>border and titlebar. I wish to be able to move the form in real time
>when the user clicks and drags on the form. I had some code that enabled
>be to trick the form into thinking you had clicked the MOVE command in
>the control box in the corner of the form, but this brings up the border
>of the actual form and ruins the circle effect, and the form doesn't
>actually move until you release the mouse button. I would like the form
>to follow the mouse all the time it is being dragged.

>Any help would be great.

>-Cheers



Sun, 23 Dec 2001 03:00:00 GMT  
 Moving a shaped borderless form in real time??
Sorry but the code was Hacked from a project where I was moving a control
After I posted the code I saw Many mistakes and fix'd it...
This works for me...

Option Explicit
Dim nCurX As Single
Dim nCurY As Single

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single,
Y As Single)

    If Button = vbLeftButton Then
        nCurX = X
        nCurY = Y
    End If

End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single,
Y As Single)

    If Button = vbLeftButton Then
        With frmCursor
           If .Left + X - nCurX < 0 Then X = nCurX
           If .Left + .Width + X - nCurX > Screen.Width Then X = nCurX
           If .Top + Y - nCurY < 0 Then Y = nCurY
           If .Top + .Height + Y - nCurY > Screen.Height Then Y = nCurY
            .Move .Left + X - nCurX, .Top + Y - nCurY
        End With
        DoEvents
    End If

End Sub

--

Have a good day.
Don

Quote:

>Hi Aaron,
>Here is a code snipet that might get you started...
>nCurX and nCurY are form level varibles...

>Private Sub frmCursor_MouseDown(Button As Integer, Shift As Integer, x As
>Single, y As Single)

>    If Button = vbLeftButton Then
>        nCurX = x
>        nCurY = y
>    End If

>End Sub

>Private Sub frmCursor_MouseMove(Button As Integer, Shift As Integer, x As
>Single, y As Single)

>    If Button = vbLeftButton Then
>        With frmCursor
>            .Left + x - nCurX < 0 Then x = nCurX
>            .Left + .Width + x - nCurX > Screen.Width Then x = nCurX
>            .Top + y - nCurY < 0 Then y = nCurY
>            .Top + .Height + y - nCurY > Screen.Height Then y = nCurY
>            .Move .Left + x - nCurX, .Top + y - nCurY
>        End With
>        DoEvents
>    End If

>End Sub

>--

>Have a good day.
>Don


>>Hi,

>>Ive created a form that has a circular shape and i have removed the
>>border and titlebar. I wish to be able to move the form in real time
>>when the user clicks and drags on the form. I had some code that enabled
>>be to trick the form into thinking you had clicked the MOVE command in
>>the control box in the corner of the form, but this brings up the border
>>of the actual form and ruins the circle effect, and the form doesn't
>>actually move until you release the mouse button. I would like the form
>>to follow the mouse all the time it is being dragged.

>>Any help would be great.

>>-Cheers



Sun, 23 Dec 2001 03:00:00 GMT  
 Moving a shaped borderless form in real time??

Quote:
>Ive created a form that has a circular shape and i have removed the
>border and titlebar. I wish to be able to move the form in real time
>when the user clicks and drags on the form. I had some code that enabled
>be to trick the form into thinking you had clicked the MOVE command in
>the control box in the corner of the form, but this brings up the border
>of the actual form and ruins the circle effect, and the form doesn't
>actually move until you release the mouse button. I would like the form
>to follow the mouse all the time it is being dragged.

Go to my web page and download MOVEFORM.ZIP which demonstrates the code
necessary to let the user move a form without a title bar.

Lee Weiner
weiner AT fuse DOT net
http://home.fuse.net/lweiner



Sun, 23 Dec 2001 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. How to move a borderless form?

2. How can you move a borderless form around in 32-bit VB4 Enterprise

3. HELP with moving borderless forms around screen

4. moving borderless window / form

5. moving borderless window / form

6. moving borderless window / form

7. Borderless Borderless Form

8. Can't get real-time shape/picture updates to display

9. Move a borderless window

10. move shape between pages / Move-Event ?

11. real time text clock in form

12. Real time: form views to avi file

 

 
Powered by phpBB® Forum Software