Form without border

G

Guest

I want to move and resize a window without border. I solved the problem of
moving thanks to internet search by using

ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);

In the Mouse_Down event handler.

Is there a similar way to size the window? Just replacing HT_CAPTION with
HT_BORDER_LEFT or one of the other HT_BORDER_... commands doesn’t seem to
work.

Chris
 
H

Herfried K. Wagner [MVP]

cnickl said:
I want to move and resize a window without border. I solved the problem of
moving thanks to internet search by using

ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);

In the Mouse_Down event handler.

Is there a similar way to size the window? Just replacing HT_CAPTION with
HT_BORDER_LEFT or one of the other HT_BORDER_... commands doesn’t seem to
work.

<URL:http://dotnetrix.co.uk/misc.html>
-> "An example of a moveable/resizable shaped form."
 
S

Stoitcho Goutsev \(100\)

Hi,

Do you want to let the user resize and move borderless form with the mouse
or you want to do it from code?

I'm asking because if you want to allow the user do it there is a better way
to accomplish this.
 
J

JezzzMoore

cnickl said:
I want to move and resize a window without border. I solved the problem of
moving thanks to internet search by using

ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HT_CAPTION, 0);

In the Mouse_Down event handler.

Is there a similar way to size the window? Just replacing HT_CAPTION with
HT_BORDER_LEFT or one of the other HT_BORDER_... commands doesn’t seem to
work.

Chris

Could you give the exact code you used to make the window movable without a
window border?

Ive been trying for weeks to make my form movable without a window border
and i cant fin the code anywhere!

Thanks,
 
P

Peter Morris

If you send the form a windows message

WM_SYSCOMMAND, 0xF012, 0

then you can move it at runtime. Only ever done it in Delphi though...

Perform(WM_SYSCOMMAND, $F012, 0);


Not even looked at how to send a windows message to a WinForm control.



--
Pete
=========================================
I use Enterprise Core Objects (Domain driven design)
http://www.capableobjects.com/
=========================================
 
C

Claes Bergefall

JezzzMoore said:
Could you give the exact code you used to make the window movable without
a
window border?

Ive been trying for weeks to make my form movable without a window border
and i cant fin the code anywhere!

Override WndProc in your Form and handle the WM_NCHITTEST notification.
Return HTCAPTION for any coordinate that should allow moving the window.
Something like this:

private const int HTCAPTION = 2;
private const int WM_NCHITTEST = 0x84;

protected override void WndProc(ref Message m)
{
if (m.Msg == WM_NCHITTEST)
{
Point pt = new Point(m.LParam.ToInt32());
pt = this.PointToClient;
if (DoesThisCoordinateAllowTheWindowToBeMoved(pt))
m.Result = new IntPtr(HTCAPTION);
else
base.WndProc(m);
}
else
{
base.WndProc(m);
}

}
 

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