Johnny,
It's a bit of a hack, but from the DTE class, you could use the
MainWindow property to get what I assume is the main window to the IDE.
Once you have that, you can subclass the window and intercept the
WM_ACTIVATE and/or WM_ACTIVATEAPP messages to see when your main window is
being activated (or a window that is a child of the main window).

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> In the VS 2005 add-in I'm currently developing, I want to be able to find
> out when the entire Visual Studio IDE receives and loses focus (e.g. when
[quoted text clipped - 5 lines]
> Cheers,
> Johnny J.
Johnny Jörgensen - 30 Jul 2007 22:07 GMT
Hi Nicholas
Thanks for the input. I did try your approach. But seeing that I'm not so
experienced in subclassing windows messages, I found a C# example of how to
do it on vbAccelerator.com
(http://www.vbaccelerator.com/home/NET/Code/Libraries/Windows_Messages/Subclassin
g_in__NET/article.asp).
It was actually almost precisely what i was looking for apart from one
thing: it was indeed in C#, and the current project I'm working on is VB.
So I converted the C# to VB and it went ok apart from one detail (as far as
I can tell - it compiled at least...):
It seems like I can get the hWnd as well as the Handle from
EnvDTE.MainWindow (even though they are not visible in the intellisense).
The problem is that both of these values are Integer, but my subclassing
routine requires a handle of the type IntPtr.
I tried this:
activateChange = New ActivationChangeSubclass(CType(myDTE.MainWindow.Handle,
IntPtr), Nothing, Me)
but It made the Add-In crash, so apparently it wasn't the right solution.
Same with:
activateChange = New ActivationChangeSubclass(CType(myDTE.MainWindow.HWnd,
IntPtr), Nothing, Me)
Any ideas about how I can do that?
Cheers,
Johnny J.
> Johnny,
>
[quoted text clipped - 13 lines]
>> Cheers,
>> Johnny J.
Nicholas Paldino [.NET/C# MVP] - 30 Jul 2007 22:29 GMT
Johnny,
You can't cast directly from an integer to an IntPtr, but you can create
a new IntPtr from an integer, like so (in C#, but you can convert it to VB
easily):
// The integer value.
int i = 10;
IntPtr ptr = new IntPtr(i);

Signature
- Nicholas Paldino [.NET/C# MVP]
- mvp@spam.guard.caspershouse.com
> Hi Nicholas
>
[quoted text clipped - 47 lines]
>>> Cheers,
>>> Johnny J.
Johnny Jörgensen - 31 Jul 2007 19:56 GMT
Thanks a lot for your help Nicholas - Now I got it working perfectly just
like I want it...
Cheers,
Johnny J.
> Johnny,
>
[quoted text clipped - 59 lines]
>>>> Cheers,
>>>> Johnny J.