2015-03-03 108 views
0

所以即时创建在c#中的GUI,我将边界设置为无(为平面样式看) 和我注意到,在任何地方双击gui它最大化整个屏幕上的GUI甚至我禁用它的选项。禁用最大化双击

http://i.stack.imgur.com/FIjxa.png

我试图改变选项,并增加了双击功能

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

    } 



} 

}

现在

,我可以看到,香港专业教育学院一直在使用它来使窗口调整大小,我可以使它所以只有一个小区域作为标题栏?像右上角的三角形或什么?遗憾的混合问题,但是这是通过设置2,或HTCAPTION,有效地使你的整个形式充当标题栏相关

+1

这个'WndProc'部分是什么?双击窗口标题具有这种行为。你在玩非客户区域还是什么? – Sinatr 2015-03-03 13:07:13

+0

你可以尝试改变你的FormBorderStyle以外的无,像单身或其他东西。检查是否可以看到最大化按钮。 – 2015-03-03 13:45:40

回答

1

由于@Sinatr indicates,你WndProc正在应对每WM_NCHITTEST查询。

这使双击(联合国)最大化你的形式。

另请参阅MSDN: WM_NCHITTEST message

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

+0

哦,right..so我怎样才能让窗口移动而不会造成这种情况?如果我不能。是否有双击标题栏的事件? – 2015-03-03 13:11:10

+0

提到您添加了重写以使您的窗口可拖动将在您的问题中成为有价值的信息。请包括所有相关的细节。查看重复的一些问题的答案。 – CodeCaster 2015-03-03 13:13:21