1 Star 0 Fork 1

nkjpj/PaintPlus-1

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
RibbonFramework.cpp 2.72 KB
一键复制 编辑 原始数据 按行查看 历史
ngtritham 提交于 2017-12-06 23:09 . Initial commit
// 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;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/nkjpj/PaintPlus-1.git
git@gitee.com:nkjpj/PaintPlus-1.git
nkjpj
PaintPlus-1
PaintPlus-1
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385