none
How to show my .Net Screen on top of outlook from an addin RRS feed

  • Question

  • From form region in outlook addin, i show a vb.net form. VB.net form shows but it does not get the focus and show on top - in spite of bringtofront, focus or activate. Topmost = true is not what i want.
    Monday, October 8, 2012 3:31 PM

Answers

  • In the Shown() event for the form (subscribe to it in the form code) set top most to true, then call System.Windows.Forms.Application.DoEvents() and then set the value to false and see if that achieves the effect you want.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Sivakumar Angarai" <=?utf-8?B?U2l2YWt1bWFyIEFuZ2FyYWk=?=> wrote in message news:591bb730-6422-4c1d-b210-5d3b922b002e...
    When i set topmost = true in my vb.net forms load event, and then set it false from the calling method, the form goes minimized again. Wondering what to do.

    Ken Slovak MVP - Outlook
    Monday, October 8, 2012 8:55 PM

All replies

  • Set TopMost == true, then set if false after the form has been activated.
     
    Otherwise your option is pretty much to fall back to getting the hWnd of your form window and calling Win32 API functions such as SetWindowPos() with a value of HWND_TOP.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Sivakumar Angarai" <=?utf-8?B?U2l2YWt1bWFyIEFuZ2FyYWk=?=> wrote in message news:95662970-ee46-4656-b354-f32a2cc07d9b...
    From form region in outlook addin, i show a vb.net form. VB.net form shows but it does not get the focus and show on top - in spite of bringtofront, focus or activate. Topmost = true is not what i want.

    Ken Slovak MVP - Outlook
    Monday, October 8, 2012 3:48 PM
  • When i set topmost = true in my vb.net forms load event, and then set it false from the calling method, the form goes minimized again. Wondering what to do.
    Monday, October 8, 2012 4:58 PM
  • In the Shown() event for the form (subscribe to it in the form code) set top most to true, then call System.Windows.Forms.Application.DoEvents() and then set the value to false and see if that achieves the effect you want.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "Sivakumar Angarai" <=?utf-8?B?U2l2YWt1bWFyIEFuZ2FyYWk=?=> wrote in message news:591bb730-6422-4c1d-b210-5d3b922b002e...
    When i set topmost = true in my vb.net forms load event, and then set it false from the calling method, the form goes minimized again. Wondering what to do.

    Ken Slovak MVP - Outlook
    Monday, October 8, 2012 8:55 PM
  • Thanks. Your idea works. There seems to be a momentary delay when  it goes this seq of true, doevents and then false. But hey it works. Thanks a lot. 
    Tuesday, October 9, 2012 1:52 AM
  • Hello Siva and Ken,

    Using DoEvents can create many problems, see http://www.tonicodes.net/blog/application-doevents-are-evil/ for instance. Here's what Microsoft tell about using it, see http://support.microsoft.com/kb/138063. Don't be misleaded by the title: your Outlook add-in is a "OLE Server DLL", too.


    Regards from Belarus (GMT + 3),

    Andrei Smolin
    Add-in Express Team Leader

    Please mark answers and useful posts to help other developers use the forums efficiently.

    Tuesday, October 9, 2012 1:35 PM