locked
[VS2012] IVsUIShell5.ThemeWindow() not working for ListView control RRS feed

  • Question

  • Hi all,

    Hoping someone could shed some light on this problem for me please. Been working on my DPack extension on VS 2012 support. New themes support is not working for me on ListView control.

    I have a toolwindow descendant of ToolWindowPane hosting my WinForms UserControl with a ListView on it. Calling IVsUIShell5.ThemeWindow() themes very first time works and themes it just fine. When theme's changed and I call the same IVsUIShell5.ThemeWindow() ListView's column header isn't getting redrawn and remains unchanged. IE, changing from the light to dark theme updates the appearance of my ListView to dark but the columns header, which remains light. The only workaround is to close the toolwindow and reopen it again, which  obviously is not an acceptable solution.

    I'd appreciate any help or suggestions. Thanks so much.


    Sergey (DPack - www.usysware.com/dpack/)


    • Edited by Sergey M Monday, October 22, 2012 12:49 PM
    Sunday, October 21, 2012 10:13 PM

Answers

  • Invalidating the window won't help - the colors inside the class dealing with the header theming are cached, and the cache gets invalidated only when the listview or the header gets a message indicating the colors have changed.

    When the shell theme changes, the shell broadcast a message to all subscribers (via IVsBroadcastMessageEvents.OnBroadcastMessage). Your toolwindow will have to intercept the message and pass it further to the listview/header (or any other children that will need themed).

    Since your toolwindow is derived from MPF's ToolWindowPane class, you're already subscribed to receive shell events - you only need to override the virtual OnBroadcastMessage() function, and forward messages like WM_THEMECHANGED and WM_SYSCOLORCHANGE to the listview or header.

    Alin

    Monday, October 22, 2012 5:04 AM

All replies

  • Have you tried invalidating the window? Perhaps windows hasn't realized the header rects are dirty and thus hasn't tried to re-render them.

    Ryan

    Monday, October 22, 2012 12:20 AM
  • Invalidating the window won't help - the colors inside the class dealing with the header theming are cached, and the cache gets invalidated only when the listview or the header gets a message indicating the colors have changed.

    When the shell theme changes, the shell broadcast a message to all subscribers (via IVsBroadcastMessageEvents.OnBroadcastMessage). Your toolwindow will have to intercept the message and pass it further to the listview/header (or any other children that will need themed).

    Since your toolwindow is derived from MPF's ToolWindowPane class, you're already subscribed to receive shell events - you only need to override the virtual OnBroadcastMessage() function, and forward messages like WM_THEMECHANGED and WM_SYSCOLORCHANGE to the listview or header.

    Alin

    Monday, October 22, 2012 5:04 AM
  • Hi guys,

    Ryan, yeah, I've already tried Invalidate() and unfortunately, that didn't. Thanks for your suggestion though.

    Alin, that makes sense. Matter of fact, I think I do use IVsBroadcastMessageEvents already anyways. I'll need to add a pass-through for those 2 WM_ messages to see if that fixes it but I suspect it should do the trick. I do recall seeing some colors getting cached on ListView while examining it with Reflector just didn't put 2 and 2 together. I'll give it a try in the next few days and report back. Thank you very much for your help.


    Sergey (DPack - www.usysware.com/dpack/)

    Monday, October 22, 2012 12:48 PM
  • IVsBroadcastMessageEvents worked great for me. Thanks so much for your help.

    Sergey (DPack - www.usysware.com/dpack/)

    Tuesday, October 23, 2012 3:07 AM