Module

fAutoSz

Path

C:\CPRS\CPRS30\fAutoSz.pas

Last Modified

7/15/2014 3:26:36 PM

Comments

Provides the basic mechanism to resize all the controls on a form when the form size is
  changed.  Differs from frmAResize in that this one descends directly from TForm, rather
  than TPage

Initialization Code

initialization
  SpecifyFormIsNotADialog(TfrmAutoSz);


end.

Units Used in Interface

Name Comments
fBase508Form -

Classes

Name Comments
TfrmAutoSz -
TSizeRatio Records relative sizes and positions for resizing logic

Procedures

Name Owner Declaration Scope Comments
FormDestroy TfrmAutoSz procedure FormDestroy(Sender: TObject); Public/Published Destroy objects used to record size and position information for controls
FormResize TfrmAutoSz procedure FormResize(Sender: TObject); Public/Published Resize child controls using their design time proportions
Loaded TfrmAutoSz procedure Loaded; override; Protected
TfrmAutoSz methods 

 record initial size & position info for resizing logic

Global Variables

Name Type Declaration Comments
frmAutoSz TfrmAutoSz frmAutoSz: TfrmAutoSz; -


Module Source

1     unit fAutoSz;
2     { provides the basic mechanism to resize all the controls on a form when the form size is
3       changed.  Differs from frmAResize in that this one descends directly from TForm, rather
4       than TPage }
5     
6     interface
7     
8     uses
9       Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, fBase508Form,
10      VA508AccessibilityManager;
11    
12    type
13      TfrmAutoSz = class(TfrmBase508Form)
14        procedure FormResize(Sender: TObject);
15        procedure FormDestroy(Sender: TObject);
16      private
17        FSizes: TList;
18        FAutoSizeDisabled: Boolean;
19      protected
20        procedure Loaded; override;
21        property AutoSizeDisabled: Boolean read FAutoSizeDisabled write FAutoSizeDisabled;
22      public
23      end;
24    
25    var
26      frmAutoSz: TfrmAutoSz;
27    
28    implementation
29    
30    {$R *.DFM}
31    
32    uses
33      ORfn, VA508AccessibilityRouter;
34    type
35      TSizeRatio = class         // records relative sizes and positions for resizing logic
36        FControl: TControl;
37        FLeft: Extended;
38        FTop: Extended;
39        FWidth: Extended;
40        FHeight: Extended;
41        constructor Create(AControl: TControl; W, H: Integer);
42      end;
43    
44    { TSizeRatio methods }
45    
46    constructor TSizeRatio.Create(AControl: TControl; W, H: Integer);
47    begin
48      FControl := AControl;
49      with AControl do
50      begin
51        FLeft   := Left   / W;
52        FTop    := Top    / H;
53        FWidth  := Width  / W;
54        FHeight := Height / H;
55      end;
56    end;
57    
58    { TfrmAutoSz methods }
59    
60    procedure TfrmAutoSz.Loaded;
61    { record initial size & position info for resizing logic }
62    var
63      SizeRatio: TSizeRatio;
64      i,W,H: Integer;
65      Control: TControl;
66    begin
67      inherited Loaded;
68      FSizes := TList.Create;
69      if AutoSizeDisabled then Exit;
70      W := ClientWidth;
71      H := ClientHeight;
72      for i := 0 to ComponentCount - 1 do if Components[i] is TControl then
73      begin
74        Control := TControl(Components[i]);
75        W := HigherOf(W, Control.Left + Control.Width);
76        H := HigherOf(H, Control.Top + Control.Height);
77      end;
78      ClientHeight := H;
79      ClientWidth := W;
80      for i := 0 to ComponentCount - 1 do if Components[i] is TControl then
81      begin
82        SizeRatio := TSizeRatio.Create(TControl(Components[i]), W, H);
83        FSizes.Add(SizeRatio);
84      end;
85    end;
86    
87    procedure TfrmAutoSz.FormResize(Sender: TObject);
88    { resize child controls using their design time proportions }
89    var
90      SizeRatio: TSizeRatio;
91      i, W, H: Integer;
92    begin
93      inherited;
94      if AutoSizeDisabled then Exit;
95      W := HigherOf(ClientWidth, HorzScrollBar.Range);
96      H := HigherOf(ClientHeight, VertScrollBar.Range);
97      with FSizes do for i := 0 to Count - 1 do
98      begin
99        SizeRatio := Items[i];
100       with SizeRatio do
101         if ((FControl is TLabel) and TLabel(FControl).AutoSize) or ((FControl is TStaticText) and TStaticText(FControl).AutoSize) then
102         begin
103           FControl.Left := Round(FLeft*W);
104           FControl.Top  := Round(FTop*H);
105         end
106         else FControl.SetBounds(Round(FLeft*W), Round(FTop*H), Round(FWidth*W), Round(FHeight*H));
107     end; {with FSizes}
108   end;
109   
110   procedure TfrmAutoSz.FormDestroy(Sender: TObject);
111   { destroy objects used to record size and position information for controls }
112   var
113     SizeRatio: TSizeRatio;
114     i: Integer;
115   begin
116     inherited;
117     if FSizes <> nil then with FSizes do for i := 0 to Count-1 do
118     begin
119       SizeRatio := Items[i];
120       SizeRatio.Free;
121     end;
122     FSizes.Free;
123   end;
124   
125   initialization
126     SpecifyFormIsNotADialog(TfrmAutoSz);
127   
128   
129   end.

