首先,对不起我的英语不好:)
其次,我可以知道何时移动/调整表单大小,使用以下代码:
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_WINDOWPOSCHANGING)
{
WINDOWPOS winPos = new WINDOWPOS();
winPos = (WINDOWPOS)Marshal.PtrToStructure(m.LParam, typeof(WINDOWPOS));
//Here I just need to change the values of the WINDOWPOS structure
Marshal.StructureToPtr(winPos, m.LParam, true);
}
}
WM_WINDOWPOSCHANGING 消息也会在用户最小化或最大化窗口时发送。但是我怎么知道用户何时最大化/最小化,而不是移动/调整大小?我尝试获取 WindowState 属性,但它不起作用:(
WINDOWPOS 结构的代码是:
[StructLayout(LayoutKind.Sequential)]
public struct WINDOWPOS
{
public IntPtr hwnd;
public IntPtr hwndInsertAfter;
public int x;
public int y;
public int cx;
public int cy;
public int flags;
}
有什么帮助吗?