Re: Move borderless form.
Add this and take out all of your moving code:
vb.net Code:
Protected Overrides Sub WndProc(ByRef e As Message)
MyBase.WndProc(e)
If e.Message = &H84 AndAlso e.Result = &H1 Then e.Result = &H2
End Sub
Re: Move borderless form.
Quote:
Originally Posted by
minitech
Add this and take out all of your moving code:
vb.net Code:
Protected Overrides Sub WndProc(ByRef e As Message)
MyBase.WndProc(e)
If e.Message = &H84 AndAlso e.Result = &H1 Then e.Result = &H2
End Sub
That doesn't really want to work for me. e.message is underlined.
Re: Move borderless form.
Quote:
Originally Posted by
DerekM
That doesn't really want to work for me. e.message is underlined.
Change it to e.Msg. Sorry!
Re: Move borderless form.
Quote:
Originally Posted by
minitech
Add this and take out all of your moving code:
vb.net Code:
Protected Overrides Sub WndProc(ByRef e As Message)
MyBase.WndProc(e)
If e.Message = &H84 AndAlso e.Result = &H1 Then e.Result = &H2
End Sub
Not so sure about those magic numbers. What are &H84, &H1 and &H2?
Re: Move borderless form.
&H84: Some sort of mousedown
&H1 result of &H84: The client area of a window.
&H2 result of &H84: The title bar of a window.
You're telling the windows message system that if the mouse is down on the client area, it's actually on the nonexistant title bar. :D
Normally people use named constants, but I think it's unneccessary.
Re: Move borderless form.
Quote:
Originally Posted by
minitech
Normally people use named constants, but I think it's unneccessary.
Thats fine so long as no one else will ever need to work with your code. You should always use named constants if you are writing code that someone else will need to look at (like if you're using your code to illustrate a mechanism on a forum!)
Re: Move borderless form.
Quote:
Originally Posted by
minitech
Change it to e.Msg. Sorry!
Works great! :thumb: But how could I apply this to any control?
Re: Move borderless form.
Quote:
Originally Posted by
minitech
Normally people use named constants, but I think it's unneccessary.
I used to think so too, but then I had to edit 2 year old code that I wrote... it changed my way of thinking PDQ! :thumb:
Re: Move borderless form.
Take a look at my signature, there's a codebank submission on doing what you want to do. Instead of only moving, there is also resizing, including a cursor that changes to the correct resizing cursor.
It uses more or less the same code as minitech's code; it makes the window think the user is moving it via the title bar, instead of you manually setting the Location each time. This way it is much smoother, and there is no danger of 'letting the form slip' (if you use the manual way and move too fast, the form will not be able to update quickly enough or something and you will lose it).