FrontPage Com Add-ins help (FP2003 VC++.net 2003)

A

Amber Zhao

I want to develop an COM Add-in for FP2003 which adds a button to FP
toolbar,
and pop-up a window when the button is clicked.
Now I've added the button to the FP toolbar, but how to add event handle to
the
button?

There's my code about the event handler:
-------------------------------------------------------------------------------------------------------
connect.h:

extern _ATL_FUNC_INFO OnClickButtonInfo;
class ATL_NO_VTABLE CConnect :
......
public IDispEventSimpleImpl <2, CConnect,
&__uuidof(Office::_CommandBarButtonEvents)>
public:
typedef IDispEventSimpleImpl <2, CConnect,
&__uuidof(Office::_CommandBarButtonEvents)> ButtonEvents;
void __stdcall OnClickButton(IDispatch *Ctrl, VARIANT_BOOL *
CancelDefault);

BEGIN_SINK_MAP(CConnect)
SINK_ENTRY_INFO(2, __uuidof(Office::_CommandBarButtonEvents), /*dispid*/
0x01, OnClickButton, &OnClickButtonInfo)
END_SINK_MAP()

------------------------------------------------------------------------------------------------------
connect.cpp:

_ATL_FUNC_INFO OnClickButtonInfo =
{CC_STDCALL,VT_EMPTY,0,{VT_DISPATCH,VT_BYREF | VT_BOOL}};

void __stdcall CConnect::OnClickButton(IDispatch * Ctrl, VARIANT_BOOL *
CancelDefault)
{
USES_CONVERSION;
CComQIPtr<Office::_CommandBarButton> pCommandBarButton(Ctrl);
//the button that raised the event. Do something with this...
MessageBox(NULL, "Clicked Button1", "OnClickButton", MB_OK);
CExampleDlg dlg;
dlg.DoModal(); // pop up the window
}

STDMETHODIMP CConnect::OnConnection(IDispatch *pApplication,
AddInDesignerObjects::ext_ConnectMode ConnectMode, IDispatch *pAddInInst,
SAFEARRAY ** /*custom*/ )
{
/* add button to toolbar code ignored*/

ButtonEvents::DispEventAdvise((IDispatch*)m_spButton,&(Office::DIID__CommandBarButtonEvents));---------------------------------------------------------------------------------------------------------stdafx.h //The following #import imports the IDTExtensibility2 interface based onit's LIBID #import "libid:AC0714F2-3D04-11D1-AE7D-00A0C90F26F4" version("1.0")lcid("0") raw_interfaces_only named_guids //The following #import imports MSO based on it's LIBID #import "libid:2DF8D04C-5BFA-101B-BDE5-00AA0044DE52" version("2.2")lcid("0") raw_interfaces_only named_guids// The following #import imports FrontPage type lib #import "libid:3824BCD5-7042-11CE-8E17-0020AF9F9648" lcid("0")rename_namespace("FrontPage") raw_interfaces_only named_guids using namespace FrontPage;==========================================================================================================the error message when building:nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined inAddIn.objnafxcwd.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined inAddIn.obj; second definition ignored Creating library Debug/FPDigitSeal.lib and object Debug/FPDigitSeal.expnafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argvnafxcwd.lib(appcore.obj) : error LNK2001: unresolved external symbol ___argcnafxcwd.lib(apphelp.obj) : error LNK2001: unresolved external symbol__mbctypenafxcwd.lib(filelist.obj) : error LNK2001: unresolved external symbol__mbctypenafxcwd.lib(viewedit.obj) : error LNK2019: unresolved external symbol__mbctype referenced in function "protected: long __thiscallCEditView::OnFindReplaceCmd(unsigned int,long)"(?OnFindReplaceCmd@CEditView@@IAEJIJ@Z)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top