DUILIB创建不规则窗体

上传者: harvic880925 | 上传时间: 2024-08-23 14:15:02 | 文件大小: 8.74MB | 文件类型: RAR
在Windows编程中,常规的窗口通常都是矩形的,但有时候我们可能需要创建不规则形状的窗体,比如自定义的对话框或者游戏界面。DUILIB是一个轻量级的UI库,它允许开发者实现这样的功能。这个库是基于DirectUI技术的,提供了一种高效的方式来构建用户界面。本文将深入探讨如何利用DUILIB来创建不规则窗体。 了解DUILIB的基础知识是必要的。DUILIB是基于C++的一个UI库,它的设计思想源于.NET Framework中的Windows Forms,但是它是为Windows API量身定制的。DUILIB提供了丰富的控件和布局管理,使得开发者可以轻松地创建美观的界面。它支持XML来定义界面布局,这使得界面设计变得直观且易于维护。 创建不规则窗体的核心在于使用“形状区域”(Rgn)的概念。在Windows API中,可以通过`CreateRoundRectRgn`、`CreatePolygonRgn`等函数创建不同形状的区域。在DUILIB中,我们可以利用`CControlUI`类的`SetRgn`方法设置窗体的形状区域。`SetRgn`接受一个`HRGN`类型的参数,这个参数就是我们创建的形状区域句柄。 步骤如下: 1. 你需要包含DUILIB的相关头文件并初始化库。 2. 创建一个新的窗体类,继承自`CWindowWnd`或`CDialogWnd`,这两个类都提供了基本的窗口操作。 3. 在窗体类中,覆盖`OnCreate`方法。在这个方法里,你可以使用`::CreateRoundRectRgn`或`::CreatePolygonRgn`创建一个自定义形状的区域,然后调用`SetRgn(NULL)`清空当前的形状,再调用`SetRgn`设置新创建的区域。 4. 为了使不规则窗体能够响应鼠标事件,还需要重写`OnMessage`方法,处理`WM_NCHITTEST`消息。这个消息决定了鼠标点击在哪个部分,对于不规则形状的窗体,我们需要根据形状区域来判断。 5. 不要忘记在`OnPaint`方法中正确绘制窗体内容,确保它们在形状区域内。 在提供的文件`blog_try`和`blog_try_new`中,可能包含了实现上述步骤的代码示例。通过阅读和分析这些代码,你可以更好地理解如何在实际项目中应用这些概念。这些代码可能包括了窗体类的定义、XML布局文件以及主程序的入口点。 总结来说,DUILIB提供了创建不规则窗体的能力,这使得开发者可以突破传统的矩形限制,创造出更具创意和个性化的用户界面。通过理解DUILIB的基本用法,结合Windows API中的形状区域功能,你可以轻松实现这一目标。通过学习和实践,你将在UI设计方面获得更广阔的空间。

文件下载

资源详情

