Index: cprs/branches/tmg-cprs/CPRS-Chart/fFrame.pas
===================================================================
--- cprs/branches/tmg-cprs/CPRS-Chart/fFrame.pas	(revision 694)
+++ cprs/branches/tmg-cprs/CPRS-Chart/fFrame.pas	(revision 729)
@@ -143,4 +143,5 @@
     DKLanguageController1: TDKLanguageController;
     EditDemographics: TMenuItem;
+    PrintLabels1: TMenuItem;
     procedure tabPageChange(Sender: TObject);
     procedure FormCreate(Sender: TObject);
@@ -231,4 +232,5 @@
       Shift: TShiftState; X, Y: Integer);
     procedure pnlFlagClick(Sender: TObject);
+    procedure mnuViewDemoClick(Sender: TObject);
     procedure mnuFilePrintSelectedItemsClick(Sender: TObject);
     procedure mnuAlertRenewClick(Sender: TObject);
@@ -255,4 +257,5 @@
     procedure tabPageDrawTab(Control: TCustomTabControl; TabIndex: Integer;
       const Rect: TRect; Active: Boolean);
+    procedure PrintLabels1Click(Sender: TObject);
   private
     //kt Begin Mod (change Consts to Vars) 7/17/2007
@@ -324,6 +327,6 @@
     procedure ClearPatient;
     procedure ChangeFont(NewFontSize: Integer);
-    procedure LoadTabColors(INIFile : TIniFile; ColorsList : TStringList);  //kt added 8/8/08
-    procedure SaveTabColors(INIFile : TIniFile; ColorsList : TStringList);
+    procedure LoadTabColors(ColorsList : TStringList);  //kt added 8/8/08
+    procedure SaveTabColors(ColorsList : TStringList);
     //procedure CreateTab(var AnInstance: TObject; AClass: TClass; ATabID: integer; ALabel: string);
     procedure CreateTab(ATabID: integer; ALabel: string);
@@ -407,6 +410,6 @@
   frmFrame: TfrmFrame;
   uTabList: TStringList;
-  uTabColorsList : TStringList;  //kt added 8/8/08
-  uTabColorsEnabled : Boolean;   //kt 8/09
+  TabColorsList : TStringList;  //kt added 8/8/08
+  TabColorsEnabled : Boolean;   //kt 8/09
   uRemoteType : string;
   FlaggedPTList: TStringList;
@@ -440,9 +443,10 @@
   fAlertForward, UBAGlobals, fBAOptionsDiagnoses, UBACore, fOrdersSign, uVitals, fOrdersRenew, uFormMonitor,
   fImages    //kt 8/19/05
+  , uTMGOptions //kt 2/10/10
   {$IFDEF CCOWBROKER}
   , CCOW_const
   {$ENDIF}
   , fPtDemoEdit
-  , fOptionsOther;
+  , fOptionsOther, fPtLabelPrint;
 
 var                                 //  RV 05/11/04
@@ -747,5 +751,4 @@
   tempS : string; //kt
   i : integer;  //kt added 6/29/07
-  CPRSChartINI: TINIFile;  //elh 6/23/08
   tempPosition : TTabPosition; //kt
 begin
@@ -831,8 +834,9 @@
   Application.OnDeActivate := AppDeActivated;
 
+  User := TUser.Create;
+
   // load language ini settings   //elh added
-  CPRSChartINI := TINIFile.Create(ExtractFilePath(ParamStr(0)) + 'CPRSChart.ini');  // Read from INI  elh  6/23/08
-  LangManager.LanguageID := CPRSChartINI.ReadInteger('Options','Language',1033);
-  tempPosition := TTabPosition(CPRSChartINI.ReadInteger('TAB_POSITION','Tab Location',0));
+  LangManager.LanguageID := uTMGOptions.ReadInteger('Language',1033);
+  tempPosition := TTabPosition(uTMGOptions.ReadInteger('Tab Location',0));
   if tempPosition > tpRight then tempPosition := tpBottom;
   fOptionsOther.SetTabPosition(tempPosition);
