CMFCOutlookBarPane 类
有关详细信息,请参阅所安装的 Visual Studio 的 C\atlmfc\src\mfc 文件夹中的源代码。
从可插入到 Outlook 栏(CMFCOutlookBar 类)的 CMFCToolBar 类派生的控件。 Outlook 栏窗格包含一列大按钮。 如果按钮列表大于窗格,用户可以上下滚动按钮列表。 当用户将 Outlook 栏中的一个窗格与 Outlook 栏分离时,此窗格可以浮动或停靠在主框架窗口中。
语法
class CMFCOutlookBarPane : public CMFCToolBar
成员
公共构造函数
名称 | 描述 |
---|---|
CMFCOutlookBarPane::CMFCOutlookBarPane |
默认构造函数。 |
CMFCOutlookBarPane::~CMFCOutlookBarPane |
析构函数。 |
公共方法
名称 | 描述 |
---|---|
CMFCOutlookBarPane::AddButton | 向 Outlook 栏窗格添加按钮。 |
CMFCOutlookBarPane::CanBeAttached | 确定是否可将窗格停靠到另一个窗格或框架窗口。 (替代 CBasePane::CanBeAttached。) |
CMFCOutlookBarPane::CanBeRestored |
确定系统是否可以在自定义后将工具栏还原到其原始状态。 (替代 CMFCToolBar::CanBeRestored。) |
CMFCOutlookBarPane::ClearAll | 释放 Outlook 栏窗格中图像使用的资源。 |
CMFCOutlookBarPane::Create | 创建 Outlook 栏窗格。 |
CMFCOutlookBarPane::CreateObject |
由框架用于创建此类类型的动态实例。 |
CMFCOutlookBarPane::Dock |
由框架调用来停靠 Outlook 栏窗格。 (替代 CPane::Dock 。) |
CMFCOutlookBarPane::EnablePageScrollMode | 指定 Outlook 栏窗格上的滚动箭头是按页面还是按按钮推进按钮列表。 |
CMFCOutlookBarPane::GetRegularColor | 返回 Outlook 栏窗格的常规(非选定)文本颜色。 |
CMFCOutlookBarPane::GetThisClass |
由框架用于获取指向与此类类型关联的 CRuntimeClass 对象的指针。 |
CMFCOutlookBarPane::IsBackgroundTexture | 确定是否为 Outlook 栏窗格加载了背景图像。 |
CMFCOutlookBarPane::IsChangeState |
确定浮动窗格是否可停靠。 (替代 CPane::IsChangeState 。) |
CMFCOutlookBarPane::IsDrawShadedHighlight | 确定按钮边框在突出显示按钮并显示背景图像时是否带阴影。 |
CMFCOutlookBarPane::OnBeforeFloat |
在窗格即将悬浮时由框架调用。 (替代 CPane::OnBeforeFloat。) |
CMFCOutlookBarPane::RemoveButton | 移除具有指定命令 ID 的按钮。 |
CMFCOutlookBarPane::RestoreOriginalstate |
还原工具栏的原始状态。 (替代 CMFCToolBar::RestoreOriginalState。) |
CMFCOutlookBarPane::SetBackColor | 设置背景色。 |
CMFCOutlookBarPane::SetBackImage | 设置背景图像。 |
CMFCOutlookBarPane::SetDefaultState | 将 Outlook 栏窗格重置为原始按钮集。 |
CMFCOutlookBarPane::SetExtraSpace | 设置 Outlook 栏窗格中按钮周围使用的填充像素数目。 |
CMFCOutlookBarPane::SetTextColor | 设置 Outlook 栏窗格中常规文本和高亮文本的颜色。 |
CMFCOutlookBarPane::SetTransparentColor | 设置 Outlook 栏窗格的透明颜色。 |
CMFCOutlookBarPane::SmartUpdate |
在内部用于更新 Outlook 栏。 (替代 CMFCToolBar::SmartUpdate 。) |
受保护方法
名称 | 描述 |
---|---|
CMFCOutlookBarPane::EnableContextMenuItems | 指定在自定义模式下显示哪些快捷菜单项。 |
CMFCOutlookBarPane::RemoveAllButtons | 从 Outlook 栏窗格中移除所有按钮。 (替代 CMFCToolBar::RemoveAllButtons。) |
注解
若要了解如何实现 Outlook 栏,请参阅 CMFCOutlookBar 类。
有关 Outlook 栏的示例,请参阅 OutlookDemo 示例项目。
示例
下面的示例演示了如何使用 CMFCOutlookBarPane
类的各种方法。 该示例演示如何创建 Outlook 栏窗格、启用页面滚动模式、启用停靠并设置 Outlook 栏的背景色。 此代码片段是 Outlook 多视图示例的一部分。
CMFCOutlookBarPane m_wndShortcutsPane1;
CImageList images;
images.Create(IDB_SHORTCUTS, 32, 0, RGB(255, 0, 255));
// Create first page:
m_wndShortcutsPane1.Create(&m_wndShortcutsBar, AFX_DEFAULT_TOOLBAR_STYLE, ID_SHORTCUTS_PANE_1);
// The this pointer points to a CMainFrame class which extends the CFrameWnd class
m_wndShortcutsPane1.SetOwner(this);
m_wndShortcutsPane1.EnableTextLabels();
m_wndShortcutsPane1.EnableDocking(CBRS_ALIGN_ANY);
m_wndShortcutsPane1.EnablePageScrollMode();
m_wndShortcutsPane1.SetBackColor(RGB(0, 255, 0));
m_wndShortcutsPane1.AddButton(images.ExtractIcon(0), _T("View 1"), ID_SHORTCUT_1);
m_wndShortcutsPane1.AddButton(images.ExtractIcon(1), _T("View 2"), ID_SHORTCUT_2);
m_wndShortcutsPane1.AddButton(images.ExtractIcon(2), _T("View 3"), ID_SHORTCUT_3);
m_wndShortcutsPane1.AddButton(images.ExtractIcon(3), _T("View 4"), ID_SHORTCUT_4);
继承层次结构
要求
标头:afxoutlookbarpane.h
CMFCOutlookBarPane::AddButton
向 Outlook 栏窗格添加按钮。
BOOL AddButton(
UINT uiImage,
LPCTSTR lpszLabel,
UINT iIdCommand,
int iInsertAt=-1);
BOOL AddButton(
UINT uiImage,
UINT uiLabel,
UINT iIdCommand,
int iInsertAt=-1);
BOOL AddButton(
LPCTSTR szBmpFileName,
LPCTSTR szLabel,
UINT iIdCommand,
int iInsertAt=-1);
BOOL AddButton(
HBITMAP hBmp,
LPCTSTR lpszLabel,
UINT iIdCommand,
int iInsertAt=-1);
BOOL AddButton(
HICON hIcon,
LPCTSTR lpszLabel,
UINT iIdCommand,
int iInsertAt=-1,
BOOL bAlphaBlend=FALSE);
参数
uiImage
[in] 指定位图的资源标识符。
lpszLabel
[in] 指定按钮的文本。
iIdCommand
指定按钮控件的 ID。
iInsertAt
[in] 指定 Outlook 栏的页面上基于零的索引,要在该索引处插入按钮。
uiLabel
[in] 字符串资源 ID。
szBmpFileName
[in] 指定要加载的磁盘图像文件的名称。
szLabel
[in] 指定按钮的文本。
hBmp
[in] 指向按钮位图的句柄。
hIcon
[in] 指向按钮图标的句柄。
返回值
如果成功添加了按钮,则为 TRUE;否则为 FALSE。
注解
使用此方法将新按钮插入 Outlook 栏的页面。 可从应用程序资源或磁盘文件加载按钮的图像。
如果 uiPageID 指定的页面 ID 为 -1,则按钮将插入到第一页。
如果 iInsertAt 指定的索引为 -1,则将按钮添加到页面末尾。
CMFCOutlookBarPane::CanBeAttached
有关详细信息,请参阅所安装的 Visual Studio 的 C\atlmfc\src\mfc 文件夹中的源代码。
virtual BOOL CanBeAttached() const;
返回值
备注
CMFCOutlookBarPane::ClearAll
释放 Outlook 栏窗格上图像使用的资源。
void ClearAll();
备注
此方法直接调用 CMFCToolBarImages::Clear,该类是在 Outlook 栏窗格使用的图像上调用的。
CMFCOutlookBarPane::Create
创建 Outlook 栏窗格。
virtual BOOL Create(
CWnd* pParentWnd,
DWORD dwStyle=AFX_DEFAULT_TOOLBAR_STYLE,
UINT uiID=(UINT)-1,
DWORD dwControlBarStyle=0);
参数
pParentWnd
[in] 指定 Outlook 栏窗格控件的父窗口。 不得为 NULL。
dwStyle
[in] 窗口样式。 有关窗口样式的列表,请参阅窗口样式。
uiID
[in] 控件 ID。 必须是唯一的,这样才能保存控件的状态。
dwControlBarStyle
[in] 指定当 Outlook 栏窗格控件与 Outlook 栏分离时定义该控件的行为的特殊样式。
返回值
如果此方法成功,则为 TRUE;否则为 FALSE。
注解
要构造 CMFCOutlookBarPane
对象,请先调用构造函数,然后调用 Create
,这将创建 Outlook 栏窗格钮控件并将其附加到 CMFCOutlookBarPane
对象上。
有关 dwControlBarStyle
的详细信息,请参阅 CBasePane::CreateEx。
CMFCOutlookBarPane::EnableContextMenuItems
指定在自定义模式下显示哪些快捷菜单项。
virtual BOOL EnableContextMenuItems(
CMFCToolBarButton* pButton,
CMenu* pPopup);
参数
pButton
[in] 指向用户单击的工具栏按钮的指针。
pPopup
[in] 指向快捷菜单的指针。
返回值
如果应显示快捷菜单,则返回 TRUE;否则返回 FALSE。
备注
替代此方法来修改框架在自定义模式下显示的框架标准快捷菜单。
默认实现将检查自定义模式 (CMFCToolBar::IsCustomizeMode);如果该模式设置为 TRUE,则禁用除“删除”之外的所有快捷菜单项。 然后,它只需将输入参数传递给 CMFCToolBar::EnableContextMenuItems
。
注意
上下文菜单是快捷菜单的同义词。
CMFCOutlookBarPane::EnablePageScrollMode
指定 Outlook 栏窗格上的滚动箭头逐页面还是逐按钮推进按钮列表。
void EnablePageScrollMode(BOOL bPageScroll=TRUE);
参数
bPageScroll
[in] 如果为 TRUE,请启用页面滚动模式。 如果为 FALSE,请禁用页面滚动模式。
CMFCOutlookBarPane::GetRegularColor
返回 Outlook 栏窗格的常规(即,非选定)文本颜色。
DECLARE_MESSAGE_MAPCOLORREF GetRegularColor() const;
返回值
当前文本颜色(RGB 颜色值)。
备注
使用 CMFCOutlookBarPane::SetTextColor 设置 Outlook 栏的当前(常规和选定)文本颜色。 可使用 COLOR_WINDOW 索引调用 GetSysColor 函数来获取默认文本颜色。
CMFCOutlookBarPane::IsBackgroundTexture
确定是否为 Outlook 栏窗格加载了背景图像。
BOOL IsBackgroundTexture() const;
返回值
如果存在要显示的背景图像,则为 TRUE;否则为 FALSE。
备注
可调用 CMFCOutlookBarPane::SetBackImage 函数来添加背景图像。
如果没有背景图像,则使用 CMFCOutlookBarPane::SetBackColor 指定的颜色绘制背景。
CMFCOutlookBarPane::IsDrawShadedHighlight
确定按钮边框在突出显示按钮并显示背景图像时是否带阴影。
BOOL IsDrawShadedHighlight() const;
返回值
如果按钮的边框带阴影,则为 TRUE;否则为 FALSE。
CMFCOutlookBarPane::RemoveAllButtons
从 Outlook 栏窗格中移除所有按钮。
virtual void RemoveAllButtons();
CMFCOutlookBarPane::RemoveButton
移除具有指定命令 ID 的按钮。
BOOL RemoveButton(UINT iIdCommand);
参数
iIdCommand
[in] 指定要移除的按钮的命令 ID。
返回值
如果已成功移除按钮,则为 TRUE;如果指定的命令 ID 无效,则为 FALSE。
CMFCOutlookBarPane::SetBackColor
设置 Outlook 栏的背景色。
void SetBackColor(COLORREF color);
参数
color
[in] 指定新的背景色。
备注
调用此函数可设置 Outlook 栏的当前背景色。 仅当没有背景图像时,才使用背景色。
CMFCOutlookBarPane::SetBackImage
设置背景图像。
void SetBackImage(UINT uiImageID);
参数
uiImageID
[in] 指定图像资源 ID。
备注
调用此方法可设置 Outlook 栏的背景图像。 背景图像列表由嵌入的 CMFCToolBarImages 类对象管理。
CMFCOutlookBarPane::SetDefaultState
将 Outlook 栏窗格重置为原始按钮集。
void SetDefaultState();
备注
此方法将 Outlook 栏按钮还原到原始集。 此方法与 CMFCOutlookBarPane::RestoreOriginalstate
类似,但不会触发 Outlook 栏窗格的重绘。
CMFCOutlookBarPane::SetExtraSpace
设置 Outlook 栏窗格中按钮周围使用的填充像素数目。
void SetExtraSpace()
CMFCOutlookBarPane::SetTextColor
设置 Outlook 栏窗格中常规文本和高亮文本的颜色。
void SetTextColor(
COLORREF clrRegText,
COLORREF clrSelText=0);
参数
clrRegText
[in] 指定非选定文本的新颜色。
clrSelText
[in] 指定选定文本的新颜色。
CMFCOutlookBarPane::SetTransparentColor
设置 Outlook 栏窗格的透明颜色。
void SetTransparentColor(COLORREF color);
参数
color
[in] 指定新的透明颜色。
备注
需要用透明颜色来显示透明图像。 图像中任何出现此颜色的位置均改用背景色填充。 背景图像和前景图像没混合。
另请参阅
层次结构图
类
CMFCToolBar 类
CMFCOutlookBar 类
CMFCOutlookBarTabCtrl 类