Index: cprs/trunk/CPRS-Chart/Encounter/fPCEBaseMain.pas
===================================================================
--- cprs/trunk/CPRS-Chart/Encounter/fPCEBaseMain.pas	(revision 456)
+++ cprs/trunk/CPRS-Chart/Encounter/fPCEBaseMain.pas	(revision 829)
@@ -1,3 +1,5 @@
 unit fPCEBaseMain;
+{Warning: The tab order has been changed in the OnExit event of several controls.
+ To change the tab order of lbSection, lbxSection, and btnOther you must do it programatically.}
 
 interface
@@ -6,5 +8,5 @@
   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
   fPCEBaseGrid, ComCtrls, StdCtrls, ORCtrls, ExtCtrls, Buttons, rPCE, uPCE,
-  CheckLst, ORFn;
+  CheckLst, ORFn, VA508AccessibilityManager;
 
 type
@@ -41,8 +43,14 @@
     procedure splLeftMoved(Sender: TObject);
     procedure edtCommentKeyPress(Sender: TObject; var Key: Char);
+    procedure lbSectionExit(Sender: TObject);
+    procedure btnOtherExit(Sender: TObject);
+    procedure lbxSectionExit(Sender: TObject);
+    procedure lbGridExit(Sender: TObject);
+    procedure FormCreate(Sender: TObject);
   private
     FCommentItem: integer;
     FCommentChanged: boolean;
     FUpdateCount: integer;
+    FSectionPopulated: boolean;
     //FUpdatingGrid: boolean;  moved to 'protected' so frmDiagnoses can see it  (RV)
   protected
@@ -77,7 +85,15 @@
 implementation
 
-uses fPCELex, fPCEOther, fEncounterFrame, fHFSearch;
+uses fPCELex, fPCEOther, fEncounterFrame, fHFSearch, VA508AccessibilityRouter,
+  ORCtrlsVA508Compatibility, fBase508Form;
 
 {$R *.DFM}
+
+type
+  TLBSectionManager = class(TORListBox508Manager)
+  public
+    function GetItemInstructions(Component: TWinControl): string; override;
+    function GetState(Component: TWinControl): string; override;    
+  end;
 
 procedure TfrmPCEBaseMain.lbSectionClick(Sender: TObject);
@@ -87,4 +103,13 @@
   FPCEListCodesProc(lbxSection.Items, lbSection.ItemIEN);
   CheckOffEntries;
+  FSectionPopulated := TRUE;
+end;
+
+procedure TfrmPCEBaseMain.lbSectionExit(Sender: TObject);
+begin
+  inherited;
+  if TabIsPressed then
+    if lbxSection.CanFocus then
+      lbxSection.SetFocus;
 end;
 
@@ -102,5 +127,5 @@
   try
     SaveGridSelected;
-    tmpList.Assign(lbGrid.Items);
+    FastAssign(lbGrid.Items, tmpList);
     for i := 0 to lbGrid.Items.Count-1 do
     begin
@@ -109,5 +134,6 @@
       tmpList.Objects[i] := lbGrid.Items.Objects[i];
     end;
-    lbGrid.Items.Assign(tmpList);
+  //FastAssign(tmpList,lbGrid.Items); //cq: 13228  Causin a/v errors.
+    lbGrid.Items.Assign(tmpList);    //cq: 13228
     RestoreGridSelected;
     SyncGridData;
@@ -155,4 +181,16 @@
 end;
 
+procedure TfrmPCEBaseMain.btnOtherExit(Sender: TObject);
+begin
+  inherited;
+  if TabIsPressed then begin
+    if lbGrid.CanFocus then
+      lbGrid.SetFocus
+  end
+  else if ShiftTabIsPressed then
+    if lbxSection.CanFocus then
+      lbxSection.SetFocus;
+end;
+
 procedure TfrmPCEBaseMain.edtCommentExit(Sender: TObject);
 begin
@@ -240,4 +278,12 @@
 end;
 
+procedure TfrmPCEBaseMain.lbGridExit(Sender: TObject);
+begin
+  inherited;
+  if ShiftTabIsPressed then
+    if btnOther.CanFocus then
+      btnOther.SetFocus;
+end;
+
 procedure TfrmPCEBaseMain.lbGridSelect(Sender: TObject);
 begin
@@ -245,4 +291,11 @@
 //  clbList.ItemIndex := -1;
   UpdateControls;
+end;
+
+procedure TfrmPCEBaseMain.FormCreate(Sender: TObject);
+begin
+  inherited FormCreate(Sender);
+  lbxSection.HideSelection := TRUE;
+  amgrMain.ComponentManager[lbSection] := TLBSectionManager.Create;
 end;
 
@@ -413,4 +466,16 @@
 end;
 
+procedure TfrmPCEBaseMain.lbxSectionExit(Sender: TObject);
+begin
+  inherited;
+  if TabIsPressed then begin
+    if btnOther.CanFocus then
+      btnOther.SetFocus
+  end
+  else if ShiftTabIsPressed then
+    if lbSection.CanFocus then
+      lbSection.SetFocus;
+end;
+
 procedure TfrmPCEBaseMain.UpdateTabPos;
 begin
@@ -503,3 +568,36 @@
 end;
 
+{ TLBSectionManager }
+
+function TLBSectionManager.GetItemInstructions(Component: TWinControl): string;
+var
+  lb : TORListBox;
+  idx: integer;
+begin
+  lb := TORListBox(Component);
+  idx := lb.ItemIndex;
+  if (idx >= 0) and lb.Selected[idx] then
+    Result := 'Press space bar to populate ' +
+        TfrmPCEBaseMain(Component.Owner).FTabName + ' section'
+  else
+    result := inherited GetItemInstructions(Component);
+end;
+
+function TLBSectionManager.GetState(Component: TWinControl): string;
+var
+  frm: TfrmPCEBaseMain;
+begin
+  Result := '';
+  frm := TfrmPCEBaseMain(Component.Owner);
+  if frm.FSectionPopulated then
+  begin
+    frm.FSectionPopulated := FALSE;
+    Result := frm.FTabName + ' section populated with ' +
+        inttostr(frm.lbxSection.Count) + ' items';
+  end;
+end;
+
+initialization
+  SpecifyFormIsNotADialog(TfrmPCEBaseMain);
+
 end.