Module Calls (2 levels)


fAutoSz
 └fBase508Form
   ├uConst
   └uHelpManager

Module Called-By (2 levels)


                   fAutoSz
                 fODBase┤ 
               uOrders┤ │ 
               rODBase┤ │ 
               fOrders┤ │ 
                 fMeds┤ │ 
            uSignItems┤ │ 
             fODDietLT┤ │ 
               fODDiet┤ │ 
               fODMisc┤ │ 
                fODGen┤ │ 
              fODMedIn┤ │ 
             fODMedOut┤ │ 
         fODMedComplex┤ │ 
               fODText┤ │ 
            fODConsult┤ │ 
               fODProc┤ │ 
                fODRad┤ │ 
                fODLab┤ │ 
              fODBBank┤ │ 
               fODMeds┤ │ 
              fODMedIV┤ │ 
             fODVitals┤ │ 
               fODAuto┤ │ 
               fOMNavA┤ │ 
       fOrderSaveQuick┤ │ 
                fOMSet┤ │ 
             fODMedNVA┤ │ 
           fOrdersCopy┤ │ 
              fMedCopy┤ │ 
              fODAllgy┘ │ 
                fTimeout┤ 
                 uInit┘ │ 
               fOCAccept┤ 
            fODBase...┤ │ 
          fOrdersRenew┘ │ 
       fBALocalDiagnoses┤ 
            UBAGlobals┤ │ 
           fOrdersSign┤ │ 
               fReview┤ │ 
         fODConsult...┘ │ 
                fPCEBase┤ 
       fEncounterFrame┤ │ 
            fVisitType┤ │ 
            fDiagnoses┤ │ 
          fPCEBaseGrid┤ │ 
            fProcedure┤ │ 
         fImmunization┤ │ 
             fSkinTest┤ │ 
            fPatientEd┤ │ 
         fHealthFactor┤ │ 
                 fExam┤ │ 
            fEncVitals┤ │ 
                  fGAF┘ │ 
               fPCEOther┤ 
          fPCEBaseMain┘ │ 
           fEncVitals...┤ 
          fPrintLocation┤ 
                fFrame┤ │ 
        fOrdersSign...┤ │ 
            fReview...┘ │ 
               fOMAction┤ 
            uOrders...┤ │ 
             fARTAllgy┤ │ 
               fOMHTML┘ │ 
              fPrintList┤ 
                fNotes┤ │ 
             fConsults┤ │ 
               fDCSumm┘ │ 
          fConsult513Prt┤ 
          fConsults...┘ │ 
                 fNoteST┤ 
             fNotes...┘ │ 
             fNoteSTStop┤ 
             CPRSChart┤ │ 
             fNotes...┘ │ 
 fReportsAdhocComponent1┤ 
              fReports┤ │ 
 fReportsAdhocSubItem1┘ │ 
