IUIApplication::OnViewChanged 方法 (uiribbon.h)
在 视图 的状态更改时调用。
语法
HRESULT OnViewChanged(
[in] UINT32 viewId,
[in] UI_VIEWTYPE typeID,
[in] IUnknown *view,
[in] UI_VIEWVERB verb,
[in] INT32 uReasonCode
);
参数
[in] viewId
类型: UINT32
视图的 ID。 只有值 0 有效。
[in] typeID
类型: UI_VIEWTYPE
应用程序托管 的UI_VIEWTYPE 。
[in] view
类型: IUnknown*
指向视图接口的指针。
[in] verb
类型: UI_VIEWVERB
视图 ) 执行的 UI_VIEWVERB (或操作。
[in] uReasonCode
类型: INT32
未定义。
返回值
类型: HRESULT
如果该方法成功,则返回 S_OK。 否则,将返回 HRESULT 错误代码。
注解
每次视图状态更改时,框架都会将此回调通知发送到主机应用程序。
重要此回调仅适用于 viewId 为 0 的功能区视图。
示例
以下示例演示 IUIApplication::OnViewChanged 方法的基本实现。
//
// FUNCTION: OnViewChanged(UINT, UI_VIEWTYPE, IUnknown*, UI_VIEWVERB, INT)
//
// PURPOSE: Called when the state of a View (Ribbon is a view) changes - like created/destroyed/resized.
//
// PARAMETERS:
// viewId - The View identifier.
// typeID - The View type.
// pView - Pointer to the View interface.
// verb - The action performed by the View.
// uReasonCode - Not defined.
//
// COMMENTS:
//
// For this sample, return the same command handler for all commands
// specified in the .xml file.
//
//
STDMETHODIMP CApplication::OnViewChanged(
UINT viewId,
UI_VIEWTYPE typeId,
IUnknown* pView,
UI_VIEWVERB verb,
INT uReasonCode)
{
HRESULT hr = E_NOTIMPL;
// Checks to see if the view that was changed was a Ribbon view.
if (UI_VIEWTYPE_RIBBON == typeId)
{
switch (verb)
{
// The view was newly created.
case UI_VIEWVERB_CREATE:
_cwprintf(L"IUIApplication::OnViewChanged called with verb=CREATE\r\n");
if (NULL == g_pRibbon)
{
// Retrieve and store the IUIRibbon
hr = pView->QueryInterface(&g_pRibbon);
}
break;
// The view was resized.
// In the case of the Ribbon view, the application should call
// GetHeight() to determine the height of the Ribbon.
case UI_VIEWVERB_SIZE:
_cwprintf(L"IUIApplication::OnViewChanged called with verb=SIZE\r\n");
// Call to the framework to determine the height of the Ribbon.
if (NULL != g_pRibbon)
{
UINT uRibbonHeight;
hr = g_pRibbon->GetHeight(&uRibbonHeight);
}
if (!SUCCEEDED(hr))
{
//_cwprintf(L"IUIRibbon::GetHeight() failed with hr=0x%X\r\n", hr);
}
break;
// The view was destroyed.
case UI_VIEWVERB_DESTROY:
//_cwprintf(L"IUIApplication::OnViewChanged called with verb=DESTROY\r\n");
g_pRibbon = NULL;
hr = S_OK;
break;
}
}
return hr;
}
要求
最低受支持的客户端 | Windows 7 [仅限桌面应用] |
最低受支持的服务器 | Windows Server 2008 R2 [仅限桌面应用] |
目标平台 | Windows |
标头 | uiribbon.h |
DLL | Mshtml.dll |