📄 addin.cpp
字号:
////////////////////////////////////////////////////////////////////////////
// Copyright : Amit Dey 2002
//
// Email :amitdey@joymail.com
//
// This code may be used in compiled form in any way you desire. This
// file may be redistributed unmodified by any means PROVIDING it is
// not sold for profit without the authors written consent, and
// providing that this notice and the authors name is included.
//
// This file is provided 'as is' with no expressed or implied warranty.
// The author accepts no liability if it causes any damage to your computer.
//
// Do expect bugs.
// Please let me know of any bugs/mods/improvements.
// and I will try to fix/incorporate them into this file.
// Enjoy!
//
// Description : Outlook2K Addin
////////////////////////////////////////////////////////////////////////////
// Addin.cpp : Implementation of CAddin
#include "stdafx.h"
#include "OutlookAddin.h"
#include "Addin.h"
#include "GetStartUIExp.h"
/////////////////////////////////////////////////////////////////////////////
// CAddin
_ATL_FUNC_INFO OnClickButtonInfo ={CC_STDCALL,VT_EMPTY,2,{VT_DISPATCH,VT_BYREF | VT_BOOL}};
_ATL_FUNC_INFO OnOptionsAddPagesInfo={CC_STDCALL,VT_EMPTY,1,{VT_DISPATCH}};
STDMETHODIMP CAddin::InterfaceSupportsErrorInfo(REFIID riid)
{
static const IID* arr[] =
{
&IID_IAddin
};
for (int i=0; i < sizeof(arr) / sizeof(arr[0]); i++)
{
if (::InlineIsEqualGUID(*arr[i],riid))
return S_OK;
}
return S_FALSE;
}
//__declspec(dllimport) DWORD ShowUI(DWORD dwFlag);
void __stdcall CAddin::OnClickButton(IDispatch* /*Office::_CommandBarButton* */ Ctrl,VARIANT_BOOL * CancelDefault)
{
USES_CONVERSION;
CComQIPtr<Office::_CommandBarButton> pCommandBarButton(Ctrl);
CGetStartUI ui;
char szCurrentPath[255];
char szPath[255];
GetCurrentDirectory(255,szCurrentPath);
SetCurrentDirectory(m_szPath);
strcpy(szPath ,m_szPath);
/*strcat(szPath , "MyCard.dll");
if (ui.InitEx(szPath))
{
ui.GetStart();
}
ui.Free();
*/
ShellExecute(NULL , "" ,"BundleUI.exe", "-0" ,m_szPath,SW_SHOW);
//设置到以前的路径
SetCurrentDirectory(szCurrentPath);
}
void __stdcall CAddin::OnClickButton2(IDispatch* Ctrl,VARIANT_BOOL * CancelDefault)
{
CGetStartUI ui;
char szCurrentPath[255];
char szPath[255];
GetCurrentDirectory(255,szCurrentPath);
SetCurrentDirectory(m_szPath);
strcpy(szPath ,m_szPath);
strcat(szPath , "SendCard.dll");
typedef void (__stdcall * ShowUI)(LPDISPATCH Dispatch);
HINSTANCE hInstance = LoadLibrary(szPath);
if(hInstance)
{
ShowUI Show = (ShowUI)GetProcAddress(hInstance ,"ShowUI");
if(Show)
{
Show(m_Dispatch);
}
FreeLibrary(hInstance);
}
/*
if (ui.Init(szPath))
{
ui.GetStart();
}
ui.Free();
*/
//设置到以前的路径
SetCurrentDirectory(szCurrentPath);
return ;
}
void __stdcall CAddin::OnClickButton3(IDispatch* /*Office::_CommandBarButton* */ Ctrl,VARIANT_BOOL * CancelDefault)
{
/* CGetStartUI ui;
char szCurrentPath[255];
char szPath[255];
GetCurrentDirectory(255,szCurrentPath);
SetCurrentDirectory(m_szPath);
strcpy(szPath ,m_szPath);
strcat(szPath , "SendCard.dll");
if (ui.Init(szPath))
{
ui.GetStart();
}
ui.Free();
//设置到以前的路径
SetCurrentDirectory(szCurrentPath);
*/
return ;
}
void __stdcall CAddin::OnClickMenu1(IDispatch* /*Office::_CommandBarButton* */ Ctrl,VARIANT_BOOL * CancelDefault)
{
USES_CONVERSION;
CComQIPtr<Office::_CommandBarButton> pCommandBarButton(Ctrl);
CGetStartUI ui;
char szCurrentPath[255];
char szPath[255];
GetCurrentDirectory(255,szCurrentPath);
SetCurrentDirectory(m_szPath);
strcpy(szPath ,m_szPath);
/*strcat(szPath , "MyCard.dll");
if (ui.InitEx(szPath))
{
ui.GetStart();
}
ui.Free();
*/
ShellExecute(NULL , "" ,"BundleUI.exe", "-0" ,m_szPath,SW_SHOW);
//设置到以前的路径
SetCurrentDirectory(szCurrentPath);
}
void __stdcall CAddin::OnClickMenu2(IDispatch* /*Office::_CommandBarButton* */ Ctrl,VARIANT_BOOL * CancelDefault)
{
CGetStartUI ui;
char szCurrentPath[255];
char szPath[255];
GetCurrentDirectory(255,szCurrentPath);
SetCurrentDirectory(m_szPath);
strcpy(szPath ,m_szPath);
strcat(szPath , "SendCard.dll");
typedef void (__stdcall * ShowUI)(LPDISPATCH Dispatch);
HINSTANCE hInstance = LoadLibrary(szPath);
if(hInstance)
{
ShowUI Show = (ShowUI)GetProcAddress(hInstance ,"ShowUI");
if(Show)
{
Show(m_Dispatch);
}
FreeLibrary(hInstance);
}
/*if (ui.Init(szPath))
{
ui.GetStart();
}
ui.Free();
*/
//设置到以前的路径
SetCurrentDirectory(szCurrentPath);
}
void __stdcall CAddin::OnClickMenu3(IDispatch* /*Office::_CommandBarButton* */ Ctrl,VARIANT_BOOL * CancelDefault)
{
USES_CONVERSION;
CComQIPtr<Office::_CommandBarButton> pCommandBarButton(Ctrl);
//the button that raised the event. Do something with this...
MessageBox(NULL, "Clicked MenuItem", "OnClickMenu3", MB_OK);
}
void __stdcall CAddin::OnClickMenu4(IDispatch* /*Office::_CommandBarButton* */ Ctrl,VARIANT_BOOL * CancelDefault)
{
CGetStartUI ui;
char szCurrentPath[255];
char szPath[255];
GetCurrentDirectory(255,szCurrentPath);
SetCurrentDirectory(m_szPath);
strcpy(szPath ,m_szPath);
/*strcat(szPath , "UISet.dll");
if (ui.Init(szPath))
{
ui.GetStart();
}
ui.Free();
*/
ShellExecute(NULL , "" ,"BundleUI.exe", "-2" ,m_szPath,SW_SHOW);
//设置到以前的路径
SetCurrentDirectory(szCurrentPath);}
void __stdcall CAddin::OnClickMenu5(IDispatch* /*Office::_CommandBarButton* */ Ctrl,VARIANT_BOOL * CancelDefault)
{
USES_CONVERSION;
CComQIPtr<Office::_CommandBarButton> pCommandBarButton(Ctrl);
//the button that raised the event. Do something with this...
MessageBox(NULL, "Clicked MenuItem", "OnClickMenu5", MB_OK);
}
void __stdcall CAddin::OnClickMenu6(IDispatch* /*Office::_CommandBarButton* */ Ctrl,VARIANT_BOOL * CancelDefault)
{
USES_CONVERSION;
CComQIPtr<Office::_CommandBarButton> pCommandBarButton(Ctrl);
MessageBox(NULL, "Clicked MenuItem6", "OnClickMenu6", MB_OK);
}
void __stdcall CAddin::OnOptionsAddPages(IDispatch *Ctrl)
{
/* CComQIPtr<Outlook::PropertyPages> spPages(Ctrl);
ATLASSERT(spPages);
CComVariant varProgId(OLESTR("OutlookAddin.PropPage"));
CComBSTR bstrTitle(OLESTR("Addin Options"));
CComVariant varLiteProgId(OLESTR("OutlookAddin.LitePage"));
CComBSTR bstrLiteTitle(OLESTR("Lite Control"));
HRESULT hr = spPages->Add((_variant_t)varProgId,(_bstr_t)bstrTitle);
if(FAILED(hr))
ATLTRACE("\nFailed addin propertypage");
hr = spPages->Add((_variant_t)varLiteProgId,(_bstr_t)bstrLiteTitle);
if(FAILED(hr))
ATLTRACE("\nFailed adding lite PropertyPage");
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -