This page describes how to set the title of an Application Form dynamically. Changing the title may not be required, but usually done to indicate the currently displayed record of a populated form.
There can be several reasons to why the title should be changed. The first thing to consider is where to place the update code so that the title reflects the state of the form. A title that should reflect the current record will need to keep track of when the record is populated and perhaps even saved. A title that reflect a more static situation like a users connected country will require less frequent changes, where the feature activate event is likely to be adequate.
In this example the title is changed to reflect the country that the form is currently showing information for.
To achieve this a translatable string resource should be created. The string resource should be created with parameter placeholders.
Name | Value | Comment |
---|---|---|
AreaOverviewTitle | Areas of Country '&0 - &1' | This constant is used to set the title of .. |
vrtActivate
and call your utility functionSal.SetWindowText
is called, the string constant
can be used together with TranslateConstantWithParams
. The string
will in in runtime be translated, but we still need to replace our
&[n] placeholders with current values. To achieve
this, we pass the translated string together with an array of values that
should replace the placeholders.#region Overrides public override SalNumber vrtActivate(fcURL URL) { SetWindowTitle(); return base.vrtActivate(URL); } #endregion #region Methods /// <summary> /// Set the window title according to current area and country. /// </summary> public void SetWindowTitle() { SalArray<SalString> sItems = new SalArray<SalString>(); sItems[0] = sCountryId; sItems[1] = sCountry; Sal.SetWindowText(i_hWndFrame, Ifs.Fnd.ApplicationForms.Int .TranslateConstantWithParams(Properties.Resources.AreaOverviewTitle, sItems)); } #endregionFigure 1: This example overrides
vrtActivate
and callsSetWindowTitle
, which sets the window title usingTranslateConstantWithParams
.