ClayB
Tue Sep 07 04:27:16 CDT 2004
You might be able to do this if you override WndProc and ignore non-client
mouse downs in the titlebar of your form. You would probably want to do some
additional hit testing to allow clicks on the system menu and the maximize,
minimize and close buttons (if they are visible).
private int captionHeight = SystemInformation.CaptionHeight;
private Size captionButtonSize = SystemInformation.CaptionButtonSize;
protected override void WndProc(ref Message m)
{
if(m.Msg == 0xa1) //(WM_NCLBUTTONDOWN)
{
Point pt = this.PointToClient(Control.MousePosition);
//very simple hittest to allow clicks on buttons in the caption
if( pt.Y < captionHeight && pt.X > captionButtonSize.Width - 4 && pt.X <
this.Width - 3 * captionButtonSize.Width)
{
Console.WriteLine(m);
return;// ignore them
}
}
base.WndProc (ref m);
}
==================================
Clay Burch, .NET MVP
Visit www.syncfusion.com for the coolest tools
"Rommel Ladera via .NET 247" <anonymous@dotnet247.com> wrote in message
news:%230BCoL3kEHA.3896@TK2MSFTNGP15.phx.gbl...
> Does anybody know what's the best way to lock the window's position in
> .NET besides using Windows API?
>
> Basically, it will prevent the user from moving the windows form.
>
> --------------------------------
> From: Rommel Ladera
>
> -----------------------
> Posted by a user from .NET 247 (
http://www.dotnet247.com/)
>
> <Id>GBWC9OW3eUy1j6phgTAt7A==</Id>