76541572

所属分类:书籍源码
开发工具:Visual C++
文件大小:64KB
下载次数:1
上传日期:2018-02-23 11:42:30
上 传 者tew%2B817912
说明:  动态修改对话框的界面,演示了多种控件,在修改对话框大小时的变化

文件列表:
dlg_resizer.html (4257, 2000-06-28)
72DlgResizeHelper.h (2371, 2000-06-28)
dlg_resizer.h (920, 2000-06-25)
dlg_resizerDlg.h (1235, 2000-06-25)
resource.h (1333, 2000-06-25)
StdAfx.h (545, 2000-06-25)
dlg_resizer.cpp (968, 2000-06-25)
dlg_resizerDlg.cpp (4669, 2003-09-26)
O6DlgResizeHelper.cpp (4032, 2000-06-28)
StdAfx.cpp (46, 2000-06-25)
Ddlg_resizer.aps (21916, 2003-09-26)
dlg_resizer.dsp (4413, 2000-06-26)
dlg_resizer.dsw (573, 2000-06-25)
res\dlg_resizer.ico (1078, 2000-06-28)
dlg_resizer.ncb (66560, 2003-09-26)
dlg_resizer.opt (54784, 2003-09-26)
dlg_resizer.plg (1972, 2003-09-26)
dlg_resizer.rc (6056, 2000-06-25)
res\dlg_resizer.rc2 (404, 2000-06-28)
normal.jpg (31742, 2000-06-28)
resized.jpg (34554, 2000-06-28)
res (0, 2017-10-25)

A DlgResizeHelper object helps you with layouting a dialog or - more generally - a window with child windows. In contrast to other solutions DlgResizeHelper is not derived from CDialog so it can be used with every window. On initialization a DlgResizeHelper stores handles to all child windows of a parent window. On resize it resizes the child windows according to the size changes of the parent. By default a child is resized proportional to the parent size but you can optionally fix the horizontal and/or vertical dimension/position of a sub window. E.g. it's reasonable to fix the height of single line edit controls. Usage (here e.g. with a dialog class): 1. Make your dialog resizable (give it a resizable border) 2. Add a DlgResizeHelper member to your dialog class: #include "DlgResizeHelper.h" class CMyDialog : public CDialog { //... DlgResizeHelper m_resizeHelper; CPoint m_origSize; // this is an optional member which holds the original size for OnGetMinMaxInfo() //... }; 3. Initialize the resize helper in OnInitDialog(): BOOL CMyDialog::OnInitDialog() { //... m_resizeHelper.Init(m_hWnd); // default behaviour is to resize sub windows proportional to the resize of the parent // you can fix horizontal and/or vertical dimensions for some sub windows by either specifying the sub window by // * its hwnd: m_resizeHelper.Fix(m_buttonCtrl, DlgResizeHelper::kLeft, DlgResizeHelper::kNoVFix); // * its item id: m_resizeHelper.Fix(IDC_PRESS_ME, DlgResizeHelper::kWidth, DlgResizeHelper::kNoVFix); // * or all sub windows with a common class name (especially useful for single line edit controls) m_resizeHelper.Fix("Edit", DlgResizeHelper::kNoHFix, DlgResizeHelper::kHeight); // initialize the optional origSize member CRect rect; GetWindowRect(rect); m_origSize = CPoint(rect.Width(), rect.Height()); //... } 4. Tell the resize helper when the size has changed: void CMyDialog::OnSize(UINT nType, int cx, int cy) { CDialog::OnSize(nType, cx, cy); m_resizeHelper.OnSize(); } (5. optionally: enforce minimal dialog size) void CDlg_resizerDlg::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI ) { lpMMI->ptMinTrackSize = m_origSize; } The sample application is a dialog with a bunch of buttons. The name of the buttons reveals their fixed dimensions.

近期下载者

相关文件


收藏者