Moving a borderless window

M

Mike Finister

Hi there

I'm new to .NET...so still playing with some stuff.

What I am wondering is how to move around a window whose border I have
removed?

I am looking to put buttons on a background graphic with parts of it being
transparent...basically to show off what .NET can do.

However, with no window title I cannot drag it around the screen...

I have written a quick piece of code that handles the mousedown and
mousemove events and uses the X and Y co-ordinates differences to set the
Left and Top of the form.

This works...but is VERY jerky :-(

Anyone have any help here...really looking to move it smoothly around the
screen just like when you grab the title bar...

Thanks in advance

Mike

(e-mail address removed)
 
J

Jeremy Cowles

Mike Finister said:
Hi there

I'm new to .NET...so still playing with some stuff.
What I am wondering is how to move around a window whose border I have
removed?
I am looking to put buttons on a background graphic with parts of it being
transparent...basically to show off what .NET can do.
However, with no window title I cannot drag it around the screen...
I have written a quick piece of code that handles the mousedown and
mousemove events and uses the X and Y co-ordinates differences to set the
Left and Top of the form.
This works...but is VERY jerky :-(

Anyone have any help here...really looking to move it smoothly around the
screen just like when you grab the title bar...

MSDN: "HOWTO: Move a form that has no title bar"
http://support.microsoft.com/default.aspx?scid=kb;en-us;173773

Note: this article is for VB6, here is my port of the APIs to .NET:

Private Declare Function SendMessage Lib "User32" _
Alias "SendMessageA" (ByVal hWnd As IntPtr, _
ByVal wMsg As Integer, _
ByVal wParam As Integer, _
lParam As Integer) As Integer

Private Declare Sub ReleaseCapture Lib "User32" ()

Const WM_NCLBUTTONDOWN as Integer = &HA1
Const HTCAPTION as Integer = 2

'// USAGE:

Private Sub Control_MouseDown(...)
lngReturnValue = SendMessage(me.Handle, WM_NCLBUTTONDOWN, _
HTCAPTION, 0&)
End Sub


Private Sub Control_MouseUp(...)
Call ReleaseCapture( )
End Sub

HTH,
Jeremy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top