none
Custom Form Tab Order for Reply vs New RRS feed

  • Question

  • I've created a custom form to collect additonal information from the sender, however the tab order that is specified seems to apply to both new and replies.  Is there a way to set different tab orders (such that a reply has the body focused when the form loads vs the To field in new emails)?  I don't see any direct way to do this short of possibly creating 2 forms or perhaps using code to do this.  Any ideas or suggestions would be greatly appreciated!

    Monday, June 25, 2012 1:53 PM

Answers

  • You wouldn't use the Startup event handler, for the most part there won't be any open items at that time to begin with.
     
    I would handle the NewInspector() event of the Inspectors collection. In that handler I'd try casting Inspector.CurrentItem as MailItem, if the result is not null you know it's a mail item:
     
    Outlook.MailItem mail = Inspector.CurrentItem as Outlook.MailItem;
    if (mail != null)
    {
        // ok, it's a mail item. set up to handle Inspector events on this Inspector and item
     
    When Inspector.Activate() fires you have a strong object reference to the Inspector and its CurrentItem, so at that time I'd set the active tab. The actual tab orders cannot be changed for a custom form. To create different sets of tabs in different orders you'd need to use different forms (different MessageClass) or use FormRegions.
     
    You can however hide and show the custom form tabs, that might substitute for different tab orders if you design the form for that purpose. The Inspector.HideFormPage() and ShowFormPage() methods do that. Inspector.ModifiedFormPages returns a collection of objects. Each of those objects can be cast to an instance of a Forms 2.0 (FM20.dll) Page object. You can then get the Controls collection of the Page and use the Control.SetFocus() method to set the form's focus to a specific control on the page.
     
    Say you want a textbox "text1" to get focus, you'd use Controls.Item("text1") to get a handle to the textbox as a Control object and use that control's SetFocus() method.
     
    As far as finding whether an item is a new one or a reply, there's no actual function or property for that. What I usually use is a test on ConversationIndex. If it doesn't exist (null property) it's a new item (before the first save of the item). If it has that property it's not a new item but a reply or replyall or forward. If the item has an EntryID property then it's been saved already and is a saved draft or an item opened for reading.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "RyanSTV" <=?utf-8?B?UnlhblNUVg==?=> wrote in message news:b06a20b6-09a5-4379-9d31-caad626f7131...
    Ken, as always thanks for your quick reply!  I had a feeling I'd be resorting to code to handle this task.  I've spent the better part of the morning trying to figure out a method to do this (C#) and so far I've been unsuccessful.  I believe I need to set the focus in the "ThisAddIn_Startup" function, however I can't determine how focus is actually set.  I have it checking the subject line to verify the message is a reply, but the code to actually set the focus to the body has me stumped. 

    Ken Slovak MVP - Outlook
    • Marked as answer by RyanSTV Tuesday, June 26, 2012 1:00 PM
    Monday, June 25, 2012 3:28 PM

All replies

  • You would have to use 2 different forms or use code. Different forms would be a problem in coordinating with the MessageClass of the item, as replies and new items both normally have the same MessageClass.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "RyanSTV" <=?utf-8?B?UnlhblNUVg==?=> wrote in message news:0f753c78-f545-40bf-bbe7-83c7b2d41c01...

    I've created a custom form to collect additonal information from the sender, however the tab order that is specified seems to apply to both new and replies.  Is there a way to set different tab orders (such that a reply has the body focused when the form loads vs the To field in new emails)?  I don't see any direct way to do this short of possibly creating 2 forms or perhaps using code to do this.  Any ideas or suggestions would be greatly appreciated!


    Ken Slovak MVP - Outlook
    Monday, June 25, 2012 2:49 PM
  • Ken, as always thanks for your quick reply!  I had a feeling I'd be resorting to code to handle this task.  I've spent the better part of the morning trying to figure out a method to do this (C#) and so far I've been unsuccessful.  I believe I need to set the focus in the "ThisAddIn_Startup" function, however I can't determine how focus is actually set.  I have it checking the subject line to verify the message is a reply, but the code to actually set the focus to the body has me stumped. 
    You would have to use 2 different forms or use code. Different forms would be a problem in coordinating with the MessageClass of the item, as replies and new items both normally have the same MessageClass.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007

    Ken Slovak MVP - Outlook

    Monday, June 25, 2012 3:01 PM
  • You wouldn't use the Startup event handler, for the most part there won't be any open items at that time to begin with.
     
    I would handle the NewInspector() event of the Inspectors collection. In that handler I'd try casting Inspector.CurrentItem as MailItem, if the result is not null you know it's a mail item:
     
    Outlook.MailItem mail = Inspector.CurrentItem as Outlook.MailItem;
    if (mail != null)
    {
        // ok, it's a mail item. set up to handle Inspector events on this Inspector and item
     
    When Inspector.Activate() fires you have a strong object reference to the Inspector and its CurrentItem, so at that time I'd set the active tab. The actual tab orders cannot be changed for a custom form. To create different sets of tabs in different orders you'd need to use different forms (different MessageClass) or use FormRegions.
     
    You can however hide and show the custom form tabs, that might substitute for different tab orders if you design the form for that purpose. The Inspector.HideFormPage() and ShowFormPage() methods do that. Inspector.ModifiedFormPages returns a collection of objects. Each of those objects can be cast to an instance of a Forms 2.0 (FM20.dll) Page object. You can then get the Controls collection of the Page and use the Control.SetFocus() method to set the form's focus to a specific control on the page.
     
    Say you want a textbox "text1" to get focus, you'd use Controls.Item("text1") to get a handle to the textbox as a Control object and use that control's SetFocus() method.
     
    As far as finding whether an item is a new one or a reply, there's no actual function or property for that. What I usually use is a test on ConversationIndex. If it doesn't exist (null property) it's a new item (before the first save of the item). If it has that property it's not a new item but a reply or replyall or forward. If the item has an EntryID property then it's been saved already and is a saved draft or an item opened for reading.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "RyanSTV" <=?utf-8?B?UnlhblNUVg==?=> wrote in message news:b06a20b6-09a5-4379-9d31-caad626f7131...
    Ken, as always thanks for your quick reply!  I had a feeling I'd be resorting to code to handle this task.  I've spent the better part of the morning trying to figure out a method to do this (C#) and so far I've been unsuccessful.  I believe I need to set the focus in the "ThisAddIn_Startup" function, however I can't determine how focus is actually set.  I have it checking the subject line to verify the message is a reply, but the code to actually set the focus to the body has me stumped. 

    Ken Slovak MVP - Outlook
    • Marked as answer by RyanSTV Tuesday, June 26, 2012 1:00 PM
    Monday, June 25, 2012 3:28 PM