fReportsAdhocSubItem1...┤ 
           fDeviceSelect┤ 
             fFrame...┤ │ 
            uReminders┤ │ 
          fOrdersPrint┘ │ 
                 fPtCWAD┤ 
             fFrame...┤ │ 
              fODAllgy┘ │ 
                  fAbout┤ 
             fFrame...┘ │ 
         fClinicWardMeds┤ 
            fOrders...┤ │ 
        fOrdersRelease┤ │ 
        fOrdersOnChart┘ │ 
                fLabInfo┤ 
             fFrame...┘ │ 
             fIconLegend┤ 
             fFrame...┤ │ 
              fDrawers┤ │ 
         uReminders...┤ │ 
             fNotes...┤ │ 
          fConsults...┤ │ 
            fDCSumm...┤ │ 
       fTemplateEditor┤ │ 
              fSurgery┘ │ 
                fOptions┤ 
             fFrame...┘ │ 
     fBAOptionsDiagnoses┤ 
           fOptions...┘ │ 
            fODDietLT...┤ 
         fOrdersRenew...┤ 
                fOrderVw┤ 
            fOrders...┘ │ 
           fLkUpLocation┤ 
            uOrders...┤ │ 
            fOrders...┤ │ 
             fODRad...┘ │ 
               fOrdersCV┤ 
            fOrders...┘ │ 
                fODMedFA┤ 
           fODMedIn...┤ │ 
          fODMedOut...┘ │ 
        fODMedComplex...┤ 
                fNotePrt┤ 
             fNotes...┤ │ 
          fConsults...┤ │ 
            fDCSumm...┤ │ 
           fSurgery...┘ │ 
                 fNoteDR┤ 
             fNotes...┤ │ 
          fConsults...┤ │ 
            fDCSumm...┤ │ 
           fSurgery...┘ │ 
                fNotesBP┤ 
             fNotes...┤ │ 
          fConsults...┤ │ 
            fDCSumm...┤ │ 
           fSurgery...┘ │ 
          fNoteIDParents┤ 
             fNotes...┤ │ 
          fConsults...┤ │ 
            fDCSumm...┘ │ 
               fEditProc┤ 
          fConsults...┘ │ 
            fEditConsult┤ 
          fConsults...┘ │ 
            fConsMedRslt┤ 
          fConsults...┘ │ 
           fNoteCPFields┤ 
          fConsults...┘ │ 
          fOtherSchedule┤ 
             fFrame...┤ │ 
            fODMeds...┤ │ 
           fODMedIV...┘ │ 
               fIVRoutes┤ 
             fFrame...┤ │ 
           fODMedIV...┘ │ 
             fEffectDate┤ 
            fOrders...┘ │ 
               fOMVerify┤ 
            uOrders...┘ │ 
      fOrderSaveQuick...┤ 
             fOrdersHold┤ 
            fOrders...┤ │ 
              fMeds...┘ │ 
           fOrdersUnhold┤ 
            fOrders...┤ │ 
              fMeds...┘ │ 
            fOrdersAlert┤ 
            fOrders...┘ │ 
              fOrderFlag┤ 
            fOrders...┘ │ 
            fOrderUnflag┤ 
            fOrders...┘ │ 
       fOrdersRelease...┤ 
                fODChild┤ 
            uOrders...┘ │ 
fODChangeUnreleasedRenew┤ 
            uOrders...┘ │ 
       fOrdersOnChart...┤ 
      fOrdersEvntRelease┤ 
            fOrders...┘ │ 
         fOrdersComplete┤ 
            fOrders...┘ │ 
           fOrdersVerify┤ 
            fOrders...┘ │ 
           fOrderComment┤ 
            fOrders...┘ │ 
              fOCSession┤ 
            fOrders...┤ │ 
            fReview...┘ │ 
               fOrdersTS┤ 
            fOrders...┤ │ 
            mEvntDelay┘ │ 
               fODActive┤ 
            fOrders...┘ │ 
     fActivateDeactivate┤ 
            fOrders...┤ │ 
              fMeds...┘ │ 
           fOrdersRefill┤ 
              fMeds...┘ │ 
                 fRename┤ 
    fOrderSaveQuick...┘ │ 
        fODChangeEvtDisp┤ 
          fOrdersCV...┘ │ 
              fDateRange┤ 
       fOrdersRenew...┘ │ 
               fNoteCslt┤ 
                    fvit┤ 
               fVitals┘ │ 
              fAllgyFind┤ 
          fARTAllgy...┤ │ 
              fODAllgy┘ │ 
         fARTFreeTextMsg┤ 
         fAllgyFind...┘ │ 
               fHFSearch┤ 
       fPCEBaseMain...┘ │ 
            fODSaveQuick┤ 
             fOMProgress┘