【发布时间】:2026-01-20 16:35:01
【问题描述】:
所以我在 c# 中创建了一个 gui,我将边框设置为 None(用于平面样式外观) 我注意到,在任何地方双击 gui 时,它会在整个屏幕上最大化 gui,即使我在选项中禁用了它。
我尝试更改选项并添加双击功能
private void Form1_DoubleClick(object sender, EventArgs e)
{
MessageBox.Show("no", "test");
}
双击 gui 时这不会消失...我现在不知道该怎么做。
有什么想法吗? 完整代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ScrapEX
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
MessageBox.Show("no", "test");
}
private void Form1_DoubleClick(object sender, EventArgs e)
{
MessageBox.Show("no", "test");
}
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case 0x84:
base.WndProc(ref m);
if ((int)m.Result == 0x1)
m.Result = (IntPtr)0x2;
return;
}
base.WndProc(ref m);
}
}
}
现在我可以看到我用来使窗口可调整大小的东西,我可以让它只有一小块区域作为标题栏吗?比如右上角的三角形之类的?很抱歉混合问题,但这是相关的
【问题讨论】:
-
WndProc是什么部分?双击窗口标题有这样的行为。你是在玩非客户区还是什么? -
您可以尝试将您的 FormBorderStyle 更改为 None,例如 Single 或其他。检查是否可以看到最大化按钮。
标签: c# user-interface