0

In fact, I'm developping an Excel Addin.
My addin is opening a new Windows Form over Excel, and what I'd like to do is :

  • Disable and remove focus from the excel's window
  • Send focus to the new Windows Form
  • Keep the new Form over the Excel's Windows
  • Re-enable and send back focus to excel's window on Form's closing event

How should I do that ?

Note :: I don't want my new opened form to be on top of all windows but only on top of my excel's window.

Jsncrdnl
  • 3,005
  • 5
  • 28
  • 43
  • 3
    So... You just want the [modal dialog](http://msdn.microsoft.com/en-us/library/w61zzfwe.aspx)? – GSerg Jan 25 '12 at 14:06
  • No, I don't need a modal dialog. I do need a brand new Windows Form because there are many thing I have to put within' that Controler. So what I need is to find some way to force focus on my Windows Form over the Excel App. – Jsncrdnl Jan 25 '12 at 14:11
  • 2
    Everything you describe is done by the Form.ShowDialog() method. You'll have to post a snippet of your code if you that doesn't work. – Hans Passant Jan 25 '12 at 14:18
  • Hans & GSerg are correct see here http://msdn.microsoft.com/en-us/library/39wcs2dh(v=vs.80).aspx – Carl Winder Jan 25 '12 at 14:24
  • Okok, thank you ! That exactly what I wanted ! (I did not know that method - and did not understood well at once). I got another problem, how could I remove this form's focus without closing it ? (In fact, I'd like to kinda hide it and then show it back on purpose) – Jsncrdnl Jan 25 '12 at 14:30
  • Ok, so that's what worked for me :: `/*display and keep focused*/ myForm.ShowDialog(); /*Hide and may be displayed again*/ myForm.Hide();` – Jsncrdnl Jan 25 '12 at 14:56

0 Answers0