当前位置 博文首页 > 启舰:放大对话框时,改变按钮的位置(EasySize.h使用方法)

    启舰:放大对话框时,改变按钮的位置(EasySize.h使用方法)

    作者:[db:作者] 时间:2021-06-12 15:37

    设创建的对话框的类名是CMyDlg,具体过程如下:

    步骤一:把easysize.h拷贝到CMyDlg项目文件夹中,同时在CMyDlg.h文件和.cpp文件中加入#include "easysize.h"

    步骤二:在CMyDlgh文件中,加入DECLARE_EASYSIZE,注意结尾处不要加

    class CMyDlg : public CDialog
    
    {
    
          DECLARE_EASYSIZE
    
    // Construction
    
    …
    
    }

    步骤三:在CMyDlg类的OnInitDialog()函数的结尾处加入INIT_EASYSIZE,注意此处结尾处要加

    BOOL CMyDlg::OnInitDialog()
    
    {     …
    
    // TODO: Add extra initialization here
    
          INIT_EASYSIZE;
    
           returnTRUE;  // return TRUE  unless you set the focus to a control
    
    }?

    步骤四:增加WM_SIZE消息响应函数OnSize(),在函数中加入UPDATE_EASYSIZE,注意此处结尾处要加

    void CMyDlg::OnSize(UINT nType, int cx, int cy)
    
    {
    
          CDialog::OnSize(nType, cx, cy);
    
           // TODO:Add your message handler code here
    
          UPDATE_EASYSIZE;
    
    }
    

    步骤五:在CMyDlgcpp文件中添加EASYSIZE的宏映射

    BEGIN_EASYSIZE_MAP(CMyDlg)
    
    EASYSIZE(control,left,top,right,bottom,options)
    
    END_EASYSIZE_MAP
    

    注意:如果没有添加EASYSIZE的宏映射就开始编译的话,会出现链接错误!

    补充:原文解释如下:

    1. Now you have to create the "EasySize Map" (or whatever you want to call it) in which you will specify the behavior of each dialog item. It can be placed anywhere inside your class implementation. The map looks like this:

    BEGIN_EASYSIZE_MAP(class_name)

    ???...

    ???EASYSIZE(control,left,top,right,bottom,options)

    ???...

    END_EASYSIZE_MAP

    下一篇:没有了