FormBorderStyle = None的表单的Aero Snap效果 [英] Aero Snap effect for form with FormBorderStyle = None

查看:94
本文介绍了FormBorderStyle = None的表单的Aero Snap效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用FormBorderStyle = None进行winform,如果他触摸侧面屏幕我需要添加部署表单(这很容易),但是如何添加aero demo作为表单将部署,我不能。

在函数Dwmapi.dll中搜索,但未找到。

截图。

解决方案

将以下内容添加到表单中:

 < span class =code-keyword> protected  覆盖 CreateParams CreateParams 
{
获取
{
CreateParams cp = base .CreateParams;
cp.Style | = 0x40000; // WS_SIZEBOX;
return cp;
}
}





虽然我通常使用:

 受保护 覆盖 CreateParams CreateParams 
{
get
{
CreateParams cp = base .CreateParams;
{
cp.Style | = 0x20000 | 0x80000 | 0x40000; // WS_MINIMIZEBOX | WS_SYSMENU | WS_SIZEBOX;
}
return cp;
}
}


我找到了解决方案,如果标题栏上的光标返回HTCAPTION,则需要处理WM_NCHITTEST。测试代码,如果所有表格标题栏。



<前lang =c#> 受保护 覆盖 void WndProc( ref 消息消息)
{
base .WndProc( ref 消息);

if (message.Msg == WM_NCHITTEST)
message.Result =( IntPtr的)HTCAPTION;
}


I have winform with FormBorderStyle = None and I need add deployment form if he touch sides screen (it is easy) , but how add aero demo as form will be deploy, i can not.
Searched in functions Dwmapi.dll, but did not find.
Screenshot.

解决方案

Add the following to your Form:

protected override CreateParams CreateParams
{
   get
   {
      CreateParams cp = base.CreateParams;
      cp.Style |= 0x40000; //WS_SIZEBOX;
      return cp;
   }
}



though I usually use:

protected override CreateParams CreateParams
{
   get
   {
      CreateParams cp = base.CreateParams;
      {
         cp.Style |= 0x20000 | 0x80000 | 0x40000; //WS_MINIMIZEBOX | WS_SYSMENU | WS_SIZEBOX;
      }
      return cp;
   }
}


I found solution, need handle WM_NCHITTEST if cursor on title bar return HTCAPTION. Test code if all form title bar.

protected override void WndProc(ref Message message)
        {
            base.WndProc(ref message);

            if (message.Msg == WM_NCHITTEST )
                            message.Result = (IntPtr)HTCAPTION;
        }


这篇关于FormBorderStyle = None的表单的Aero Snap效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