.net - VSTO: Application Focus -
Does anyone know how to see if the excel window of a VSTO project is in active / focus?
I'm looking for the system equivalent. Windows Window Iactiv .
I was also disappointed with this ? If so, what I have done is to officially add an event to close the Windows Form / Dialogue to activate the application of the office (Example is with Word, so Excel can differ ):
// ... VSTO startup event WindowsForm form = new WindowsForm (); Form.FormClosed + New FormClosedEventHandler (form_FormClosed); Form.Show (); Zero form_FormClosed (Object Sender, FormClosedEventArgs e) {this.Application.Activate (); This. Application. Active window Windows = Microsoft. Office Interp. Word Windstate. Wadvindostat general; } I have found that this line is always false / true:
this.ActiveWindow.Active () < P> but it is active (global bool variable "apache" to keep track of active bundles): // ... VSTO startup event this. Application. Deactivate Windows + New Microsoft.Office. Interop.Word.ApplicationEvents4_WindowDeactivateEventHandler (Application_WindowDeactivate); This. Application. Activate window + new Microsoft.Office.Interop.Word.ApplicationEvents4_WindowActivateEventHandler (application_WindowActivate); Zero Application_WindowActivate (Microsoft.Office.Interop.Word.DocumentDoc, Microsoft.Office.Interop.Word.Window Wn) {AppActive = true; } Zero Application_WindowDeactivate (Microsoft.Office.Interop.Word.Document Doc, Microsoft.Office.Interop.Word.Window Wn) {AppActive = false; }
Comments
Post a Comment