locked
How to get window focus change in vspackage ? RRS feed

  • Question

  • I create vspackage editor and implement selection tracking. All works fine except I need to know when my editor being lost focus, so like VS IDE behaviour the selected background color become greyed when the window has lost focus and back to dark blue when got focus.

    So how to get Window got focus and lost focus event in vspackage editor ?


    It's hard to be advanced programmer

    Thursday, February 14, 2013 6:10 AM

Answers

  • Cast your frame to IVsWindowFrame2 and call Advise, I believe the (poorly named) OnShow method of your IVsWindowFrameNotify callback interface will be invoked on gaining and losing activation (the shell talks about activations of windows, not focus, since focus is a more granular concept, i.e. inside your window something specific has focus, the shell doesn't care, it only cares about what frame is active).
    Thursday, February 14, 2013 6:40 AM
  • I believe you should get a FRAMESHOW_WinActivated when your window is activated.

    • Marked as answer by Ego Jiang Tuesday, February 26, 2013 8:58 AM
    Friday, February 15, 2013 7:27 AM

All replies

  • Cast your frame to IVsWindowFrame2 and call Advise, I believe the (poorly named) OnShow method of your IVsWindowFrameNotify callback interface will be invoked on gaining and losing activation (the shell talks about activations of windows, not focus, since focus is a more granular concept, i.e. inside your window something specific has focus, the shell doesn't care, it only cares about what frame is active).
    Thursday, February 14, 2013 6:40 AM
  • you are right, I already tried it and works. But the only problem is I don't know when the window going onhide. I check the fshow argument of OnShow method it always 1, I thought it will set to 0 when hide but it is not .

    So how to know when the window editor going to inactive ?


    It's hard to be advanced programmer

    Friday, February 15, 2013 3:15 AM
  • I just found also that when the editor window undock from its frame, and I change active document the windowframenotify not invoked again.I also tried IVsRunningDocTableEvents and it acctually same with above ?

    I guess it is wrong way ?


    It's hard to be advanced programmer


    • Edited by IRW7 Friday, February 15, 2013 4:19 AM addition
    Friday, February 15, 2013 3:45 AM
  • I believe you should get a FRAMESHOW_WinActivated when your window is activated.

    • Marked as answer by Ego Jiang Tuesday, February 26, 2013 8:58 AM
    Friday, February 15, 2013 7:27 AM