@@ -841,6 +845,6 @@
   {$ENDIF}
   SkinChanged := false;
-  SkinAtStartup := CPRSChartINI.ReadBool('Skin','Load At Startup',false);
-  CurrentSkinFile := CPRSChartINI.ReadString('Skin','Default Skin','TMG_Extra\Skins\ICQ_Longhorn_v.1.2.ipz');
+  SkinAtStartup := uTMGOptions.ReadBool('Load Skin At Startup',false);
+  CurrentSkinFile := uTMGOptions.ReadString('Default Skin','TMG_Extra\Skins\ICQ_Longhorn_v.1.2.ipz');
   if SkinAtStartup then ActivateCurrentSkin;
   //kt -- end mod --
@@ -851,5 +855,5 @@
   // create initial core objects
   FCreateProgress := FCP_OBJECTS;
-  User := TUser.Create;
+  //User := TUser.Create;  moved elh 2/12/10
 
   // make sure we're using the matching server version
@@ -937,5 +941,5 @@
   RemoteReports := TRemoteReportList.Create;
   uTabList := TStringList.Create;
-  uTabColorsList := TStringList.Create;  //kt added 8/8/08
+  TabColorsList := TStringList.Create;  //kt added 8/8/08
   FlaggedPTList := TStringList.Create;
   HasFlag  := False;
@@ -970,11 +974,15 @@
   //kt original line --> CreateTab(CT_COVER,    'Cover Sheet');
 
+  //kt original line --> CreateTab(CT_IMAGES,   'Images');
+  CreateTab(CT_IMAGES, DKLangConstW('fFrame_Images'));    //kt
+  SetATabVisibility(CT_IMAGES, uTMGOptions.ReadBool('EnableImages',false));
+
   for i := CT_WEBTAB1 to CT_LAST_WEBTAB do begin
     CreateTab(i, IntToStr(i-CT_WEBTAB1+1));  //kt
     SetATabVisibility(i, false); //kt hide until activated by RPC
   end;
-  //kt replace later... CreateTab(CT_IMAGES,   'Images');   //kt  8/19/05
-  LoadTabColors(CPRSChartINI,uTabColorsList);  //kt added 8/8/08
-  TabPage.OwnerDraw := uTabColorsEnabled;
+
+  LoadTabColors(TabColorsList);  //kt added 8/8/08
+  TabPage.OwnerDraw := TabColorsEnabled;
   ShowHideChartTabMenus(mnuViewChart);
   //  We defer calling LoadUserPreferences to UMInitiate, so that the font sizing
@@ -1013,5 +1021,4 @@
 //  if WindowState = wsMinimized then WindowState := wsNormal;
   SetFormMonitoring(true);
-  CPRSChartINI.Free;  //kt added 8/8/08
 end;
 
@@ -1226,7 +1233,4 @@
 procedure TfrmFrame.FormDestroy(Sender: TObject);
 { free core objects used by CPRS }
-var
-  CPRSChartINI: TINIFile;  //kt 8/8/08
-
 begin
   Application.OnActivate := FOldActivate;
@@ -1235,10 +1239,9 @@
   uTabList.Free;
   //kt --- 8/8/08 start mod ---
-  CPRSChartINI := TINIFile.Create(ExtractFilePath(ParamStr(0)) + 'CPRSChart.ini');
-  CPRSChartINI.WriteInteger('Options','Language',LangManager.LanguageID);
-  SaveTabColors(CPRSChartINI,uTabColorsList);
-  uTabColorsList.Free;
-  CPRSChartINI.WriteInteger('TAB_POSITION','Tab Location',integer(tabPage.TabPosition));
-  CPRSChartINI.WriteBool('Skin','Load At Startup',SkinAtStartup);  //kt 9/11/08
+  //kt uTMGOptions.WriteInteger('Language',LangManager.LanguageID);
+  //ktSaveTabColors(TabColorsList);
+  TabColorsList.Free;
+  //kt uTMGOptions.WriteInteger('Tab Location',integer(tabPage.TabPosition));
+  //kt uTMGOptions.WriteBool('Load Skin At Startup',SkinAtStartup);  //kt 9/11/08
   //kt --- end mod ---
 
