📄 iconhandler.cpp
字号:
// IconHandler.cpp : implementation file
//
#include "stdafx.h"
#include "AlIcon.h"
#include "winnetwk.h"
#include "shlobj.h"
#include "winnls.h"
#include "IconHandler.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CIconHandler
IMPLEMENT_DYNCREATE(CIconHandler, CCmdTarget)
CIconHandler::CIconHandler()
{
}
CIconHandler::~CIconHandler()
{
}
BEGIN_MESSAGE_MAP(CIconHandler, CCmdTarget)
//{{AFX_MSG_MAP(CIconHandler)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// Note: we add support for IID_IIconHandler to support typesafe binding
// from VBA. This IID must match the GUID that is attached to the
// dispinterface in the .ODL file.
// {A7C5953F-411B-11CF-A7B2-444553540000}
static const IID IID_IIconHandler =
{ 0xa7c5953f, 0x411b, 0x11cf, { 0xa7, 0xb2, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } };
IMPLEMENT_OLECREATE(CIconHandler,"AlIconHandler",0xa7c5953f,0x411b,0x11cf,0xa7,0xb2,0x44,0x45,0x53,0x54,0,0);
BEGIN_INTERFACE_MAP(CIconHandler, CCmdTarget)
INTERFACE_PART(CIconHandler, IID_IPersistFile, PersistFile)
INTERFACE_PART(CIconHandler, IID_IExtractIcon, Icon)
END_INTERFACE_MAP()
STDMETHODIMP_(ULONG) CIconHandler::XPersistFile::AddRef()
{
METHOD_PROLOGUE(CIconHandler,PersistFile)
return pThis->ExternalAddRef();
}
STDMETHODIMP_(ULONG) CIconHandler::XPersistFile::Release()
{
METHOD_PROLOGUE(CIconHandler,PersistFile)
return pThis->ExternalRelease();
}
STDMETHODIMP CIconHandler::XPersistFile::QueryInterface(REFIID iid,void FAR * FAR *pObj)
{
METHOD_PROLOGUE(CIconHandler,PersistFile)
return (HRESULT)pThis->ExternalQueryInterface(&iid,pObj);
}
STDMETHODIMP CIconHandler::XPersistFile::IsDirty()
{
return E_NOTIMPL;
}
STDMETHODIMP CIconHandler::XPersistFile::Load(LPCOLESTR pszFileName,DWORD)
{
METHOD_PROLOGUE(CIconHandler,PersistFile);
WideCharToMultiByte(CP_ACP,0,(LPCWSTR)pszFileName,-1,
pThis->m_szFile,sizeof(pThis->m_szFile),
NULL,NULL);
return NOERROR;
}
STDMETHODIMP CIconHandler::XPersistFile::Save(LPCOLESTR,BOOL)
{
return E_NOTIMPL;
}
STDMETHODIMP CIconHandler::XPersistFile::SaveCompleted(LPCOLESTR)
{
return E_NOTIMPL;
}
STDMETHODIMP CIconHandler::XPersistFile::GetCurFile(LPOLESTR FAR *)
{
return E_NOTIMPL;
}
STDMETHODIMP CIconHandler::XPersistFile::GetClassID(LPCLSID)
{
return E_NOTIMPL;
}
STDMETHODIMP_(ULONG) CIconHandler::XIcon::AddRef()
{
METHOD_PROLOGUE(CIconHandler,Icon)
return pThis->ExternalAddRef();
}
STDMETHODIMP_(ULONG) CIconHandler::XIcon::Release()
{
METHOD_PROLOGUE(CIconHandler,Icon)
return pThis->ExternalRelease();
}
STDMETHODIMP CIconHandler::XIcon::QueryInterface(REFIID iid,void FAR * FAR *pObj)
{
METHOD_PROLOGUE(CIconHandler,Icon)
return (HRESULT)pThis->ExternalQueryInterface(&iid,pObj);
}
STDMETHODIMP CIconHandler::XIcon::GetIconLocation(UINT uFlags,LPSTR szIconFile,
UINT cchMax,int *piIndex,
UINT *pwFlags)
{
METHOD_PROLOGUE(CIconHandler,Icon);
//TODO: Supply icon file & index here -- if you need the file name use pThis->m_szFile
// OR return S_FALSE and supply an HICON below
::GetModuleFileName(AfxGetInstanceHandle(),szIconFile,cchMax);
*piIndex=0;
*pwFlags|=GIL_PERINSTANCE;
return S_OK;
}
STDMETHODIMP CIconHandler::XIcon::Extract(LPCSTR,UINT,HICON *,HICON *,UINT)
{
METHOD_PROLOGUE(CIconHandler,Icon);
//TODO: Supply HICON here -- if you need the file name use pThis->m_szFile
// OR return S_FALSE and provide an icon file (see above)
return S_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// CIconHandler message handlers
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -