Share via


CDialogBar 类

提供控件条中的 Windows 无模式对话框功能。

语法

class CDialogBar : public CControlBar

成员

公共构造函数

名称 描述
CDialogBar::CDialogBar 构造 CDialogBar 对象。

公共方法

名称 描述
CDialogBar::Create 创建一个 Windows 对话栏并将其附加到 CDialogBar 对象。

备注

对话栏与对话框类似,包含用户可以在其中点选的标准 Windows 控件。 另一种相似之处在于要创建对话框模板来表示对话框栏。

创建和使用对话框栏类似于创建和使用 CFormView 对象。 首先,使用对话框编辑器定义具有样式 WS_CHILD 且没有其他样式的对话框模板。 模板不得具有样式 WS_VISIBLE。 在应用程序代码中,调用构造函数以构造 CDialogBar 对象,然后调用 Create 以创建对话栏窗口,并将其附加到 CDialogBar 对象。

若要详细了解 CDialogBar,请参阅文章对话栏以及技术说明 31:控制栏

注意

在当前版本中,CDialogBar 对象不能承载 Windows 窗体控件。 若要详细了解 Visual C++ 中的 Windows 窗体控件,请参阅在 MFC 中使用 Windows 窗体用户控件

继承层次结构

CObject

CCmdTarget

CWnd

CControlBar

CDialogBar

要求

标头:afxext.h

CDialogBar::CDialogBar

构造 CDialogBar 对象。

CDialogBar();

CDialogBar::Create

加载通过 lpszTemplateNamenIDTemplate 指定的对话框资源模板,创建对话栏窗口、设置其样式并将其与 CDialogBar 对象关联。

virtual BOOL Create(
    CWnd* pParentWnd,
    LPCTSTR lpszTemplateName,
    UINT nStyle,
    UINT nID);

virtual BOOL Create(
    CWnd* pParentWnd,
    UINT nIDTemplate,
    UINT nStyle,
    UINT nID);

参数

pParentWnd
指向父 CWnd 对象的指针。

lpszTemplateName
指向 CDialogBar 对象的对话框资源模板名称的指针。

nStyle
工具栏样式。 支持的其他工具栏样式包括:

  • CBRS_TOP 控件条位于框架窗口顶部。

  • CBRS_BOTTOM 控件条位于框架窗口底部。

  • CBRS_NOALIGN 控件条在父级调整大小时不会重新定位。

  • CBRS_TOOLTIPS 控件条显示工具提示。

  • CBRS_SIZE_DYNAMIC 控件条是动态的。

  • CBRS_SIZE_FIXED 控件条是固定的。

  • CBRS_FLOATING 控件条是浮动的。

  • CBRS_FLYBY 状态栏显示有关按钮的信息。

  • CBRS_HIDE_INPLACE 控件条未向用户显示。

nID
对话栏的控件 ID。

nIDTemplate
CDialogBar 对象的对话框模板的资源 ID。

返回值

如果成功,则不为 0;否则为 0。

备注

如果指定 CBRS_TOP 或 CBRS_BOTTOM 对齐样式,对话栏的宽度是框架窗口的宽度,高度是 nIDTemplate 指定的资源高度。 如果指定 CBRS_LEFT 或 CBRS_RIGHT 对齐样式,对话栏的高度是框架窗口的高度,宽度是 nIDTemplate 指定的资源宽度

示例

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
   if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
      return -1;

   EnableDocking(CBRS_ALIGN_ANY);

   // m_wndDlgBar is a CDialogBar member of CMainFrame
   // IDD_DIALOGBAR - Resource ID of the dialog
   // template. This dialog template should be created
   // with  the  style  WS_CHILD and no other style.
   // The template must not have the style WS_VISIBLE.
   if (!m_wndDlgBar.Create(this, IDD_DIALOGBAR,
                           CBRS_LEFT | CBRS_TOOLTIPS | CBRS_FLYBY, IDD_DIALOGBAR))
   {
      TRACE0("Failed to create DlgBar\n");
      return -1; // Fail to create.
   }

   return 0;
}

另请参阅

MFC 示例 CTRLBARS
CControlBar Class
层次结构图
CFormView 类
CControlBar Class