.NET Forum / Visual Studio.NET / Extensibility / December 2005
How to use IVsFontAndColorEvents interface?
|
|
Thread rating:  |
Dmitry Shaporenkov - 02 Dec 2005 13:38 GMT Hi,
in my package I need to get notified of changes made by user to the font and color settings of various display items via Tools|Options|Environment|Fonts and Colors dialog. I've found an interface IVsFontAndColorEvents that seemingly enables that, and IVsFontAndColorStorage that can be used to get the current settings. However, I completely miss how can I advise an object implementing IVsFontAndColorEvents to the event source and what is that event source? It seems there are no any methods receiving IVsFontAndColorEvents as a parameter, and IVsFontAndColorStorage doesn't allow to connect this interface via COM connection points (in managed code, the following lines throw InvalidCastException):
IVsFontAndColorStorage storage = (IVsFontAndColorStorage)GetService(typeof(SVsFontAndColorStorage), typeof(IVsFontAndColorStorage)); myFontAndColorEventsCookie = new NativeMethods.ConnectionPointCookie(storage, this, typeof(IVsFontAndColorEvents));
What should I do in order to connect to events?
Thanks in advance.
Regards, Dmitry Shaporenkov JetBrains, Inc http://www.jetbrains.com "Develop with pleasure!"
"Gary Chang[MSFT]" - 03 Dec 2005 09:10 GMT Hi Dmitry,
Currently we are looking into this problem. We will reply here with more information as soon as possible. If you have any more concerns on it, please feel free to post here.
Thanks for your understanding!
Best regards,
Gary Chang Microsoft Community Support -------------------- Get Secure! ¡§C www.microsoft.com/security Register to Access MSDN Managed Newsgroups! http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp &SD=msdn
This posting is provided "AS IS" with no warranties, and confers no rights.
Dmitry Shaporenkov - 03 Dec 2005 12:20 GMT Hello Gary,
thank for your reply! I'm eagerly waiting for your further recommendations.
By the way, you wished me a nice weekend in another thread - but it looks that you're spending your weekend at work. Or may be it's just a time difference...
Regards, Dmitry Shaporenkov JetBrains, Inc http://www.jetbrains.com "Develop with pleasure!"
> Hi Dmitry, > [quoted text clipped - 16 lines] > This posting is provided "AS IS" with no warranties, and confers no > rights. Ed Dore [MSFT] - 04 Dec 2005 02:33 GMT Hi Dmitry,
If memory serves, I just derived the class that implements IVsFontAndColorDefauts, from IVsFontAndColorEvents as well. I did this a while back with a C++ package targeting VS 2003. My coworker found a bug in my package that causes a recusive interface call on VS2005. I'll try to dig that sample up on Monday and send you the fixed version.
The .IDL file that defines the interface does make mention of IConnectionPointContainer, so I'll double check the sources on this as well.
Sincerely, Ed Dore [MSFT]
This post is 'AS IS' with no warranties, and confers no rights.
Dmitry Shaporenkov - 05 Dec 2005 07:12 GMT Hello Ed,
thank you, as usually :). I'll be waiting for your sample. I've also derived my class from IVsFontAndColorDefauts and IVsFontAndColorEvents, but I cannot find how to connect ir - as I said in the original post, IVsFontAndColorStorage doesn't seem to expose IConnectionPointContainer (or I may be doing something wrong, though I have no idea what it could be).
Regards, Dmitry Shaporenkov JetBrains, Inc http://www.jetbrains.com "Develop with pleasure!"
> Hi Dmitry, > [quoted text clipped - 12 lines] > Ed Dore [MSFT] > This post is 'AS IS' with no warranties, and confers no rights. "Ed Dore [MSFT]" - 05 Dec 2005 23:54 GMT Hi Dmitry,
It appears that the documentation is in error here. I did a quick check through the IDE sources and it appears that the IVsFontAndColorEvents interface does need to be implemented on the object that also is implementing IVsFontAndColorDefaults.
In particular, the shell retrieves your IVsFontAndColorDefaults and then QI's for IVsFontAndColorEvents. If it find this interface, it's stored and used. Consquently, you need to implement this on the same object that's implementing your IVsFontAndColorDefaults interface.
I haven't tried proffer'ing a custom IVsFontAndColorDefaultsProvider service from a managed package as of yet. But you do need to ensure that the service is registered both unser the Services registry key as well as the FontsAndColors registry key. I don't have a lot of spare time this week, due to the ongoing VSIP developer lab, but I'll see if I can create a new C# based implementation of my original 2003 package and get it out to you.
Sincerely, Ed Dore [MSFT]
This post is 'AS IS' with no warranties, and confers no rights.
Dmitry Shaporenkov - 06 Dec 2005 05:31 GMT Hello Ed,
thanks for your investigation. As far as I understand, I need to proffer a service that implements IVsFontAndColorDefaultsProvider, IVsFontAndColorDefaults and IVsFontAndColorEvents and register this service appropriately. I'll try to do that and notify you if I have a success.
Regards, Dmitry Shaporenkov JetBrains, Inc http://www.jetbrains.com "Develop with pleasure!"
> Hi Dmitry, > [quoted text clipped - 19 lines] > Ed Dore [MSFT] > This post is 'AS IS' with no warranties, and confers no rights.
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|