1 Star 0 Fork 1

nkjpj/PaintPlus-1

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CommandHandler.cpp 2.84 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 <UIRibbon.h>
#include "CommandHandler.h"
#include "RibbonIDs.h"
#include "RibbonFramework.h"
// Static method to create an instance of the object.
HRESULT CCommandHandler::CreateInstance(IUICommandHandler **ppCommandHandler)
{
if (!ppCommandHandler)
{
return E_POINTER;
}
*ppCommandHandler = NULL;
HRESULT hr = S_OK;
CCommandHandler* pCommandHandler = new CCommandHandler();
if (pCommandHandler != NULL)
{
*ppCommandHandler = static_cast<IUICommandHandler *>(pCommandHandler);
}
else
{
hr = E_OUTOFMEMORY;
}
return hr;
}
// IUnknown method implementations.
STDMETHODIMP_(ULONG) CCommandHandler::AddRef()
{
return InterlockedIncrement(&m_cRef);
}
STDMETHODIMP_(ULONG) CCommandHandler::Release()
{
LONG cRef = InterlockedDecrement(&m_cRef);
if (cRef == 0)
{
delete this;
}
return cRef;
}
STDMETHODIMP CCommandHandler::QueryInterface(REFIID iid, void** ppv)
{
if (iid == __uuidof(IUnknown))
{
*ppv = static_cast<IUnknown*>(this);
}
else if (iid == __uuidof(IUICommandHandler))
{
*ppv = static_cast<IUICommandHandler*>(this);
}
else
{
*ppv = NULL;
return E_NOINTERFACE;
}
AddRef();
return S_OK;
}
//
// FUNCTION: UpdateProperty()
//
// PURPOSE: Called by the Ribbon framework when a command property (PKEY) needs to be updated.
//
// COMMENTS:
//
// This function is used to provide new command property values, such as labels, icons, or
// tooltip information, when requested by the Ribbon framework.
//
// In this SimpleRibbon sample, the method is not implemented.
//
STDMETHODIMP CCommandHandler::UpdateProperty(
UINT nCmdID,
REFPROPERTYKEY key,
const PROPVARIANT* ppropvarCurrentValue,
PROPVARIANT* ppropvarNewValue)
{
UNREFERENCED_PARAMETER(nCmdID);
UNREFERENCED_PARAMETER(key);
UNREFERENCED_PARAMETER(ppropvarCurrentValue);
UNREFERENCED_PARAMETER(ppropvarNewValue);
return E_NOTIMPL;
}
//
// FUNCTION: Execute()
//
// PURPOSE: Called by the Ribbon framework when a command is executed by the user. For example, when
// a button is pressed.
//
extern int type;
#define LINE 2000
#define ELLIPSE 2001
#define RETANGLE 2002
STDMETHODIMP CCommandHandler::Execute(
UINT nCmdID,
UI_EXECUTIONVERB verb,
const PROPERTYKEY* key,
const PROPVARIANT* ppropvarValue,
IUISimplePropertySet* pCommandExecutionProperties)
{
UNREFERENCED_PARAMETER(pCommandExecutionProperties);
UNREFERENCED_PARAMETER(ppropvarValue);
UNREFERENCED_PARAMETER(key);
UNREFERENCED_PARAMETER(verb);
UNREFERENCED_PARAMETER(nCmdID);
SendMessage(GetForegroundWindow(), WM_COMMAND, nCmdID, NULL);
return S_OK;
}
马建仓 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