禁用双击最大化

Disable maximize on double click

所以我在 C# 中创建了一个图形用户界面,我将边框设置为 None(为了平面样式的外观) 我注意到,在任何地方双击图形用户界面后,即使我在选项中禁用了它,它也会在整个屏幕上最大化图形用户界面。

我尝试更改选项并添加双击功能

    private void Form1_DoubleClick(object sender, EventArgs e)
    {
        MessageBox.Show("no", "test");

    }

双击图形用户界面时没有消失...我现在不知道该怎么做。

有什么想法吗? 完整代码:

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);

    }



}

}

既然我可以看到我一直在使用什么来使 window 可调整大小,我能否将其设置为只有一小块区域充当标题栏?比如右上角的三角形之类的?抱歉混淆问题,但这是相关的

@Sinatr indicates 一样,您的 WndProc 通过设置 2HTCAPTION 来响应每个 WM_NCHITTEST 查询,有效地使您的整个表单充当标题栏。

这将使您的表单 double-clicking(取消)最大化。

另见 MSDN: WM_NCHITTEST message

关于您的编辑,您似乎想制作一个自定义标题栏。请参阅 Win api in C#. Get Hi and low word from IntPtr 以获得具有 X 和 Y 坐标的 Point,因此您可以确定何时设置 1 (HTCLIENT) 或 2 (HTCAPTION)。