Change the caption of the InfoPath - InfoPath Dev
in

InfoPath Dev

Change the caption of the InfoPath

Last post 09-01-2006 10:52 AM by Greg Collins. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 08-29-2006 08:49 AM

    Change the caption of the InfoPath

    Hi,

    I'd like to customized the caption of the form, e.g. "Absence Request form of **** Co. Ltd."
    In the XDocument:OnLoad() I write
    Application.ActiveWindow.Caption = "Absence Request form of **** Co. Ltd.";

    When the form is just opened, the caption displays properly. However, it's soon changed to "Form1" (in case of double clicking the templat) or "Preview1" (in case of preview when designing the form).

    Any suggestion?


    Thanks!
  • 08-29-2006 01:51 PM In reply to

    Re: Change the caption of the InfoPath

    I'm not sure that you'll be able to do this. You might try adding that line of code in the OnContextChange event handler so that the new title bar is constantly overwritten. This might affect performance and it is kind of a hack but it should accomplish this.
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 08-30-2006 01:25 PM In reply to

    Re: Change the caption of the InfoPath

    Its probably no surprise for previewing, but you'll need to find out what is triggering the title change in your live form and then reset the title to your text when that trigger occurs.

    I have seen this feature, but never used it--so I was unaware that InfoPath would change it back after setting it.
  • 09-01-2006 12:58 AM In reply to

    Re: Change the caption of the InfoPath

    Hi Greg,

    I made a simple template as following:
    1. one button and one text box.
    2. JS codes are:

    function XDocument::OnLoad(eventObj)
    {
    Application.ActiveWindow.Caption = "Hello World";
    }
    function CTRL1_5::OnClick(eventObj)
    {
    Application.ActiveWindow.Caption = "Hello World again by Clicking";
    }


    Every time the form is opened by either previewing or double clicking the template, the captical is "Preview1" or "Form1" correspondingly. After the button is clicked, it's changed to "Hello World by Clicking", and focus swiching between button and text box or inputting in the text box doesn't reflect the capital.


    Then I added/modified the JS codes like:
    var ii;
    function XDocument::OnLoad(eventObj)
    {
    Application.ActiveWindow.Caption = "Hello World";
    ii = 0;
    }
    function CTRL1_5::OnClick(eventObj)
    {
    Application.ActiveWindow.Caption = "Hello World again by Clicking";
    }
    function XDocument::OnContextChange(eventObj)
    {
    ii++;
    Application.ActiveWindow.Caption = "Hello World " + ii;
    }


    Now every time when the form is displayed in "filling" mode, the capital is "Hello World 1". When the focus is changed, the count is added, and when the button is clicked after it just gets the focus, the capital will first be "Hello World by Clicking" then immediately changes to "Hello World *".


    From the above, maybe I can say that event OnContextChange is triggered right after OnLoad. However, the default OnContextChange will set the capital to its initial form, namely "Preview*" for previewing and "Form*" for filling.


    quote:
    Originally posted by Greg Collins

    Its probably no surprise for previewing, but you'll need to find out what is triggering the title change in your live form and then reset the title to your text when that trigger occurs.

    I have seen this feature, but never used it--so I was unaware that InfoPath would change it back after setting it.

  • 09-01-2006 10:52 AM In reply to

    Re: Change the caption of the InfoPath

    Yes, the OnContextChange is fired after OnLoad... it occurs when the view has been drawn completely (keep in mind the View object doesn't even exist during OnLoad--it is created and rendered afterward). Once the view is drawn, the initial context is set, thus firing the very first OnContextChange event.

    Here's what I had to do to get the custom caption to stay:

    1. Set a global variable: SetCaption = 0;
    2. In the OnContextChange event handler, check: if(SetCaption < 2) { SetCaption++; Application.ActiveWindows.Caption = "Custom Caption"; }

    That seemed to do the trick. The initial caption change in OnContextChange was lost, but the second change remained.

    Good luck!
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.