所以我有一个无边框表单,我需要调整它的大小(通过单击 4 个边或角中的任何一个)。澄清一下,我希望我的表单像 Windows 7 中的默认便签一样无边框。
通过使用 Julien Lebosquain 在这篇文章中提供的代码,我已经让它可以工作了(目前仅在右下角):
调整右下角无边框窗口的大小 https://stackoverflow.com/questions/1535826/resize-borderless-window-on-bottom-right-corner/1535943#1535943
但是,我真的很想在右下角显示拖动夹具图像。 Julien 在他的帖子中提到了关于抓手的这一点:
你可以初始化一个新的
VisualStyleRenderer(VisualStyleElement.Status.Gripper.Normal) 和
使用它的PaintBackground()
method.
我不知道如何在我的表单中执行此操作。有人能指出我正确的方向吗?
谢谢。
因此,在这里阅读了一些内容之后:http://msdn.microsoft.com/en-us/library/system.windows.forms.visualstyles.visualstyleelement.status.gripper.normal.aspx http://msdn.microsoft.com/en-us/library/system.windows.forms.visualstyles.visualstyleelement.status.gripper.normal.aspx,我已经找到解决办法了。
首先覆盖OnPaint()
表单的事件。
protected override void OnPaint(PaintEventArgs e) {
base.OnPaint(e);
DrawGripper(e);
}
以及绘图的方法。
public void DrawGripper(PaintEventArgs e) {
if (VisualStyleRenderer.IsElementDefined(
VisualStyleElement.Status.Gripper.Normal)) {
VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Status.Gripper.Normal);
Rectangle rectangle1 = new Rectangle((Width) - 18, (Height) - 20, 20, 20);
renderer.DrawBackground(e.Graphics, rectangle1);
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)