C#: Excel 2007 Addin, How to Hook Windows Activate and Deactivate Events

Posted by user127490 on Stack Overflow See other posts from Stack Overflow or by user127490
Published on 2009-07-03T12:36:35Z Indexed on 2010/03/27 21:03 UTC
Read the original article Hit count: 669

Filed under:
|
|
|

I am writing an Excel 2007 Addin. using VS2008 and .net 3.5, C#.

I catched Microsoft.Office.Interop.Excel.Application's WindowActivate and WindowDeActivate events.

It was surprised to know that WindowActivate and Deactivate only triggers when i switch between two Excel Windows. if i switch to notepad, i expect Deactivate to be triggered, but its not happening. same way from notepad if i switch to excel window, i expect Activate to be triggered but its not happening. It looks like the behaviour indicates windows are MDI-Child windows.

Now what i want to do is get HWnd of Excel's Mainwindow and hook Window Activate and Deactivates using dllimport features.

Can anyone guide to me on this.

Regards

© Stack Overflow or respective owner

Related posts about addins

Related posts about hooks