对话框大小改变时控件自动改变大小--EASYSIZE
来源:互联网 发布:淘宝兼职名片 编辑:程序博客网 时间:2024/06/07 07:07
Note that all this works exactly the same way with both CDialog and CPropertyPage
1、#include EasySize.h to your stdafx.h (or put it in your include directory and #include <EasySize.h> , which I recommend)
2、Add DECLARE_EASYSIZE anywhere in your class declaration:
class CEasySizeDemoDlg : public CDialog
{
DECLARE_EASYSIZE
BOOL CEasySizeDemoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
...
INIT_EASYSIZE;
return TRUE; // return TRUE unless you set the focus to a control
void CEasySizeDemoDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
UPDATE_EASYSIZE;
void CEasySizeDemoDlg::OnSizing(UINT fwSide, LPRECT pRect)
{
CDialog::OnSizing(fwSide, pRect);
EASYSIZE_MINSIZE(280,250,fwSide,pRect);
}
//(in this example, 280 is the minimum width and 250 the
BEGIN_EASYSIZE_MAP(class_name)
...
EASYSIZE(control,left,top,right,bottom,options)
...
END_EASYSIZE_MAP
The map from the demo application looks like this:
...
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BEGIN_EASYSIZE_MAP(CEasySizeDemoDlg)
EASYSIZE(IDC_TITLE,ES_BORDER,ES_BORDER,
ES_BORDER,ES_KEEPSIZE,ES_HCENTER)
EASYSIZE(IDC_RADIO1,ES_BORDER,ES_BORDER,
ES_KEEPSIZE,ES_KEEPSIZE,0)
EASYSIZE(IDC_RADIO2,ES_BORDER,ES_BORDER,
ES_KEEPSIZE,ES_KEEPSIZE,0)
EASYSIZE(IDC_CONTENT,ES_BORDER,ES_BORDER,
ES_BORDER,ES_BORDER,0)
EASYSIZE(IDC_STATUSFRAME,ES_BORDER,ES_KEEPSIZE,
ES_BORDER,ES_BORDER,0)
EASYSIZE(IDC_STATUS,ES_BORDER,ES_KEEPSIZE,
ES_BORDER,ES_BORDER,0)
EASYSIZE(IDOK,ES_KEEPSIZE,ES_KEEPSIZE,
ES_BORDER,ES_BORDER,0)
EASYSIZE(IDCANCEL,ES_KEEPSIZE,ES_KEEPSIZE,
ES_BORDER,ES_BORDER,0)
EASYSIZE(IDC_MYICON1,ES_BORDER,IDC_RADIO2,IDC_CONTENT,
IDC_STATUSFRAME,ES_HCENTER|ES_VCENTER)
EASYSIZE(IDC_MYICON2,ES_BORDER,ES_BORDER,IDC_TITLE,
ES_KEEPSIZE,ES_HCENTER)
END_EASYSIZE_MAP
///////////////////////////////////////////////////////////////
// CEasySizeDemoDlg message handlers
...
Looks confusing? It's not once you get the point (and I know I'm not good at explaining it) Read on.
1、#include EasySize.h to your stdafx.h (or put it in your include directory and #include <EasySize.h> , which I recommend)
2、Add DECLARE_EASYSIZE anywhere in your class declaration:
class CEasySizeDemoDlg : public CDialog
{
DECLARE_EASYSIZE
...
}
3、Create an OnInitDialog handler if it doesn't already exist, and put this in the end of it: "INIT_EASYSIZE;" :BOOL CEasySizeDemoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
...
INIT_EASYSIZE;
return TRUE; // return TRUE unless you set the focus to a control
}
4、
Create an OnSize handler and add the UPDATE_EASYSIZE; macro to it:void CEasySizeDemoDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
UPDATE_EASYSIZE;
}
5(可选)
Optional - If you want your dialog to have a minimum size, then create an OnSizing handler and add the EASYSIZE_MINSIZE macro as below:void CEasySizeDemoDlg::OnSizing(UINT fwSide, LPRECT pRect)
{
CDialog::OnSizing(fwSide, pRect);
EASYSIZE_MINSIZE(280,250,fwSide,pRect);
}
//(in this example, 280 is the minimum width and 250 the
//minimum height we want our dialog to have)
6 添加消息响应
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
The map from the demo application looks like this:
...
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BEGIN_EASYSIZE_MAP(CEasySizeDemoDlg)
EASYSIZE(IDC_TITLE,ES_BORDER,ES_BORDER,
ES_BORDER,ES_KEEPSIZE,ES_HCENTER)
EASYSIZE(IDC_RADIO1,ES_BORDER,ES_BORDER,
ES_KEEPSIZE,ES_KEEPSIZE,0)
EASYSIZE(IDC_RADIO2,ES_BORDER,ES_BORDER,
ES_KEEPSIZE,ES_KEEPSIZE,0)
EASYSIZE(IDC_CONTENT,ES_BORDER,ES_BORDER,
ES_BORDER,ES_BORDER,0)
EASYSIZE(IDC_STATUSFRAME,ES_BORDER,ES_KEEPSIZE,
ES_BORDER,ES_BORDER,0)
EASYSIZE(IDC_STATUS,ES_BORDER,ES_KEEPSIZE,
ES_BORDER,ES_BORDER,0)
EASYSIZE(IDOK,ES_KEEPSIZE,ES_KEEPSIZE,
ES_BORDER,ES_BORDER,0)
EASYSIZE(IDCANCEL,ES_KEEPSIZE,ES_KEEPSIZE,
ES_BORDER,ES_BORDER,0)
EASYSIZE(IDC_MYICON1,ES_BORDER,IDC_RADIO2,IDC_CONTENT,
IDC_STATUSFRAME,ES_HCENTER|ES_VCENTER)
EASYSIZE(IDC_MYICON2,ES_BORDER,ES_BORDER,IDC_TITLE,
ES_KEEPSIZE,ES_HCENTER)
END_EASYSIZE_MAP
///////////////////////////////////////////////////////////////
// CEasySizeDemoDlg message handlers
...
Looks confusing? It's not once you get the point (and I know I'm not good at explaining it) Read on.
0 0
- 对话框大小改变时控件自动改变大小--EASYSIZE
- EasySize类-----改变窗口中各个控件的大小
- 随对话框大小改变控件大小
- VB自动改变控件大小
- VC 对话框 控件 随对话框大小改变
- 动态改变对话框中控件的大小
- 禁止改变对话框大小
- WTL改变对话框大小
- 对话框控件随界面大小的改变而改变
- MFC控件随对话框大小改变而改变
- MFC 控件随着对话框大小的改变而改变
- 运行时改变控件大小
- 三种随着对话框的大小更新改变控件大小
- 让VB自动改变控件大小
- 一劳永逸让VB自动改变控件大小
- EasySize使用笔记(对话框中的控件随着对话框大小的变化进行自动调整)
- 改变大小控件
- 改变大小控件
- 描述一下JVM加载class文件的原理机制
- 模式识别:利用MATLAB生成模式类
- 泰州电信内部正是由于上述反应不及时的问题
- Linux动态库生成与使用指南
- iOS UI界面之UISlider
- 对话框大小改变时控件自动改变大小--EASYSIZE
- typedef 和指针一点总结
- CodeForces 277A Learning Languages 并查集
- 关于做好2015年度计算机技术与软件专业技术资格(水平)考试有关问题的通知
- 回推示家程嘎铀克号臃野拿凰驶胃
- 例题1.15 网络 UVALive 3902
- 聘凳素叫甘菩矩撑确恫约染弦倒拼
- 澈疑可戮汹突康拓鼓使闹轿宋浪谜
- 亟第医搪葱蹲钟躺复饲磷巢当膳歉