c++ - 删除 CPropertySheet/Tabbed Dialog 页面下方的间隙

标签 c++ layout mfc tabbed-interface cpropertysheet

我有一个 CPropertySheet,我用它来显示三个 CPropertyPage。我删除了默认的“应用”和“帮助”按钮。我的问题来了,现在它们被移除了,我在它们曾经所在的位置有一个很大的差距。有没有办法消除这个差距?谢谢!

这是我所说的差距的图片: Gap

在移除按钮之前,它们位于间隙的右侧。请注意,“更改选项”页面是在 Visual Studio 的设计器中创建的,该页面在“打印”按钮的正下方结束。主要的管理选项 CPropertySheet 完全由代码创建。 下面是初始化 CPropertySheet 和页面的代码(以及删除“帮助”和“应用”按钮:

BEGIN_MESSAGE_MAP(CSLIMOptCplusplusApp, CWinApp)
//ON_COMMAND(ID_HELP, &CWinApp::OnHelp) Commented out to remove the "Help" button
END_MESSAGE_MAP()

BOOL OptCplusplusApp::InitInstance()
{
CWinApp::InitInstance();
SQLHENV m_1;
EnvGetHandle(m_1);

Login lgn;   //Creates a Login dialog for the user to enter credentials.
lgn.DoModal();

CImageSheet*      imagedlg = new CImageSheet( "SLIM Admin Options" );
CImageDisplay*    pageImageDisplay    = new CImageDisplay;
CImageDimensions* pageImageDimensions = new CImageDimensions;
ListOption*       pageListOption      = new ListOption;

ASSERT( imagedlg );
ASSERT( pageImageDisplay );
ASSERT( pageImageDimensions );  
ASSERT( pageListOption );

imagedlg->AddPage( pageListOption);
imagedlg->AddPage( pageImageDisplay );
imagedlg->AddPage( pageImageDimensions );

imagedlg->m_psh.dwFlags |= PSH_NOAPPLYNOW;  //Removes the default Apply button
imagedlg->Create();
imagedlg->ShowWindow( SW_SHOW );
m_pMainWnd = imagedlg;

如果需要更多详细信息,我会进行编辑。谢谢。

最佳答案

用属性表实现这种外观....

enter image description here

您需要在工作表中处理 OnitDialog 并重新调整其大小。例如,使用 CPropertySheet::GetPage 的组合和 CWnd::MoveWindow将完成您想要的。

BOOL MyPropSheet::OnInitDialog()
    {
    BOOL bResult = CPropertySheet::OnInitDialog();

    // TODO:  Add your specialized code here
    CPropertyPage* pg1 = GetPage(0);
    CRect rect(0, 0, 0, 0);

    pg1->GetWindowRect(&rect);

    CRect thisRect(0, 0, 0, 0);
    GetWindowRect(&thisRect);

    thisRect.bottom = rect.bottom + 16;
    MoveWindow(&thisRect);
return bResult;
}

关于c++ - 删除 CPropertySheet/Tabbed Dialog 页面下方的间隙,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29040239/

相关文章:

java - JComponent 的运行时对齐 + 链接到 RowFilters

c++ - 找到一个在安全事件后终止的进程

c++ - 用户定义类型的 std::common_type 特征

派生类实例化的 C++ 语法异常

java - 当未选中可调整大小时,Netbeans null 布局会导致背景周围出现边框

c++ - 备份和恢复所有注册表

c++ - 如果使用 'Visual Studio 2017 (v141)' 平台工具集构建应用程序,CCheckListBox 项目会在选择时重叠

c++ - C/C++ 如何知道如何针对正确的体系结构进行编译?

c++ - “ULONG_MAX”未在此范围内声明

html - 内部 div 100% 高度在具有最小高度的 div 内不起作用