diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/gui/customstyles/customstyles.lpr | 12 | ||||
-rw-r--r-- | examples/gui/customstyles/mystyle.pas | 22 |
2 files changed, 18 insertions, 16 deletions
diff --git a/examples/gui/customstyles/customstyles.lpr b/examples/gui/customstyles/customstyles.lpr index 5da13e0f..419e6456 100644 --- a/examples/gui/customstyles/customstyles.lpr +++ b/examples/gui/customstyles/customstyles.lpr @@ -48,13 +48,15 @@ var frm: TTestForm; begin fpgApplication.Initialize; + + { Set our new style as the default (before we create any forms), unless + a the end-user specified a different style via the command line. } + if not gCommandLineParams.IsParam('style') then + if fpgStyleManager.SetStyle('Demo Style') then + fpgStyle := fpgStyleManager.Style; + frm := TTestForm.Create(nil); try - { Lets set a new default style if no style was specified in the command line } - if not gCommandLineParams.IsParam('style') then - if fpgStyleManager.SetStyle('Demo Style') then - fpgStyle := fpgStyleManager.Style; - frm.Show; fpgApplication.Run; finally diff --git a/examples/gui/customstyles/mystyle.pas b/examples/gui/customstyles/mystyle.pas index 3e9c2992..8db9f2b4 100644 --- a/examples/gui/customstyles/mystyle.pas +++ b/examples/gui/customstyles/mystyle.pas @@ -2,9 +2,10 @@ A very quick and basic style implementation. It took all of 10 minutes. To apply this style, follow these instructions: - * free the old fpgStyle - * instantiate the new style class - * and assign this new instance to fpgStyle variable + 1) (optional) Check if a style was specified via a command line parameter + 2) If (1) was false, set the new default which will instantiate the new + style class and automatically free the old one. + 3) Assign our new style instance to the fpgStyle variable Example: @@ -14,14 +15,15 @@ frm: TMainForm; begin fpgApplication.Initialize; + + { Set our new style as the default (before we create any forms), unless + a the end-user specified a different style via the command line. } + if not gCommandLineParams.IsParam('style') then + if fpgStyleManager.SetStyle('Demo Style') then + fpgStyle := fpgStyleManager.Style; + frm := TMainForm.Create(nil); try - // Free the old and set the new style - if Assigned(fpgStyle) then - fpgStyle.Free; - fpgStyle := TMyStyle.Create; - - // now continue with the application frm.Show; fpgApplication.Run; finally @@ -41,8 +43,6 @@ uses type - { TMyStyle } - TMyStyle = class(TfpgStyle) public constructor Create; override; |