duilib中禁止一个窗口双击最大化

用duilib开发了一个窗口,比如是登录窗口,那么这个窗口的窗口的双击最大化就毫无意义,甚至带来灾难,我们就要明确禁止这样的行为。

我们应该明确,一个窗口创建的时候就赋予了它一些属性,那我们就首先看看如何创建窗口的,即Create函数。

例如,你定义了一个窗口类叫LogInWnd,你会在需要的时候这用进行创建一个窗口:

<code class="hljs sql has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background: transparent;">LogInWnd login_wnd;
login_wnd.<span class="hljs-operator" style="box-sizing: border-box;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">Create</span>(nullptr, _T(<span class="hljs-string" style="color: rgb(0, 136, 0); box-sizing: border-box;">"登录窗口"</span>), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE);</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

我们注意到Create的第三个参数是宏定义,可以看出是跟windows style相关的一些定义,那我们就看看吧:

<code class="hljs cs has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">#<span class="hljs-keyword" style="box-sizing: border-box;">define</span> UI_WNDSTYLE_FRAME      (WS_VISIBLE | WS_OVERLAPPEDWINDOW)</span>

<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">#<span class="hljs-keyword" style="box-sizing: border-box;">define</span> UI_WNDSTYLE_DIALOG     (WS_VISIBLE | WS_POPUPWINDOW | WS_CAPTION | WS_DLGFRAME | WS_CLIPSIBLINGS | WS_CLIPCHILDREN)</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li><li style="box-sizing: border-box; padding: 0px 5px;">3</li></ul>

这里呢,我们注意是分析一下UI_WNDSTYLE_FRAME 和 UI_WNDSTYLE_DIALOG 的区别所在。

UI里的宏 
窗体样式宏 
UI_WNDSTYLE_CONTAINER 容器样式,无任何样式

UI_WNDSTYLE_FRAME UI标准框架窗体样式(标题栏、边框、图标、标题、最大、最小按钮、关闭按钮)

UI_WNDSTYLE_CHILD UI窗体子控件样式

UI_WNDSTYLE_DIALOG UI对话框窗体样式扩展窗体样式宏

UI_WNDSTYLE_EX_FRAME 窗体客户区凹陷样式

UI_WNDSTYLE_EX_DIALOG 工具栏窗口样式+模式对话框样式

因此 如果我们想要禁止双击最大化,那再创建窗口的时候就使用UI_WNDSTYLE_DIALOG 这个宏定义。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值