How to move a borderless form? 
Author Message
 How to move a borderless form?

Hi.

I need to move a borderless form, and have tried using the form's
mousedown/mousemove events.  While I'm able to move the form, it flashes
like crazy, and it's not 100% accurate.  Here's the code I'm using ... any
help would be appreciated.  I'm sure I'm missing some very simple.

Private Sub frmViewer_MouseDown(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
blnMoving = True
origLoc.X = Me.Location.X
origLoc.Y = Me.Location.Y
origX = e.X
origY = e.Y
End Sub

Private Sub frmViewer_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
If blnMoving = True Then
newloc.X = origLoc.X + (Screen.PrimaryScreen.Bounds.X - origX)
newloc.Y = origLoc.Y + (Screen.PrimaryScreen.Bounds.Y - origY)
If Me.Location.X <> newloc.X Or Me.Location.Y <> newloc.Y Then
Me.Location = newloc
End If
End If
End Sub

Private Sub frmViewer_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
blnMoving = False
newloc.X = newloc.X
newloc.Y = newloc.Y
Me.Location = newloc
End Sub



Sun, 30 Jan 2005 04:56:09 GMT  
 How to move a borderless form?

Quote:
> Hi.

> I need to move a borderless form, and have tried using the form's
> mousedown/mousemove events.  While I'm able to move the form, it flashes
> like crazy, and it's not 100% accurate.  Here's the code I'm using ... any
> help would be appreciated.  I'm sure I'm missing some very simple.

> Private Sub frmViewer_MouseDown(ByVal sender As Object, ByVal e As
> System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
> blnMoving = True
> origLoc.X = Me.Location.X
> origLoc.Y = Me.Location.Y
> origX = e.X
> origY = e.Y
> End Sub

> Private Sub frmViewer_MouseMove(ByVal sender As Object, ByVal e As
> System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
> If blnMoving = True Then
> newloc.X = origLoc.X + (Screen.PrimaryScreen.Bounds.X - origX)
> newloc.Y = origLoc.Y + (Screen.PrimaryScreen.Bounds.Y - origY)
> If Me.Location.X <> newloc.X Or Me.Location.Y <> newloc.Y Then
> Me.Location = newloc
> End If
> End If
> End Sub

> Private Sub frmViewer_MouseUp(ByVal sender As Object, ByVal e As
> System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
> blnMoving = False
> newloc.X = newloc.X
> newloc.Y = newloc.Y
> Me.Location = newloc
> End Sub

You might try this.  It works for me without flicker.

http://www.avenuezx.com/VBnet4apps/tips/2.htm

----
VBnet4Apps
http://www.avenuezx.com/vbnet4apps/



Sun, 30 Jan 2005 04:13:51 GMT  
 How to move a borderless form?
AWESOME!

THank you! Thank You! Thank You!


Quote:


> > Hi.

> > I need to move a borderless form, and have tried using the form's
> > mousedown/mousemove events.  While I'm able to move the form, it flashes
> > like crazy, and it's not 100% accurate.  Here's the code I'm using ...
any
> > help would be appreciated.  I'm sure I'm missing some very simple.

> > Private Sub frmViewer_MouseDown(ByVal sender As Object, ByVal e As
> > System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseDown
> > blnMoving = True
> > origLoc.X = Me.Location.X
> > origLoc.Y = Me.Location.Y
> > origX = e.X
> > origY = e.Y
> > End Sub

> > Private Sub frmViewer_MouseMove(ByVal sender As Object, ByVal e As
> > System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
> > If blnMoving = True Then
> > newloc.X = origLoc.X + (Screen.PrimaryScreen.Bounds.X - origX)
> > newloc.Y = origLoc.Y + (Screen.PrimaryScreen.Bounds.Y - origY)
> > If Me.Location.X <> newloc.X Or Me.Location.Y <> newloc.Y Then
> > Me.Location = newloc
> > End If
> > End If
> > End Sub

> > Private Sub frmViewer_MouseUp(ByVal sender As Object, ByVal e As
> > System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
> > blnMoving = False
> > newloc.X = newloc.X
> > newloc.Y = newloc.Y
> > Me.Location = newloc
> > End Sub

> You might try this.  It works for me without flicker.

> http://www.avenuezx.com/VBnet4apps/tips/2.htm

> ----
> VBnet4Apps
> http://www.avenuezx.com/vbnet4apps/



Sun, 30 Jan 2005 05:38:20 GMT  
 How to move a borderless form?
   Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
      MyBase.WndProc(m)
      If m.Msg = &H84 Then
         If m.Result.ToInt32 = 1 Then m.Result = New IntPtr(2)
      End If
   End Sub

HTH

--
Corrado Cavalli
UGIdotNET - http://www.ugidotnet.org



Sun, 30 Jan 2005 05:44:56 GMT  
 How to move a borderless form?
Hi Corrado:

That's really cool code!  Now if I could just understand why/how it works,
I'd really be happy!

Thanks much!
Terry

Quote:
>    Protected Overrides Sub WndProc(ByRef m As

System.Windows.Forms.Message)
Quote:
>       MyBase.WndProc(m)
>       If m.Msg = &H84 Then
>          If m.Result.ToInt32 = 1 Then m.Result = New IntPtr(2)
>       End If
>    End Sub

> HTH

> --
> Corrado Cavalli
> UGIdotNET - http://www.ugidotnet.org



Sun, 30 Jan 2005 07:24:12 GMT  
 How to move a borderless form?
If simply looks for WM_NCHITTEST message (0x84), this message i sent from
windows to check what area is the cursor on.
If normal OS processing (done by MyBase.WndProc method) returns 1
(HT_CLIENT) meaning that cursor is on client area, it change it to 2
(HT_CAPTION) fooling Windows to believe that cursor is on caption area, this
enabled mouse dragging...

HTH

--
Corrado Cavalli
UGIdotNET - http://www.ugidotnet.org



Sun, 30 Jan 2005 06:31:00 GMT  
 How to move a borderless form?
Thanks Corrado ... you described this well!

Quote:
> If simply looks for WM_NCHITTEST message (0x84), this message i sent from
> windows to check what area is the cursor on.
> If normal OS processing (done by MyBase.WndProc method) returns 1
> (HT_CLIENT) meaning that cursor is on client area, it change it to 2
> (HT_CAPTION) fooling Windows to believe that cursor is on caption area,
this
> enabled mouse dragging...

> HTH

> --
> Corrado Cavalli
> UGIdotNET - http://www.ugidotnet.org



Sun, 30 Jan 2005 08:02:39 GMT  
 
 [ 8 post ] 

 Relevant Pages 

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

2. How do I move a borderless form using the mouse?

3. Moving a shaped borderless form in real time??

4. HELP with moving borderless forms around screen

5. moving borderless window / form

6. moving borderless window / form

7. moving borderless window / form

8. Borderless Borderless Form

9. Move a borderless window

10. Drag borderless form/window?

11. borderless form automatically resizes?

12. Borderless Forms and TaskBar Titles

 

 
Powered by phpBB® Forum Software