@@ -1568,6 +1571,9 @@
     //kt -- start addition
     //below taken out 6/29/07 to achieve compile.  Fix later...
-    //if NewForm.Name = frmImages.Name then frmImages.Align := alClient
-    //  else frmImages.Align := alNone;
+    if Assigned (frmImages) and (NewForm.Name = frmImages.Name) then begin
+      frmImages.Align := alClient;
+    end else begin
+      frmImages.Align := alNone;
+    end;
     //kt -- end addition
     NewForm.BringToFront;                    // to cause tab switch to happen immediately
@@ -1591,5 +1597,4 @@
   TabID : integer; //kt added.
 begin
-
   if (not User.IsReportsOnly) then
   begin
@@ -1609,10 +1614,9 @@
       CT_REPORTS:  SwitchToPage(frmReports);
       CT_WEBTAB1..CT_LAST_WEBTAB:  SwitchToPage(frmWebTabs[TabID-CT_WEBTAB1]);  //kt added 8/6/08
-      //kt CT_IMAGES:   SwitchToPage(frmImages);     //kt 8/19/05
+      CT_IMAGES:   SwitchToPage(frmImages);     //kt 8/19/05
     end; {case}
   end
   else // Reports Only tab.
     SwitchToPage(frmReports);
-
 end;
 
@@ -3796,11 +3800,8 @@
                     frmWebTabs[ATabID-CT_WEBTAB1] := TempFrmWebTab
                   end;                                     //kt 6/6/08
-
-    { //kt replace later
-    CT_IMAGES  : begin                                     //kt 8/19/05
-                    frmImages := TfrmImages.Create(Self);  //kt 8/19/05
-                    frmImages.Parent := pnlPage;           //kt 8/19/05
-                  end;                                     //kt 8/19/05
-     }  //kt
+    CT_IMAGES  : begin                                     //kt 8/19/05, 3/8/10
+                    frmImages := TfrmImages.Create(Self);  //kt 8/19/05, 3/8/10
+                    frmImages.Parent := pnlPage;           //kt 8/19/05, 3/8/10
+                  end;                                     //kt 8/19/05, 3/8/10
   else
     Exit;
@@ -3817,20 +3818,36 @@
       tabPage.Tabs.Add(ALabel);
     end;
