c# - 如何在不影响行为的情况下处理表单中的 wndproc calcsize 进程进行自定义
问题描述
我正在开发一个自定义表单,它提供了更多选项来自定义表单的外观。在 wndproc 中获取消息 131 时,我已经覆盖了 wndproc 并在 calcsize() 方法中计算了表单的大小。我已经完成了在 calcsize() 中自定义标题栏高度的计算。请参考下面的代码。问题是在 Windows 10 和 8 中使用边框样式 sizeablewindowtool 打开表单时,表单进入任务栏(这是一种行为msdn 表单)。但是问题是当我在 windows 7 中打开表单时,表单进入任务栏。我已经检查了 msdn 表单,它没有进入 windows 7 的任务栏。请帮我找到我的错误。
/// <summary>
/// Calculates the non client area of the form
/// </summary>
/// <param name="m">reference message</param>
/// <returns>retruns true if the method returns combiantion of values
/// returns false if the method return zero</returns>
private bool OnWmNcCalcSize(ref Message m)
{
NativeMethods.RECT rc = (NativeMethods.RECT)m.GetLParam(typeof(NativeMethods.RECT));
int iBorderWidth = fl.BorderWidth;
fl.PerformLayout(rc.Width, rc.Height);
rc.top += fl.CaptionHeight;
if (this.WindowState == FormWindowState.Maximized)
{
///<summary>
/// local variable to store x-coordinate of native rectangle,rc.left is -6 when we double click on title-bar and -8 when we click the maximize button.
///</summary>
int xcoordinate = rc.left;
rc.left -= xcoordinate;
rc.right += xcoordinate;
rc.bottom += xcoordinate;
}
else
{
rc.left += iBorderWidth - (iBorderWidth / 3);
rc.right -= iBorderWidth - (iBorderWidth / 3);
rc.bottom -= iBorderWidth - (iBorderWidth / 3);
}
Marshal.StructureToPtr(rc, m.LParam, true);
m.Result = IntPtr.Zero;
return true;
}
解决方案
推荐阅读
- vba - 在不接受更改的情况下在 Tracked Change 中显示最终建议的文本
- debugging - 有没有办法在 VSC 中复制未转义的文本变量值?
- c# - 如何将焦点设置在 ViewModel (WPF/MVVM) 中的 TextBox 上?
- amazon-web-services - 用于创建触发 lambda 函数的云监视事件的 Terraform 代码
- java - 没有可用的名为“DAOBean”的 bean
- javascript - Jquery cookie插件从多个项目中删除项目
- networking - 如何知道我的测试(使用 JMeter)将产生的网络流量?
- java - 返回总和最大的数组。如果出现平局,则返回
- python - 我如何制作值元组?
- c - CMake:在工具链文件中添加编译器标志