首页 > 其他分享 >Sizing Framework

Sizing Framework

时间:2022-12-13 14:24:36浏览次数:56  
标签:Sizing WRCT dialog ENDGROUP Framework RCTOFIT CTestDlg IDC

Sizing Framework

Sample Image - sizingframework.jpg

Introduction

The WTL possibilities to build sizeable graphical user interface exists but was not fitting my needs so I decided to port the excellent framework from Paul DiLascia 'Windows UI: Our WinMgr Sample Makes Custom Window Sizing Simple' published in the July 2001 issue of MSDN Magazine. To understand all the principle of the framework, please read the original article.

The port was almost straightforward. I just added the gripper to the dialog.

Usage

To use the framework you need first to add those files to your project:
  • WinMgr.h
  • WinMgr.cpp
  • WinRect.cpp
  • SizeableDlg.h
Your dialog needs then to inherit from the class CDialogSizeable like this:  
class CTestDlg :
    public CDialogSizeable<CTestDlg>,
    public CDialogImpl<CTestDlg>
In the OnInitDialog() event handler, add as first line the following:  
LRESULT CTestDlg::OnInitDialog( HWND hwnd, LPARAM  lParam)
{
    BOOL bRet = CDialogSizeable<CTestDlg>::OnInitDialog( hwnd, lParam );
    ...
}
Add the following macro to your main message map:  
BEGIN_MSG_MAP_EX(CTestDlg)
    ...
    MESSAGE_HANDLER_EX(WM_WINMGR, OnWinMgr)
    ...
END_MSG_MAP()
And the the method to your dialog class (get more information on the original article):  
///////////////////
// Handle WM_WINMGR: return min size for OK/Cancel buttons
//
LRESULT CTestDlg::OnWinMgr(UINT uMsg, WPARAM wp, LPARAM lp)
{
    ATLASSERT(lp);
    NMWINMGR& nmw = *(NMWINMGR*)lp;

    if ( nmw.code == NMWINMGR::GET_SIZEINFO )
    {
        if ( wp==IDOK || wp==IDCANCEL )
        {
            nmw.sizeinfo.szMin = m_szMinButton;
            return TRUE;
        }
    }
    return 0;
}
Build the Window map in the cpp file of your dialog class, i.e.:  
BEGIN_WINDOW_MAP(TestDlgMap)
BEGINROWS(WRCT_REST,0,RCMARGINS(8,8))
 BEGINCOLS(WRCT_REST,0,0)
  BEGINROWS(WRCT_REST,4,RCMARGINS(-4,-4))
   RCTOFIT(IDC_STATIC1)
   RCSPACE(-4)
    BEGINROWS(WRCT_TOFIT,IDC_GROUP1,RCMARGINS(-8,-8))
     RCSPACE(-10)
    RCTOFIT(IDC_RADIO1)
    RCTOFIT(IDC_RADIO2)
    ENDGROUP()
  ENDGROUP()
  RCPERCENT(IDC_EDIT1,50)
 ENDGROUP()
 RCSPACE(-4)
 RCTOFIT(IDC_STATIC2)
 RCTOFIT(IDC_SLIDER1)
 BEGINCOLS(WRCT_TOFIT,0,0)
  RCREST(-1)
  BEGINROWS(WRCT_TOFIT,0,0)
    RCTOFIT(IDOK)
    RCSPACE(-2)
    RCTOFIT(IDCANCEL)
  ENDGROUP()
 ENDGROUP()
ENDGROUP()
END_WINDOW_MAP()
Add finally the following to the constructor of your dialog:  
CTestDlg::CTestDlg( ) :
    CDialogSizeable<CTestDlg>( TestDlgMap )
{
    ...
Now enjoy your sizing dialog.

Faced Problems

标签:Sizing,WRCT,dialog,ENDGROUP,Framework,RCTOFIT,CTestDlg,IDC
From: https://www.cnblogs.com/qzxff/p/16978628.html

相关文章

  • DPDK — IGB_UIO,与 UIO Framework 进行交互的内核模块[转载]
    转自:https://blog.51cto.com/u_15301988/5181173目录文章目录目录前文列表IGB_UIOIGB_UIO是如何注册PCI设备的?Linux中的PCI设备PCI的BAR(基地址)IGB_UIO如何获得......
  • RobotFramework学习笔记:Robot Framework和BrowserLibrary(PlayWright)简介
    1为什么要开始写这个? 大家如果在测试学习交流群的话,就应该能感受到群里满满的学习氛围,近期呢,群里有一位大佬利用自己空闲的时间,准备录制一系列的自动化学习视频,目前会主要......
  • 使用 .NET 升级助手将.NET Framework应用迁移到.NET 5
    从.NETFramework迁移到.NET5犹如搬家,我们都知道搬家是很痛苦的,我们请求搬家公司来减轻我们的压力,​​.NET升级助手​​​.NET升级助手是一个全局命令行工具,可以指导你......
  • django-rest framework
    目录(1)Web应用模式及API接口(2)Restful规范(3)drf安装和简单使用(4)源码分析(5)序列化器-Serializer(6)局部和全局响应配置(7)视图(8)路由-Routers(9)认证-Authentication(10)权......
  • robotframework中导入selenium执行脚本后显示'WebDriver' object has no attribute 'f
    robotframework中导入selenium执行脚本后显示'WebDriver'objecthasnoattribute'find_elements_by_id',经检查是selenium版本导致,版本selenium4不支持find_elements_by_......
  • paozhu c++ web framework 框架原理
    paozhuc++webframework框架原理paozhuc++webframework使用asio网络库,如果用动态库方式还要boost库。paozhu框架使用两个线程池,一个是框架使用的解析协议,连接......
  • Linux Regulator Framework(2)_regulator driver
    1.前言本文从regulatordriver的角度,描述怎样基于regulatorframework编写regulator驱动。同时,以此为契机,学习、理解regulator有关的物理特性,以便能够更好的使用它们。2......
  • Linux Regulator Framework(1)_概述
    1.前言Regulator,中文名翻译为“稳定器”,在电子工程中,是voltageregulator(稳压器)或者currentregulator(稳流器)的简称,指可以自动维持恒定电压(或电流)的装置。voltageregul......
  • Entity Framework Core 笔记 - 入门
    先决条件请确保安装了.NETCore第6或7版本,我这安装的是7.   一.领域建模方式1.CodeFirstPOCO:PlainOldCLRObject。内在含义是指那些没有从任何类继承......
  • framework 用 jexus 也能跑 k8s
     Jexus以支持ASP.NET、Core、php在Linux上运行为特色,能够支持ASP.NET的原理,就是在Linux上安装了Mono(跨平台.NET运行环境),进而支持ASP.NET程序的运行。官网:JexusWebServer......