[476] | 1 | unit SkinFormU;
|
---|
| 2 | (*
|
---|
| 3 | WorldVistA Configuration Utility
|
---|
| 4 | (c) 8/2008 Kevin Toppenberg
|
---|
| 5 | Programmed by Kevin Toppenberg, Eddie Hagood
|
---|
| 6 |
|
---|
| 7 | Family Physicians of Greeneville, PC
|
---|
| 8 | 1410 Tusculum Blvd, Suite 2600
|
---|
| 9 | Greeneville, TN 37745
|
---|
| 10 | kdtop@yahoo.com
|
---|
| 11 |
|
---|
| 12 | This library is free software; you can redistribute it and/or
|
---|
| 13 | modify it under the terms of the GNU Lesser General Public
|
---|
| 14 | License as published by the Free Software Foundation; either
|
---|
| 15 | version 2.1 of the License, or (at your option) any later version.
|
---|
| 16 |
|
---|
| 17 | This library is distributed in the hope that it will be useful,
|
---|
| 18 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 19 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 20 | Lesser General Public License for more details.
|
---|
| 21 |
|
---|
| 22 | You should have received a copy of the GNU Lesser General Public
|
---|
| 23 | License along with this library; if not, write to the Free Software
|
---|
| 24 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
---|
| 25 | *)
|
---|
| 26 |
|
---|
| 27 |
|
---|
| 28 | //==========================================================================
|
---|
| 29 | //==========================================================================
|
---|
| 30 | // NOTICE BELOW...
|
---|
| 31 | //==========================================================================
|
---|
| 32 | //==========================================================================
|
---|
| 33 | (*
|
---|
| 34 | NOTICE:
|
---|
| 35 | This unit makes use of propriatary, commercial, binary files
|
---|
| 36 | (.DCU files) that are bound by a *separate* license. Please see that
|
---|
| 37 | license which is in the \GUI-Config\SkinStuff\ folder
|
---|
| 38 | *)
|
---|
| 39 |
|
---|
| 40 | //NOTE: If the compilation directive USE_SKINS is not defined, then this
|
---|
| 41 | // form compiles without the skin manager, and is essentially useless.
|
---|
| 42 | // I chose not to remove the entire form for programming reasons, but
|
---|
| 43 | // it will not be accessible to the user unless active.
|
---|
| 44 |
|
---|
| 45 | interface
|
---|
| 46 |
|
---|
| 47 | uses
|
---|
| 48 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
---|
| 49 | {$IFDEF USE_SKINS}
|
---|
| 50 | ipSkinManager,
|
---|
| 51 | {$ENDIF}
|
---|
| 52 | StdCtrls, ExtCtrls, ComCtrls, Buttons, DBCtrls, Mask;
|
---|
| 53 |
|
---|
| 54 | type
|
---|
| 55 | TSkinForm = class(TForm)
|
---|
| 56 | Panel3: TPanel;
|
---|
| 57 | SkinsListBox: TListBox;
|
---|
| 58 | ApplySkinButton: TButton;
|
---|
| 59 | btnDisable: TButton;
|
---|
| 60 | Label12: TLabel;
|
---|
| 61 | Button6: TButton;
|
---|
| 62 | Button1: TButton;
|
---|
| 63 | cbSkinAtStartup: TCheckBox;
|
---|
| 64 | procedure FormCreate(Sender: TObject);
|
---|
| 65 | procedure ApplySkinButtonClick(Sender: TObject);
|
---|
| 66 | procedure SkinsListBoxDblClick(Sender: TObject);
|
---|
| 67 | procedure SkinsListBoxKeyPress(Sender: TObject; var Key: Char);
|
---|
| 68 | procedure Button6Click(Sender: TObject);
|
---|
| 69 | procedure FormDestroy(Sender: TObject);
|
---|
| 70 | procedure FormShow(Sender: TObject);
|
---|
| 71 | private
|
---|
| 72 | { Private declarations }
|
---|
| 73 | {$IFDEF USE_SKINS}
|
---|
| 74 | SkinManager : TipSkinManager;
|
---|
| 75 | {$ENDIF}
|
---|
| 76 | FINIFileName : string;
|
---|
| 77 | procedure FillSkinList;
|
---|
| 78 | public
|
---|
| 79 | { Public declarations }
|
---|
| 80 | CurrentSkinFile : string;
|
---|
| 81 | procedure ActivateCurrentSkin;
|
---|
| 82 | procedure InactivateSkin;
|
---|
| 83 | end;
|
---|
| 84 |
|
---|
| 85 | var
|
---|
| 86 | SkinForm: TSkinForm;
|
---|
| 87 |
|
---|
| 88 | //CONST
|
---|
| 89 | // SKIN_NONE = '<TURN OFF SKINS>' ;
|
---|
| 90 |
|
---|
| 91 | implementation
|
---|
| 92 |
|
---|
| 93 | {$R *.DFM}
|
---|
| 94 |
|
---|
| 95 | uses ShellAPI, inifiles;
|
---|
| 96 |
|
---|
| 97 | procedure TSkinForm.FillSkinList;
|
---|
| 98 | var
|
---|
| 99 | SRec : TSearchRec;
|
---|
| 100 | R : Integer;
|
---|
| 101 | begin
|
---|
| 102 | SkinsListBox.Items.Clear;
|
---|
| 103 | // SkinsListBox.Items.Add (SKIN_NONE);
|
---|
| 104 | R := FindFirst (ExtractFilePath (Application.ExeName) + '\SkinStuff\Skins\*.ipz', faAnyFile, SRec);
|
---|
| 105 | while R = 0 do
|
---|
| 106 | begin
|
---|
| 107 | SkinsListBox.Items.Add (SRec.Name);
|
---|
| 108 | R := FindNext (SRec);
|
---|
| 109 | end;
|
---|
| 110 | SkinsListBox.Sorted := true;
|
---|
| 111 | SkinsListBox.ItemIndex := 0;
|
---|
| 112 | end;
|
---|
| 113 |
|
---|
| 114 |
|
---|
| 115 | procedure TSkinForm.FormCreate(Sender: TObject);
|
---|
| 116 | var iniFile : TIniFile;
|
---|
| 117 | begin
|
---|
| 118 | {$IFDEF USE_SKINS}
|
---|
| 119 | SkinManager := TipSkinManager.Create(self);
|
---|
| 120 | {$ENDIF}
|
---|
| 121 | FINIFileName := ExtractFilePath(ParamStr(0)) + 'GUI_Config.ini';
|
---|
| 122 | iniFile := TIniFile.Create(FINIFileName);
|
---|
| 123 | cbSkinAtStartup.Checked := iniFile.ReadBool('Skin','Load At Startup',false);
|
---|
[482] | 124 | CurrentSkinFile := iniFile.ReadString('Skin','Default Skin','SkinStuff\Skins\ICQ_Longhorn_v.1.2.ipz');
|
---|
[476] | 125 | iniFile.Free;
|
---|
| 126 | end;
|
---|
| 127 |
|
---|
| 128 | procedure TSkinForm.FormDestroy(Sender: TObject);
|
---|
| 129 | var iniFile : TIniFile;
|
---|
| 130 | begin
|
---|
| 131 | iniFile := TIniFile.Create(FINIFileName);
|
---|
| 132 | iniFile.WriteString('Skin','Default Skin',CurrentSkinFile);
|
---|
| 133 | iniFile.WriteBool('Skin','Load At Startup',cbSkinAtStartup.Checked);
|
---|
| 134 | iniFile.Free;
|
---|
| 135 | {$IFDEF USE_SKINS}
|
---|
| 136 | SkinManager.Free;
|
---|
| 137 | {$ENDIF}
|
---|
| 138 | end;
|
---|
| 139 |
|
---|
| 140 | procedure TSkinForm.ApplySkinButtonClick(Sender: TObject);
|
---|
| 141 | var fileS : String;
|
---|
| 142 | begin
|
---|
| 143 | fileS := '';
|
---|
| 144 | if SkinsListBox.ItemIndex > -1 then begin
|
---|
| 145 | fileS := SkinsListBox.Items [SkinsListBox.ItemIndex];
|
---|
| 146 | end;
|
---|
| 147 | // if fileS = SKIN_NONE then fileS := '';
|
---|
[482] | 148 | CurrentSkinFile := 'SkinStuff\Skins\' +fileS;
|
---|
[476] | 149 | ModalResult := mrOK;
|
---|
| 150 | end;
|
---|
| 151 |
|
---|
| 152 | procedure TSkinForm.SkinsListBoxDblClick(Sender: TObject);
|
---|
| 153 | begin
|
---|
| 154 | ApplySkinButtonClick (Self);
|
---|
| 155 | end;
|
---|
| 156 |
|
---|
| 157 | procedure TSkinForm.SkinsListBoxKeyPress(Sender: TObject; var Key: Char);
|
---|
| 158 | begin
|
---|
| 159 | if Key = #13 then ApplySkinButtonClick (Self);
|
---|
| 160 | end;
|
---|
| 161 |
|
---|
| 162 | procedure TSkinForm.Button6Click(Sender: TObject);
|
---|
| 163 | begin
|
---|
| 164 | ShellExecute (Handle, 'open', 'http://www2.wincustomize.com/Skins.aspx?LibID=12&view=1&sortby=9&sortdir=DESC&p=1&advanced=0&mode=1&u=0', nil, nil, SW_SHOWNORMAL);
|
---|
| 165 | end;
|
---|
| 166 |
|
---|
| 167 | procedure TSkinForm.ActivateCurrentSkin;
|
---|
| 168 | begin
|
---|
| 169 | {$IFDEF USE_SKINS}
|
---|
[482] | 170 | SkinManager.SkinFile := ExtractFilePath (Application.ExeName) + CurrentSkinFile;
|
---|
| 171 | if FileExists(SkinManager.SkinFile)=false then begin
|
---|
| 172 | SkinManager.SkinFile := '';
|
---|
| 173 | end;
|
---|
| 174 | if SkinManager.SkinFile <>'' then begin
|
---|
[476] | 175 | try
|
---|
| 176 | SkinManager.Active := true;
|
---|
| 177 | except
|
---|
| 178 | on EInvalidOperation do begin
|
---|
| 179 | MessageDlg('Error Applying Skin. Please try another.',mtInformation,[mbOK],0);
|
---|
| 180 | end;
|
---|
| 181 | else begin
|
---|
| 182 | MessageDlg('Error Applying Skin. Please try another.',mtInformation,[mbOK],0);
|
---|
| 183 | end;
|
---|
| 184 | end;
|
---|
| 185 | end else begin
|
---|
| 186 | SkinManager.Active := false;
|
---|
| 187 | end;
|
---|
| 188 | {$ENDIF}
|
---|
| 189 | end;
|
---|
| 190 |
|
---|
| 191 |
|
---|
| 192 | procedure TSkinForm.InactivateSkin;
|
---|
| 193 | begin
|
---|
| 194 | {$IFDEF USE_SKINS}
|
---|
| 195 | SkinManager.Active := false;
|
---|
| 196 | {$ENDIF}
|
---|
| 197 | end;
|
---|
| 198 |
|
---|
| 199 | procedure TSkinForm.FormShow(Sender: TObject);
|
---|
| 200 | begin
|
---|
| 201 | FillSkinList;
|
---|
| 202 | end;
|
---|
| 203 |
|
---|
| 204 | end.
|
---|