代码拉取完成,页面将自动刷新
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
#include "stdafx.h"
#include "RibbonFramework.h"
#include "Application.h"
IUIFramework *g_pFramework = NULL; // Reference to the Ribbon framework.
IUIApplication *g_pApplication = NULL; // Reference to the Application object.
//
// FUNCTION: InitializeFramework(HWND)
//
// PURPOSE: Initialize the Ribbon framework and bind a Ribbon to the application.
//
// COMMENTS:
//
// To get a Ribbon to display, the Ribbon framework must be initialized.
// This involves three important steps:
// 1) Instantiating the Ribbon framework object (CLSID_UIRibbonFramework).
// 2) Passing the host HWND and IUIApplication object to the framework.
// 3) Loading the binary markup compiled by UICC.exe.
//
//
bool InitializeFramework(HWND hWnd)
{
// Here we instantiate the Ribbon framework object.
HRESULT hr = CoCreateInstance(CLSID_UIRibbonFramework, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&g_pFramework));
if (FAILED(hr))
{
return false;
}
// Next, we create the application object (IUIApplication) and call the framework Initialize method,
// passing the application object and the host HWND that the Ribbon will attach itself to.
hr = CApplication::CreateInstance(&g_pApplication);
if (FAILED(hr))
{
return false;
}
hr = g_pFramework->Initialize(hWnd, g_pApplication);
if (FAILED(hr))
{
return false;
}
// Finally, we load the binary markup. This will initiate callbacks to the IUIApplication object
// that was provided to the framework earlier, allowing command handlers to be bound to individual
// commands.
hr = g_pFramework->LoadUI(GetModuleHandle(NULL), L"APPLICATION_RIBBON");
if (FAILED(hr))
{
return false;
}
return true;
}
//
// FUNCTION: DestroyFramework()
//
// PURPOSE: Tears down the Ribbon framework.
//
//
void DestroyFramework()
{
if (g_pFramework)
{
g_pFramework->Destroy();
g_pFramework->Release();
g_pFramework = NULL;
}
if (g_pApplication)
{
g_pApplication->Release();
g_pApplication = NULL;
}
}
unsigned int GetRibbonHeight()
{
unsigned int ribbonHeight = 0;
if (g_pFramework)
{
IUIRibbon* ribbon = NULL;
HRESULT hr = g_pFramework->GetView(0, IID_PPV_ARGS(&ribbon));
if (SUCCEEDED(hr))
{
hr = ribbon->GetHeight(&ribbonHeight);
ribbon->Release();
if (FAILED(hr))
{
ribbonHeight = 0;
}
}
}
return ribbonHeight;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。