[{"title":"( 120 个子文件 8.74MB ) DUILIB创建不规则窗体","children":[{"title":"IrregularWindow.cpp <span style='color:#111;'> 8.54KB </span>","children":null,"spread":false},{"title":"blog_try.cpp <span style='color:#111;'> 3.36KB </span>","children":null,"spread":false},{"title":"blog_try.cpp <span style='color:#111;'> 2.70KB </span>","children":null,"spread":false},{"title":"stdafx.cpp <span style='color:#111;'> 213B </span>","children":null,"spread":false},{"title":"stdafx.cpp <span style='color:#111;'> 213B </span>","children":null,"spread":false},{"title":"Thumbs.db <span style='color:#111;'> 25.50KB </span>","children":null,"spread":false},{"title":"Thumbs.db <span style='color:#111;'> 18.50KB </span>","children":null,"spread":false},{"title":"mt.dep <span style='color:#111;'> 67B </span>","children":null,"spread":false},{"title":"mt.dep <span style='color:#111;'> 67B </span>","children":null,"spread":false},{"title":"DuiLib_ud.dll <span style='color:#111;'> 1.19MB </span>","children":null,"spread":false},{"title":"DuiLib_ud.dll <span style='color:#111;'> 1.19MB </span>","children":null,"spread":false},{"title":"DuiLib_d.dll <span style='color:#111;'> 1.18MB </span>","children":null,"spread":false},{"title":"DuiLib_d.dll <span style='color:#111;'> 1.18MB </span>","children":null,"spread":false},{"title":"DuiLib_u.dll <span style='color:#111;'> 385.00KB </span>","children":null,"spread":false},{"title":"DuiLib_u.dll <span style='color:#111;'> 385.00KB </span>","children":null,"spread":false},{"title":"DuiLib.dll <span style='color:#111;'> 379.50KB </span>","children":null,"spread":false},{"title":"DuiLib.dll <span style='color:#111;'> 379.50KB </span>","children":null,"spread":false},{"title":"blog_try.exe <span style='color:#111;'> 113.50KB </span>","children":null,"spread":false},{"title":"blog_try.exe <span style='color:#111;'> 98.50KB </span>","children":null,"spread":false},{"title":"spacer.gif <span style='color:#111;'> 43B </span>","children":null,"spread":false},{"title":"UIManager.h <span style='color:#111;'> 12.44KB </span>","children":null,"spread":false},{"title":"UIManager.h <span style='color:#111;'> 12.44KB </span>","children":null,"spread":false},{"title":"UICommonControls.h <span style='color:#111;'> 11.98KB </span>","children":null,"spread":false},{"title":"UICommonControls.h <span style='color:#111;'> 11.98KB </span>","children":null,"spread":false},{"title":"UIList.h <span style='color:#111;'> 11.66KB </span>","children":null,"spread":false},{"title":"UIList.h <span style='color:#111;'> 11.66KB </span>","children":null,"spread":false},{"title":"UIBase.h <span style='color:#111;'> 8.34KB </span>","children":null,"spread":false},{"title":"UIBase.h <span style='color:#111;'> 8.34KB </span>","children":null,"spread":false},{"title":"UIContainer.h <span style='color:#111;'> 6.79KB </span>","children":null,"spread":false},{"title":"UIContainer.h <span style='color:#111;'> 6.79KB </span>","children":null,"spread":false},{"title":"UIControl.h <span style='color:#111;'> 6.03KB </span>","children":null,"spread":false},{"title":"UIControl.h <span style='color:#111;'> 6.03KB </span>","children":null,"spread":false},{"title":"uirichedit.h <span style='color:#111;'> 4.68KB </span>","children":null,"spread":false},{"title":"uirichedit.h <span style='color:#111;'> 4.68KB </span>","children":null,"spread":false},{"title":"UICombo.h <span style='color:#111;'> 3.61KB </span>","children":null,"spread":false},{"title":"UICombo.h <span style='color:#111;'> 3.61KB </span>","children":null,"spread":false},{"title":"UIMarkup.h <span style='color:#111;'> 2.93KB </span>","children":null,"spread":false},{"title":"UIMarkup.h <span style='color:#111;'> 2.93KB </span>","children":null,"spread":false},{"title":"UIRender.h <span style='color:#111;'> 2.26KB </span>","children":null,"spread":false},{"title":"UIRender.h <span style='color:#111;'> 2.26KB </span>","children":null,"spread":false},{"title":"UIDelegate.h <span style='color:#111;'> 2.11KB </span>","children":null,"spread":false},{"title":"UIDelegate.h <span style='color:#111;'> 2.11KB </span>","children":null,"spread":false},{"title":"UIActiveX.h <span style='color:#111;'> 1.75KB </span>","children":null,"spread":false},{"title":"UIActiveX.h <span style='color:#111;'> 1.75KB </span>","children":null,"spread":false},{"title":"IrregularWindow.h <span style='color:#111;'> 1.37KB </span>","children":null,"spread":false},{"title":"UIDlgBuilder.h <span style='color:#111;'> 1.01KB </span>","children":null,"spread":false},{"title":"UIDlgBuilder.h <span style='color:#111;'> 1.01KB </span>","children":null,"spread":false},{"title":"targetver.h <span style='color:#111;'> 1.00KB </span>","children":null,"spread":false},{"title":"targetver.h <span style='color:#111;'> 1.00KB </span>","children":null,"spread":false},{"title":"stdafx.h <span style='color:#111;'> 749B </span>","children":null,"spread":false},{"title":"stdafx.h <span style='color:#111;'> 749B </span>","children":null,"spread":false},{"title":"Resource.h <span style='color:#111;'> 724B </span>","children":null,"spread":false},{"title":"Resource.h <span style='color:#111;'> 724B </span>","children":null,"spread":false},{"title":"UIlib.h <span style='color:#111;'> 640B </span>","children":null,"spread":false},{"title":"UIlib.h <span style='color:#111;'> 640B </span>","children":null,"spread":false},{"title":"blog_try.h <span style='color:#111;'> 628B </span>","children":null,"spread":false},{"title":"blog_try.h <span style='color:#111;'> 564B </span>","children":null,"spread":false},{"title":"BuildLog.htm <span style='color:#111;'> 11.17KB </span>","children":null,"spread":false},{"title":"BuildLog.htm <span style='color:#111;'> 7.28KB </span>","children":null,"spread":false},{"title":"blog_try.ico <span style='color:#111;'> 23.01KB </span>","children":null,"spread":false},{"title":"small.ico <span style='color:#111;'> 23.01KB </span>","children":null,"spread":false},{"title":"blog_try.ico <span style='color:#111;'> 23.01KB </span>","children":null,"spread":false},{"title":"small.ico <span style='color:#111;'> 23.01KB </span>","children":null,"spread":false},{"title":"vc90.idb <span style='color:#111;'> 715.00KB </span>","children":null,"spread":false},{"title":"vc90.idb <span style='color:#111;'> 459.00KB </span>","children":null,"spread":false},{"title":"blog_try.ilk <span style='color:#111;'> 567.86KB </span>","children":null,"spread":false},{"title":"blog_try.ilk <span style='color:#111;'> 404.90KB </span>","children":null,"spread":false},{"title":"DuiLib_ud.lib <span style='color:#111;'> 438.09KB </span>","children":null,"spread":false},{"title":"DuiLib_ud.lib <span style='color:#111;'> 438.09KB </span>","children":null,"spread":false},{"title":"DuiLib_u.lib <span style='color:#111;'> 436.89KB </span>","children":null,"spread":false},{"title":"DuiLib_u.lib <span style='color:#111;'> 436.89KB </span>","children":null,"spread":false},{"title":"DuiLib_d.lib <span style='color:#111;'> 435.72KB </span>","children":null,"spread":false},{"title":"DuiLib_d.lib <span style='color:#111;'> 435.72KB </span>","children":null,"spread":false},{"title":"DuiLib.lib <span style='color:#111;'> 433.19KB </span>","children":null,"spread":false},{"title":"DuiLib.lib <span style='color:#111;'> 433.19KB </span>","children":null,"spread":false},{"title":"blog_try.exe.embed.manifest <span style='color:#111;'> 663B </span>","children":null,"spread":false},{"title":"blog_try.exe.embed.manifest <span style='color:#111;'> 663B </span>","children":null,"spread":false},{"title":"blog_try.exe.intermediate.manifest <span style='color:#111;'> 621B </span>","children":null,"spread":false},{"title":"blog_try.exe.intermediate.manifest <span style='color:#111;'> 621B </span>","children":null,"spread":false},{"title":"blog_try.ncb <span style='color:#111;'> 3.00MB </span>","children":null,"spread":false},{"title":"stdafx.obj <span style='color:#111;'> 187.11KB </span>","children":null,"spread":false},{"title":"stdafx.obj <span style='color:#111;'> 186.79KB </span>","children":null,"spread":false},{"title":"IrregularWindow.obj <span style='color:#111;'> 82.62KB </span>","children":null,"spread":false},{"title":"blog_try.obj <span style='color:#111;'> 49.10KB </span>","children":null,"spread":false},{"title":"blog_try.obj <span style='color:#111;'> 23.14KB </span>","children":null,"spread":false},{"title":"blog_try.pch <span style='color:#111;'> 9.31MB </span>","children":null,"spread":false},{"title":"blog_try.pch <span style='color:#111;'> 9.31MB </span>","children":null,"spread":false},{"title":"blog_try.pdb <span style='color:#111;'> 1.63MB </span>","children":null,"spread":false},{"title":"blog_try.pdb <span style='color:#111;'> 1.29MB </span>","children":null,"spread":false},{"title":"vc90.pdb <span style='color:#111;'> 1.01MB </span>","children":null,"spread":false},{"title":"vc90.pdb <span style='color:#111;'> 772.00KB </span>","children":null,"spread":false},{"title":"bg.png <span style='color:#111;'> 66.65KB </span>","children":null,"spread":false},{"title":"calc1.png <span style='color:#111;'> 41.71KB </span>","children":null,"spread":false},{"title":"Image.png <span style='color:#111;'> 41.04KB </span>","children":null,"spread":false},{"title":"calc_r2_c1.png <span style='color:#111;'> 27.13KB </span>","children":null,"spread":false},{"title":"calc_r1_c1.png <span style='color:#111;'> 14.79KB </span>","children":null,"spread":false},{"title":"calc_r6_c2.png <span style='color:#111;'> 1.96KB </span>","children":null,"spread":false},{"title":"calc_r4_c4.png <span style='color:#111;'> 1.85KB </span>","children":null,"spread":false},{"title":"calc_r10_c4.png <span style='color:#111;'> 1.08KB </span>","children":null,"spread":false},{"title":"calc_r12_c5.png <span style='color:#111;'> 867B </span>","children":null,"spread":false},{"title":"......","children":null,"spread":false},{"title":"<span style='color:steelblue;'>文件过多,未全部展示</span>","children":null,"spread":false}],"spread":true}]

评论信息

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明