我很生气,我答应了一个用户无法调整大小的固定窗口,但当然他们可以双击标题栏以最大化这个"不可调整的"窗口.我该怎么办呢?我可以使用winforms代码执行此操作,还是必须转到Win32?
谢谢!
ion*_*den 30
您可以将MaximizeBox
表单的属性设置为false
Sal*_*lty 20
您可以禁用标题栏上的双击消息(或更改最大化窗口的默认行为).它适用于任何FormBorderStyle:
private const int WM_NCLBUTTONDBLCLK = 0x00A3; //double click on a title bar a.k.a. non-client area of the form
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_NCLBUTTONDBLCLK)
{
m.Result = IntPtr.Zero;
return;
}
base.WndProc(ref m);
}
Run Code Online (Sandbox Code Playgroud)
干杯!
小智 9
/// ///这是我们重写基本WIN32窗口过程,以防止鼠标移动窗体以及鼠标双击调整大小./// ///
protected override void WndProc(ref Message m)
{
const int WM_SYSCOMMAND = 0x0112;
const int SC_MOVE = 0xF010;
const int WM_NCLBUTTONDBLCLK = 0x00A3; //double click on a title bar a.k.a. non-client area of the form
switch (m.Msg)
{
case WM_SYSCOMMAND: //preventing the form from being moved by the mouse.
int command = m.WParam.ToInt32() & 0xfff0;
if (command == SC_MOVE)
return;
break;
}
if(m.Msg== WM_NCLBUTTONDBLCLK) //preventing the form being resized by the mouse double click on the title bar.
{
m.Result = IntPtr.Zero;
return;
}
base.WndProc(ref m);
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
17803 次 |
最近记录: |