-  uTabColorsList.Add(IntToStr(ATabID));  //will put colors in later...  //kt
-  {if uTabColorsList.IndexOf(ALabel) < 0 then                    //kt added 8/8/08
-    uTabColorsList.Add(ALabel);  //will put colors in later...  //kt  }
-end;
-
-procedure TfrmFrame.LoadTabColors(INIFile : TIniFile; ColorsList : TStringList);
+  TabColorsList.Add(IntToStr(ATabID));  //will put colors in later...  //kt
+  {if TabColorsList.IndexOf(ALabel) < 0 then                    //kt added 8/8/08
+    TabColorsList.Add(ALabel);  //will put colors in later...  //kt  }
+end;
+
+procedure TfrmFrame.LoadTabColors(ColorsList : TStringList);
 //kt added 8/8/08  Entire function
 var i : integer;
     sValue : string;
     value : longword;
+    DefColor : integer;
+const
+  DEF_COLORS : array[0..11] of integer =
+    (255,
+     33023,
+     16711935,
+     65280,
+     65535,
+     65535,
+     8388736,
+     16776960,
+     16512,
+     65535,
+     65535,
+     65535 );
 begin
   value :=0;
-  uTabColorsEnabled := INIFile.ReadBool('TAB_COLORS','ENABLE',true);
+  TabColorsEnabled := uTMGOptions.ReadBool('TAB_COLORS ENABLE',true);
   for i := 0 to ColorsList.Count-1 do begin
-    //sValue := INIFile.ReadString('TAB_COLORS',ColorsList.Strings[i],IntToStr($00FFFF));
-    sValue := INIFile.ReadString('TAB_COLORS','Tab '+IntToStr(i),IntToStr($00FFFF));
+    if i <= 11 then DefColor := DEF_COLORS[i]
+    else DefColor := ($00FFFF);
+    sValue := uTMGOptions.ReadString('Tab '+IntToStr(i)+' Color',inttostr(DefColor));
     try
       value := StrToInt(sValue)
@@ -3842,13 +3859,12 @@
 end;
 
-procedure TfrmFrame.SaveTabColors(INIFile : TIniFile; ColorsList : TStringList);
+procedure TfrmFrame.SaveTabColors(ColorsList : TStringList);
 //kt added 8/8/08  Entire function
 var i : integer;
 begin
   for i := 0 to ColorsList.Count-1 do begin
-    //INIFile.WriteInteger('TAB_COLORS',ColorsList.Strings[i],longword(ColorsList.Objects[i]));
-    INIFile.WriteInteger('TAB_COLORS','Tab '+IntToStr(i),longword(ColorsList.Objects[i]));
-  end;
-  INIFile.WriteBool('TAB_COLORS','ENABLE',uTabColorsEnabled); //kt 8/09
+    uTMGOptions.WriteInteger('Tab '+IntToStr(i)+' Color',longword(ColorsList.Objects[i]));
+  end;
+  uTMGOptions.WriteBool('TAB_COLORS ENABLE',TabColorsEnabled); //kt 8/09
 end;
 
@@ -4016,5 +4032,6 @@
 procedure TfrmFrame.pnlPatientClick(Sender: TObject);
 begin
-  ViewInfo(mnuViewDemo);
+  //ViewInfo(mnuViewDemo);
+  mnuViewDemoClick(Self);
 end;
 
@@ -4977,18 +4994,18 @@
     color : TColor;
 begin
-  if uTabColorsEnabled then begin
+  if TabColorsEnabled then begin
     ALabel := TTabControl(Control).Tabs[TabIndex];
     {
-    colorIndex := uTabColorsList.IndexOf(ALabel);
+    colorIndex := TabColorsList.IndexOf(ALabel);
     if colorIndex < 0 then color := clYellow
-    else color := TColor(uTabColorsList.Objects[colorIndex]);
+    else color := TColor(TabColorsList.Objects[colorIndex]);
     }
-    color := TColor(uTabColorsList.Objects[TabIndex]);
+    color := TColor(TabColorsList.Objects[TabIndex]);
     DrawTab(Control,TabIndex,Rect,color,Active);
   end else begin
     //this isn't working... This is not what I want.  Fix later...
-    //For now, uTabColorsEnabled should always be TRUE.
+    //For now, TabColorsEnabled should always be TRUE.
     //Control.Canvas.FillRect(Rect);   //elh   we will try to alter the OwnerDraw property here
-    //TabPage.OwnerDraw := uTabColorsEnabled;
+    //TabPage.OwnerDraw := TabColorsEnabled;
   end;
 end;
@@ -5108,5 +5125,26 @@
   end;
 
-  initialization
+procedure TfrmFrame.PrintLabels1Click(Sender: TObject);
+begin
+  if frmPtLabelPrint <> nil then begin
+    frmPtLabelPrint.PrepDialog(Patient);
+    frmPtLabelPrint.ShowModal;
+  end;
+end;
+
+procedure TfrmFrame.mnuViewDemoClick(Sender: TObject);
+{ displays patient inquiry report (which optionally allows new patient to be selected) }
+var
+  SelectNew: Boolean;
+begin
+  StatusText(TX_PTINQ);
+  PatientInquiry(SelectNew);
+  if Assigned(FLastPage) then
+    FLastPage.FocusFirstControl;
+  StatusText('');
+  if SelectNew then mnuFileOpenClick(mnuViewDemo);
+end;
+
+initialization
 
 finalization
