Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Capturing the event

Capturing the event

Scheduled Pinned Locked Moved C / C++ / MFC
comquestionc++graphics
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hey everybody, I put a post out about my word automation not working. I haven't been able to get past the Link Error so I tried something different. Now, I have this function which puts a button (with a bitmap) onto MS Word. As you can see, I create it dynamically. Now, what I was wondering, how can I capture the event when this button is pressed? I am trying to do an Advise but it doesn't seem to be doing what I want it to do??? I have pasted the header file for the event sink and the actual function which does the Advise. Any ideas? Anything come to mind? Do you think I am making this too complicated and have a better way to go at it? Just let me know, I am knew to COM/ATL/OLE development... ====================================================================== header file wordeventsink.h: #if !defined(AFX_WORDEVENTSINK_H__F45A8330_C1E9_11D2_A0C4_0080C7F3B56B__INCLUDED_) #define AFX_WORDEVENTSINK_H__F45A8330_C1E9_11D2_A0C4_0080C7F3B56B__INCLUDED_ /*----------------------------------------------------------------------------*/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 /*----------------------------------------------------------------------------*/ //#pragma warning (disable:4146) //#import "mso97.dll" //#pragma warning (default:4146) //#import "vbeext1.olb" //#import "msword8.olb" rename("ExitWindows", "WordExitWindows") #pragma warning (disable:4146) #import "C:\Program Files\Common Files\Microsoft Shared\Office10\mso.dll" #pragma warning (default:4146) #import "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\vbe6ext.olb" #import "C:\Program Files\Microsoft Office\Office10\MSWORD.olb" rename("ExitWindows", "WordExitWindows") #include "ConnectionAdvisor.h" class CTestDlg; /*----------------------------------------------------------------------------*/ const IID IID_IWordAppEventSink = __uuidof(Word::ApplicationEvents); const IID IID_IWordDocEventSink = __uuidof(Word::DocumentEvents); const IID IID_IPSISaveExit = __uuidof(Office::_CommandBarButtonEvents); /*----------------------------------------------------------------------------*/ class CWordEventSink : public CCmdTarget { DECLARE_DYNCREATE(CWordEventSink) public: CWordEventSink(); virtual ~CWordEventSink(); BOOL Advise(IUnknown* pSource, REFIID iid); BOOL Unadvise(REFIID iid); void SetLauncher(CTestDlg* pWordLauncher); // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CWordEventSink) public: virtual void OnFinalRelease(); //}}AFX_V

    R 1 Reply Last reply
    0
    • L Lost User

      Hey everybody, I put a post out about my word automation not working. I haven't been able to get past the Link Error so I tried something different. Now, I have this function which puts a button (with a bitmap) onto MS Word. As you can see, I create it dynamically. Now, what I was wondering, how can I capture the event when this button is pressed? I am trying to do an Advise but it doesn't seem to be doing what I want it to do??? I have pasted the header file for the event sink and the actual function which does the Advise. Any ideas? Anything come to mind? Do you think I am making this too complicated and have a better way to go at it? Just let me know, I am knew to COM/ATL/OLE development... ====================================================================== header file wordeventsink.h: #if !defined(AFX_WORDEVENTSINK_H__F45A8330_C1E9_11D2_A0C4_0080C7F3B56B__INCLUDED_) #define AFX_WORDEVENTSINK_H__F45A8330_C1E9_11D2_A0C4_0080C7F3B56B__INCLUDED_ /*----------------------------------------------------------------------------*/ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 /*----------------------------------------------------------------------------*/ //#pragma warning (disable:4146) //#import "mso97.dll" //#pragma warning (default:4146) //#import "vbeext1.olb" //#import "msword8.olb" rename("ExitWindows", "WordExitWindows") #pragma warning (disable:4146) #import "C:\Program Files\Common Files\Microsoft Shared\Office10\mso.dll" #pragma warning (default:4146) #import "C:\Program Files\Common Files\Microsoft Shared\VBA\VBA6\vbe6ext.olb" #import "C:\Program Files\Microsoft Office\Office10\MSWORD.olb" rename("ExitWindows", "WordExitWindows") #include "ConnectionAdvisor.h" class CTestDlg; /*----------------------------------------------------------------------------*/ const IID IID_IWordAppEventSink = __uuidof(Word::ApplicationEvents); const IID IID_IWordDocEventSink = __uuidof(Word::DocumentEvents); const IID IID_IPSISaveExit = __uuidof(Office::_CommandBarButtonEvents); /*----------------------------------------------------------------------------*/ class CWordEventSink : public CCmdTarget { DECLARE_DYNCREATE(CWordEventSink) public: CWordEventSink(); virtual ~CWordEventSink(); BOOL Advise(IUnknown* pSource, REFIID iid); BOOL Unadvise(REFIID iid); void SetLauncher(CTestDlg* pWordLauncher); // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CWordEventSink) public: virtual void OnFinalRelease(); //}}AFX_V

      R Offline
      R Offline
      Ramu Pulipati
      wrote on last edited by
      #2

      You have to advise the button events (_CommandBarButtonEvents) from m_pButton and add event handlers to the sink map. Hth, Ramu

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups