ほとんどのシナリオでは、リポジトリに保存された事前定義済みのスタイルで、アプリケーションの要件が満たされます。しかし、場合によっては、フォントや色の選択の際などに動的なスタイルが必要になることがあります。このような状況では、他のコンポーネントと同じようにスタイルを定義したり、インスタンスを作成したりすることができます。つまり、プロパティを実行時に設定できるということです。
以下の例では、フォームをクリックしたときにカラー・ピッカーのダイアログが開きます。選択した色は、スタイルに適用され、したがってフォームの背景に適用されます。
Function Options(*DIRECT)
Begin_Com Role(*EXTENDS #PRIM_Form) Clientheight(284) Clientwidth(464) Height(323) Left(695) Style(#Style) Top(223) Width(480)
Define_Com Class(#prim_vs.Style) Name(#Style) Normbackcolor(White)
Define_Com Class(#Prim_appl.ICommonDialogColor) Name(#ColorPicker) Reference(*dynamic)
Define_Com Class(#PRIM_LABL) Name(#Label1) Caption('Click form to show color picker') Displayposition(1) Ellipses(Word) Height(25) Left(29) Parent(#COM_OWNER) Tabposition(1) Tabstop(False) Top(29) Verticalalignment(Center) Width(396) Alignment(Center)
Evtroutine Handling(#Com_owner.CreateInstance)
#Com_owner.Cursor <= #sys_appln.Cursors<Hand>
Endroutine
Evtroutine Handling(#Com_owner.Click)
If (#ColorPicker *Is *null)
#ColorPicker <= #sys_appln.CreateColorDialog
#ColorPicker.FullyOpen := true
Endif
#ColorPicker.Show
* Set Com(#Style) Normbackcolor(#ColorPicker.ChosenColor)
#Style.NormBackColor := #ColorPicker.ChosenColor
Endroutine
End_Com