Index: cprs/trunk/CPRS-Lib/ORCtrls.pas
===================================================================
--- cprs/trunk/CPRS-Lib/ORCtrls.pas	(revision 456)
+++ cprs/trunk/CPRS-Lib/ORCtrls.pas	(revision 829)
@@ -7,5 +7,5 @@
 uses Windows, Messages, SysUtils, Classes, Graphics, Controls, StdCtrls, Forms,
      ComCtrls, Commctrl, Buttons, ExtCtrls, Grids, ImgList, Menus, CheckLst,
-     Accessibility_TLB, Variants;
+     Variants, VAClasses;
 
 const
@@ -21,14 +21,7 @@
 
 type
-
-  TORStaticText = class(TStaticText)
-  private
-     FOnEnter: TNotifyEvent;
-     FOnExit: TNotifyEvent;
-  published
-     property OnEnter: TNotifyEvent read FOnEnter write FOnEnter;
-     property OnExit: TNotifyEvent read FOnExit write FOnExit;
-     procedure DoEnter; override;
-     procedure DoExit; override;
+  IORBlackColorModeCompatible = interface(IInterface)
+  ['{3554985C-F524-45FA-8C27-4CDD8357DB08}']
+    procedure SetBlackColorMode(Value: boolean);
   end;
 
@@ -81,5 +74,5 @@
   end;
 
-  TORListBox = class(TListBox)
+  TORListBox = class(TListBox, IVADynamicProperty, IORBlackColorModeCompatible)
   private
     FFocusIndex: Integer;                        // item with focus when using navigation keys
@@ -127,8 +120,9 @@
     FMItems: TORStrings;                         // Used to save corresponding M strings ("the pieces")
     FCaption: TStaticText;                       // Used to supply a title to IAccessible interface
-    FAccessible: IAccessible;
     FCaseChanged: boolean;                       // If true, the names are stored in the database as all caps, but loaded and displayed in mixed-case
     FLookupPiece: integer;                       // If zero, list look-up comes from display string; if non-zero, indicates which piece of the item needs to be used for list lookup
-    procedure WMGetObject(var Message: TMessage); message WM_GETOBJECT;
+    FIsPartOfComboBox: boolean;
+    FBlackColorMode: boolean;
+    FHideSelection: boolean;
     procedure AdjustScrollBar;
     procedure CreateScrollBar;
@@ -214,4 +208,5 @@
     procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState); override;
     function GetIndexFromY(YPos :integer) :integer;
+    property isPartOfComboBox: boolean read FIsPartOfComboBox write FIsPartOfComboBox default False;
     property HideSynonyms: boolean read FHideSynonyms write SetHideSynonyms default FALSE;
     property SynonymChars: string read FSynonymChars write SetSynonymChars;
@@ -241,6 +236,9 @@
     property CheckedState[Index: Integer]: TCheckBoxState read GetCheckedState write SetCheckedState;
     property MItems: TStrings read GetMItems write SetMItems;
-    procedure MakeAccessible(Accessible: IAccessible);
     function VerifyUnique(SelectIndex: Integer; iText: String): integer;
+    procedure SetBlackColorMode(Value: boolean);
+    function SupportsDynamicProperty(PropertyID: integer): boolean;
+    function GetDynamicProperty(PropertyID: integer): string;
+    property HideSelection: boolean read FHideSelection write FHideSelection;
   published
     property AllowGrayed: boolean read FAllowGrayed write FAllowGrayed default FALSE;
@@ -303,5 +301,5 @@
   end;
 
-  TORComboBox = class(TWinControl)
+  TORComboBox = class(TWinControl, IVADynamicProperty, IORBlackColorModeCompatible)
   private
     FItems: TStrings;                            // points to Items in FListBox
@@ -340,4 +338,9 @@
     FCharsNeedMatch: integer;                    // how many text need to be matched for auto selection
     FUniqueAutoComplete: Boolean;                // If true only perform autocomplete for unique list items.
+    FBlackColorMode: boolean;
+    FDisableHints: boolean;                      // true if hints have been disabled because drop down window was opened
+    FDropDownStatusChangedCount: integer;        // prevents multiple calls to disabling hint window
+    procedure DropDownStatusChanged(opened: boolean);
+    procedure ClearDropDownStatus;
     function EditControl: TWinControl;
     procedure AdjustSizeOfSelf;
@@ -440,4 +443,5 @@
     procedure SetLookupPiece(const Value: integer);
     procedure SetUniqueAutoComplete(const Value: Boolean);
+    procedure LoadComboBoxImage;
   protected
     procedure DropPanelBtnPressed(OKBtn, AutoClose: boolean);
@@ -452,4 +456,5 @@
   public
     constructor Create(AOwner: TComponent); override;
+    destructor Destroy; override;
     function AddReference(const S: string; AReference: Variant): Integer;
     procedure Clear;
@@ -458,4 +463,5 @@
     procedure InitLongList(S: string);
     procedure InsertSeparator;
+    procedure Invalidate; override;
     procedure SetTextAutoComplete(TextToMatch : String);
     function GetIEN(AnIndex: Integer): Int64;
@@ -466,5 +472,7 @@
     procedure InsertReference(Index: Integer; const S: string; AReference: Variant);
     procedure SelectAll;
-    function MakeAccessible( Accessible: IAccessible): TORListBox;
+    procedure SetBlackColorMode(Value: boolean);
+    function SupportsDynamicProperty(PropertyID: integer): boolean;
+    function GetDynamicProperty(PropertyID: integer): string;
     property DisplayText[Index: Integer]: string read GetDisplayText;
     property DroppedDown: Boolean read FDroppedDown write SetDroppedDown;
@@ -648,5 +656,5 @@
 
 
-  TCaptionTreeView = class(TTreeView)
+  TCaptionTreeView = class(TTreeView, IVADynamicProperty)
   private
     procedure SetCaption(const Value: string);
@@ -654,4 +662,7 @@
   protected
     FCaptionComponent: TStaticText;
+  public
+    function SupportsDynamicProperty(PropertyID: integer): boolean;
+    function GetDynamicProperty(PropertyID: integer): string;
   published
     property Align;
@@ -665,7 +676,5 @@
     FTag: integer;
     FStringData: string;
-    FAccessible: IAccessible;
     FCaption: string;
-    procedure WMGetObject(var Message: TMessage); message WM_GETOBJECT;
     function GetParent: TORTreeNode;
     procedure SetCaption(const Value: string);
@@ -679,8 +688,6 @@
     function GetORTreeView: TORTreeView;
   public
-    procedure MakeAccessible(Accessible: IAccessible);
     procedure SetPiece(PieceNum: Integer; const NewPiece: string);
     procedure EnsureVisible;
-    property Accessible: IAccessible read FAccessible write MakeAccessible;
     property Bold: boolean read GetBold write SetBold;
     property Tag: integer read FTag write FTag;
@@ -700,8 +707,6 @@
     FPiece: integer;
     FOnAddition: TTVExpandedEvent;
-    FAccessible: IAccessible;
     FShortNodeCaptions: boolean;
     FOnNodeCaptioning: TNodeCaptioningEvent;
-    procedure WMGetObject(var Message: TMessage); message WM_GETOBJECT;
     procedure SetShortNodeCaptions(const Value: boolean);
   protected
@@ -716,5 +721,4 @@
   public
     constructor Create(AOwner: TComponent); override;
-    procedure MakeAccessible(Accessible: IAccessible);
     function FindPieceNode(Value: string;
                            ParentDelim: Char = #0; StartNode: TTreeNode = nil): TORTreeNode; overload;
@@ -776,5 +780,5 @@
   TGrayedStyle = (gsNormal, gsQuestionMark, gsBlueQuestionMark);
 
-  TORCheckBox = class(TCheckBox)
+  TORCheckBox = class(TCheckBox, IORBlackColorModeCompatible)
   private
     FStringData: string;
@@ -793,4 +797,5 @@
     FAssociate: TControl;
     FFocusOnBox: boolean;
+    FBlackColorMode: boolean;
     procedure SetFocusOnBox(value: boolean);
     procedure CNMeasureItem    (var Message: TWMMeasureItem);   message CN_MEASUREITEM;
@@ -835,4 +840,5 @@
     destructor Destroy; override;
     procedure AutoAdjustSize;
+    procedure SetBlackColorMode(Value: boolean);
     property SingleLine: boolean read FSingleLine;
     property StringData: string read FStringData write FStringData;
@@ -899,20 +905,22 @@
   end;
 
-  TCaptionListBox = class(TListBox)
+  TCaptionListBox = class(TListBox, IVADynamicProperty)
   private
     FHoverItemPos: integer;
-    FAccessible: IAccessible;
     FRightClickSelect: boolean;                  // When true, a right click selects teh item
     FHintOnItem: boolean;
     procedure SetCaption(const Value: string);
     function GetCaption: string;
-    procedure WMGetObject(var Message: TMessage); message WM_GETOBJECT;
     procedure WMRButtonUp(var Message: TWMRButtonUp); message WM_RBUTTONUP;
     procedure WMMouseMove(var Message: TWMMouseMove); message WM_MOUSEMOVE;
+    procedure WMKeyDown(var Message: TWMKeyDown); message WM_KEYDOWN;
+    procedure MoveFocusDown;
+    procedure MoveFocusUp;
   protected
     FCaptionComponent: TStaticText;
     procedure DoEnter; override;
   public
-    procedure MakeAccessible( Accessible: IAccessible);
+    function SupportsDynamicProperty(PropertyID: integer): boolean;
+    function GetDynamicProperty(PropertyID: integer): string;
   published
     property RightClickSelect: boolean read FRightClickSelect write FRightClickSelect default FALSE;
@@ -922,5 +930,5 @@
   end;
 
-  TCaptionCheckListBox = class(TCheckListBox)
+  TCaptionCheckListBox = class(TCheckListBox, IVADynamicProperty)
   private
     procedure SetCaption(const Value: string);
@@ -928,9 +936,12 @@
   protected
     FCaptionComponent: TStaticText;
+  public
+    function SupportsDynamicProperty(PropertyID: integer): boolean;
+    function GetDynamicProperty(PropertyID: integer): string;
   published
     property Caption: string read GetCaption write SetCaption;
   end;
 
-  TCaptionMemo = class(TMemo)
+  TCaptionMemo = class(TMemo, IVADynamicProperty)
   private
     procedure SetCaption(const Value: string);
@@ -938,9 +949,12 @@
   protected
     FCaptionComponent: TStaticText;
+  public
+    function SupportsDynamicProperty(PropertyID: integer): boolean;
+    function GetDynamicProperty(PropertyID: integer): string;
   published
     property Caption: string read GetCaption write SetCaption;
   end;
 
-  TCaptionEdit = class(TEdit)
+  TCaptionEdit = class(TEdit, IVADynamicProperty)
   private
     procedure SetCaption(const Value: string);
@@ -948,4 +962,7 @@
   protected
     FCaptionComponent: TStaticText;
+  public
+    function SupportsDynamicProperty(PropertyID: integer): boolean;
+    function GetDynamicProperty(PropertyID: integer): string;
   published
     property Align;
@@ -953,12 +970,11 @@
   end;
 
-  TCaptionRichEdit = class(TRichEdit)
+  TCaptionRichEdit = class(TRichEdit, IVADynamicProperty)
   private
-    FAccessible: IAccessible;
-    procedure WMGetObject(var Message: TMessage); message WM_GETOBJECT;
   protected
     FCaption: string;
   public
-    procedure MakeAccessible(Accessible: IAccessible);
+    function SupportsDynamicProperty(PropertyID: integer): boolean;
+    function GetDynamicProperty(PropertyID: integer): string;
   published
     property Align;
@@ -966,5 +982,5 @@
   end;
 
-  TCaptionComboBox = class(TComboBox)
+  TCaptionComboBox = class(TComboBox, IVADynamicProperty)
   private
     procedure SetCaption(const Value: string);
@@ -972,25 +988,30 @@
   protected
     FCaptionComponent: TStaticText;
+  public
+    function SupportsDynamicProperty(PropertyID: integer): boolean;
+    function GetDynamicProperty(PropertyID: integer): string;
   published
     property Caption: string read GetCaption write SetCaption;
   end;
 
-  TCaptionListView = class(TListView)
+  TCaptionListView = class(TListView, IVADynamicProperty)
+  public
+    function SupportsDynamicProperty(PropertyID: integer): boolean;
+    function GetDynamicProperty(PropertyID: integer): string;
   published
     property Caption;
   end;
 
-  TCaptionStringGrid = class(TStringGrid)
+  TCaptionStringGrid = class(TStringGrid, IVADynamicProperty)
   private
     FJustToTab: boolean;
     FCaption: string;
-    FAccessible: IAccessible;
-    procedure WMGetObject(var Message: TMessage); message WM_GETOBJECT;
   protected
     procedure KeyUp(var Key: Word; Shift: TShiftState); override;
   public
-    procedure MakeAccessible( Accessible: IAccessible);
     procedure IndexToColRow( index: integer; var Col: integer; var Row: integer);
     function ColRowToIndex( Col: integer; Row: Integer): integer;
+    function SupportsDynamicProperty(PropertyID: integer): boolean;
+    function GetDynamicProperty(PropertyID: integer): string;
   published
     property Caption: string read FCaption write FCaption;
@@ -1015,5 +1036,5 @@
 
 uses
-  uAccessAPI;
+  VAUtils;
   
 const
@@ -1424,15 +1445,30 @@
     'ORCB_RADIO_DISABLED_UNCHECKED', 'ORCB_RADIO_DISABLED_CHECKED');
 
-var
-  ORCBImages: array[TORCBImgIdx] of TBitMap;
-
-function GetORCBBitmap(Idx: TORCBImgIdx): TBitmap;
-begin
-  if(not assigned(ORCBImages[Idx])) then
-  begin
-    ORCBImages[Idx] := TBitMap.Create;
-    ORCBImages[Idx].LoadFromResourceName(HInstance, CheckBoxImageResNames[Idx]);
-  end;
-  Result := ORCBImages[Idx];
+   BlackCheckBoxImageResNames: array[TORCBImgIdx] of PChar = (
+    'BLACK_ORLB_FLAT_UNCHECKED', 'BLACK_ORLB_FLAT_CHECKED', 'BLACK_ORLB_FLAT_GRAYED',
+    'BLACK_ORCB_QUESTIONMARK', 'BLACK_ORCB_BLUEQUESTIONMARK',
+    'BLACK_ORCB_DISABLED_UNCHECKED', 'BLACK_ORCB_DISABLED_CHECKED',
+    'BLACK_ORCB_DISABLED_GRAYED', 'BLACK_ORCB_DISABLED_QUESTIONMARK',
+    'BLACK_ORLB_FLAT_UNCHECKED', 'BLACK_ORLB_FLAT_CHECKED', 'BLACK_ORLB_FLAT_GRAYED',
+    'BLACK_ORCB_RADIO_UNCHECKED', 'BLACK_ORCB_RADIO_CHECKED',
+    'BLACK_ORCB_RADIO_DISABLED_UNCHECKED', 'BLACK_ORCB_RADIO_DISABLED_CHECKED');
+  
+var
+  ORCBImages: array[TORCBImgIdx, Boolean] of TBitMap;
+
+function GetORCBBitmap(Idx: TORCBImgIdx; BlackMode: boolean): TBitmap;
+var
+  ResName: string;
+begin
+  if(not assigned(ORCBImages[Idx, BlackMode])) then
+  begin
+    ORCBImages[Idx, BlackMode] := TBitMap.Create;
+    if BlackMode then
+      ResName := BlackCheckBoxImageResNames[Idx]
+    else
+      ResName := CheckBoxImageResNames[Idx];
+    ORCBImages[Idx, BlackMode].LoadFromResourceName(HInstance, ResName);
+  end;
+  Result := ORCBImages[Idx, BlackMode];
 end;
 
@@ -1440,27 +1476,15 @@
 var
   i: TORCBImgIdx;
+  mode: boolean;
 
 begin
   for i := low(TORCBImgIdx) to high(TORCBImgIdx) do
   begin
-    if(assigned(ORCBImages[i])) then
-      ORCBImages[i].Free;
-  end;
-end;
-
-{ TORStaticText }
-
-procedure TORStaticText.DoEnter;
-begin
-  inherited DoEnter;
-  if Assigned(FOnEnter) then
-     FOnEnter(Self);
-end;
-
-procedure TORStaticText.DoExit;
-begin
-  inherited DoExit;
-  if Assigned(FOnExit) then
-     FOnExit(Self);
+    for Mode := false to true do
+    begin
+      if(assigned(ORCBImages[i, Mode])) then
+        ORCBImages[i, Mode].Free;
+    end;
+  end;
 end;
 
@@ -1658,4 +1682,5 @@
   FCaseChanged := TRUE;
   FLookupPiece := 0;
+  FIsPartOfComboBox := False;
 end;
 
@@ -1768,4 +1793,12 @@
     SetString(Result, Buf, Len);
   end;
+end;
+
+function TORListBox.GetDynamicProperty(PropertyID: integer): string;
+begin
+  if PropertyID = DynaPropAccesibilityCaption then
+    Result := GetCaption
+  else
+    Result := '';
 end;
 
@@ -2016,23 +2049,27 @@
   case Message.CharCode of
     VK_LBUTTON, VK_RETURN, VK_SPACE:
-    if FocusIndex > -1 then
-    begin
-      if MultiSelect then
+    begin
+      if (FocusIndex < 0) and (CheckBoxes or MultiSelect) and (Count > 0) then // JNM - 508 compliance
+        SetFocusIndex(0);
+      if FocusIndex > -1 then
       begin
-        IsSelected := LongBool(Perform(LB_GETSEL, FocusIndex, 0));
-        Perform(LB_SETSEL, Longint(not IsSelected), FocusIndex);
-      end
-      else Perform(LB_SETCURSEL, FocusIndex, 0);
-      // Send WM_COMMAND here because LBN_SELCHANGE not triggered by LB_SETSEL
-      // and LBN_SELCHANGE is what eventually triggers the Click event.
-      // The LBN_SELCHANGE documentation implies we should send the control id, which is
-      // 32 bits long, in the high word of WPARAM (16 bits).  Since that won't work - we'll
-      // try sending the item index instead.
-      //PostMessage() not SendMessage() is Required here for checkboxes, SendMessage() doesn't
-      //Allow the Checkbox state on the control to be updated
-      if CheckBoxes then
-        PostMessage(Parent.Handle, WM_COMMAND, MAKELONG(FocusIndex, LBN_SELCHANGE), LPARAM(Handle))
-      else
-        SendMessage(Parent.Handle, WM_COMMAND, MAKELONG(FocusIndex, LBN_SELCHANGE), LPARAM(Handle));
+        if MultiSelect then
+        begin
+          IsSelected := LongBool(Perform(LB_GETSEL, FocusIndex, 0));
+          Perform(LB_SETSEL, Longint(not IsSelected), FocusIndex);
+        end
+        else Perform(LB_SETCURSEL, FocusIndex, 0);
+        // Send WM_COMMAND here because LBN_SELCHANGE not triggered by LB_SETSEL
+        // and LBN_SELCHANGE is what eventually triggers the Click event.
+        // The LBN_SELCHANGE documentation implies we should send the control id, which is
+        // 32 bits long, in the high word of WPARAM (16 bits).  Since that won't work - we'll
+        // try sending the item index instead.
+        //PostMessage() not SendMessage() is Required here for checkboxes, SendMessage() doesn't
+        //Allow the Checkbox state on the control to be updated
+        if CheckBoxes then
+          PostMessage(Parent.Handle, WM_COMMAND, MAKELONG(FocusIndex, LBN_SELCHANGE), LPARAM(Handle))
+        else
+          SendMessage(Parent.Handle, WM_COMMAND, MAKELONG(FocusIndex, LBN_SELCHANGE), LPARAM(Handle));
+      end;
     end;
     VK_PRIOR:          SetFocusIndex(FocusIndex - FLargeChange);
@@ -2236,4 +2273,6 @@
   begin
     FLastItemIndex := ItemIndex;
+    if (not isPartOfComboBox) and (ItemIndex <> -1) then
+      SetFocusIndex(ItemIndex);
     if Assigned(FOnChange) then FOnChange(Self);
   end;
@@ -2248,10 +2287,21 @@
 {  if (Items.Count > 0) and (Not IsAMouseButtonDown()) and (ItemIndex = -1) then
     SetFocusIndex(TopIndex);//ItemIndex := TopIndex; }
+  if FHideSelection and (ItemIndex < 0) and (FFocusIndex >= 0) then
+    ItemIndex := FFocusIndex;
   inherited DoEnter;
 end;
 
 procedure TORListBox.DoExit;
+var
+  SaveIndex: integer;
 { make sure item tip is hidden for this listbox when focus shifts to something else }
 begin
+  if FHideSelection then
+  begin
+    SaveIndex := ItemIndex;
+    ItemIndex := -1;
+    FFocusIndex := SaveIndex;
+  end;
+
   uItemTip.Hide;
   FItemTipActive := False;
@@ -2321,6 +2371,12 @@
 procedure TORListBox.KeyPress(var Key: Char);
 begin
+  {inherited KeyPress is changing the ' ' into #0, had to move conditional before inherited.}
+  if (Key = ' ') then begin
+    ToggleCheckBox(ItemIndex);
+    {The space bar causes the focus to jump to an item in the list that starts with
+     a space. Disable that function.}
+    Key := #0;
+  end;
   inherited;
-  if (Key = ' ') then ToggleCheckBox(ItemIndex);
 end;
 
@@ -2459,21 +2515,21 @@
               begin
                 if(FFlatCheckBoxes) then
-                  BMap := GetORCBBitmap(iiFlatUnChecked)
+                  BMap := GetORCBBitmap(iiFlatUnChecked, FBlackColorMode)
                 else
-                  BMap := GetORCBBitmap(iiUnchecked);
+                  BMap := GetORCBBitmap(iiUnchecked, FBlackColorMode);
               end;
             cbChecked:
               begin
                 if(FFlatCheckBoxes) then
-                  BMap := GetORCBBitmap(iiFlatChecked)
+                  BMap := GetORCBBitmap(iiFlatChecked, FBlackColorMode)
                 else
-                  BMap := GetORCBBitmap(iiChecked);
+                  BMap := GetORCBBitmap(iiChecked, FBlackColorMode);
               end;
             else // cbGrayed:
               begin
                 if(FFlatCheckBoxes) then
-                  BMap := GetORCBBitmap(iiFlatGrayed)
+                  BMap := GetORCBBitmap(iiFlatGrayed, FBlackColorMode)
                 else
-                  BMap := GetORCBBitmap(iiGrayed);
+                  BMap := GetORCBBitmap(iiGrayed, FBlackColorMode);
               end;
           end;
@@ -2482,7 +2538,7 @@
         begin
           if(FFlatCheckBoxes) then
-            BMap := GetORCBBitmap(iiFlatGrayed)
+            BMap := GetORCBBitmap(iiFlatGrayed, FBlackColorMode)
           else
-            BMap := GetORCBBitmap(iiGrayed);
+            BMap := GetORCBBitmap(iiGrayed, FBlackColorMode);
         end;
         TmpR := Rect;
@@ -2584,8 +2640,9 @@
     end;
   end;                                              // -- special long list processing - end
+  if (Value = SFI_END) or (not (Value < Items.Count)) then Value := Items.Count - 1;
   if (Value = SFI_TOP) or (Value < 0) then Value := 0;
-  if (Value = SFI_END) or (not (Value < Items.Count)) then Value := Items.Count - 1;
   FFocusIndex := Value;
-  ItemIndex := Value;
+  if Focused or (not FHideSelection) then
+    ItemIndex := Value;
   if MultiSelect then Perform(LB_SETCARETINDEX, FFocusIndex, 0) // LPARAM=0, scrolls into view
   else
@@ -2850,4 +2907,9 @@
 end;
 
+function TORListBox.SupportsDynamicProperty(PropertyID: integer): boolean;
+begin
+  Result := (PropertyID = DynaPropAccesibilityCaption);
+end;
+
 procedure TORListBox.SetHideSynonyms(Value :boolean);
 var
@@ -2930,5 +2992,5 @@
   Strings: TStringList;
   i, Pos: Integer;
-  ItemRec: PItemRec;
+  ItemRec, ItemRec2: PItemRec;
   SaveListMode: Boolean;
   RealVerify: Boolean;
@@ -2960,5 +3022,13 @@
       begin
         Pos := Items.AddObject(Strings[i], ItemRec^.UserObject);
-        References[Pos] := ItemRec^.Reference;
+        // CQ 11491 - Changing TabPositions, etc. was wiping out check box status.
+        FFromSelf := True;
+        ItemRec2 := PItemRec(SendMessage(Handle,LB_GETITEMDATA, Pos, 0));
+        FFromSelf := False;
+        if(assigned(ItemRec2)) then
+        begin
+          ItemRec2^.Reference := ItemRec^.Reference;
+          ItemRec2^.CheckedState := ItemRec^.CheckedState;
+        end;
       end;
     end;
@@ -3505,4 +3575,9 @@
 end;
 
+procedure TORListBox.SetBlackColorMode(Value: boolean);
+begin
+  FBlackColorMode := Value;
+end;
+
 procedure TORListBox.SetCaption(const Value: string);
 begin
@@ -3527,18 +3602,29 @@
 end;
 
-procedure TORListBox.MakeAccessible(Accessible: IAccessible);
-begin
-  if Assigned(FAccessible) and Assigned(Accessible) then
-    raise Exception.Create(Caption + ' List Box is already Accessible!')
-  else
-    FAccessible := Accessible;
-end;
-
-procedure TORListBox.WMGetObject(var Message: TMessage);
-begin
-  if (Message.LParam = integer(OBJID_CLIENT)) and Assigned(FAccessible) then
-    Message.Result := GetLResult(Message.wParam, FAccessible)
-  else
-    inherited;
+// In Delphi 2006, hint windows will cause the TORComboBox drop down list to
+// move behind a Stay on Top form.  Hints are also problematic with item tips in
+// the drop down list, so we disable them when ever a drop down list is open,
+// on all forms, not just stay on top forms.
+var
+  uDropPanelOpenCount: integer = 0;
+  uOldShowHintsSetting: boolean;
+
+procedure DropDownPanelOpened;
+begin
+  if uDropPanelOpenCount=0 then
+    uOldShowHintsSetting := Application.ShowHint;
+  Application.ShowHint := FALSE;
+  inc(uDropPanelOpenCount);
+end;
+
+procedure DropDownPanelClosed;
+begin
+  dec(uDropPanelOpenCount);
+  if uDropPanelOpenCount<=0 then
+  begin
+    uDropPanelOpenCount := 0;
+    if not Application.ShowHint then
+      Application.ShowHint := uOldShowHintsSetting
+  end;
 end;
 
@@ -3690,5 +3776,6 @@
 const
   ComboBoxImages: array[boolean] of string = ('BMP_CBODOWN_DISABLED', 'BMP_CBODOWN');
-  
+  BlackComboBoxImages: array[boolean] of string = ('BLACK_BMP_CBODOWN_DISABLED', 'BLACK_BMP_CBODOWN');
+
 procedure TORComboEdit.CreateParams(var Params: TCreateParams);
 { sets a one line edit box to multiline style so the editing rectangle can be changed }
@@ -3740,4 +3827,5 @@
   FCheckBoxEditColor := clBtnFace;
   FListBox := TORListBox.Create(Self);
+  FListBox.isPartOfComboBox := True;
   FListBox.Parent := Self;
   FListBox.TabStop := False;
@@ -3866,4 +3954,45 @@
 end;
 
+procedure TORComboBox.DropDownStatusChanged(opened: boolean);
+begin
+  if opened then
+  begin
+    if not FDropPanel.Visible then
+    begin
+      if FDropDownStatusChangedCount = 0 then
+      begin
+        FDisableHints := TRUE;
+        DropDownPanelOpened;
+      end;
+      inc(FDropDownStatusChangedCount);
+    end;
+  end
+  else
+  begin
+    dec(FDropDownStatusChangedCount);
+    if FDropDownStatusChangedCount <= 0 then
+    begin
+      if FDisableHints then
+      begin
+        DropDownPanelClosed;
+        FDisableHints := FALSE;
+      end;
+      FDropDownStatusChangedCount := 0;
+    end;
+  end;
+end;
+
+procedure TORComboBox.ClearDropDownStatus;
+begin
+  FDropDownStatusChangedCount := 1;
+  DropDownStatusChanged(FALSE);
+end;
+
+destructor TORComboBox.Destroy;
+begin
+  ClearDropDownStatus;
+  inherited;
+end;
+
 procedure TORComboBox.DoEnter;
 {var
@@ -3902,4 +4031,18 @@
   end;
   inherited DoExit;
+end;
+
+procedure TORComboBox.LoadComboBoxImage;
+var
+  imageName: string;
+begin
+  if assigned(FDropBtn) then
+  begin
+    if FBlackColorMode then
+      imageName := BlackComboBoxImages[inherited Enabled]
+    else
+      imageName := ComboBoxImages[inherited Enabled];
+    FDropBtn.Glyph.LoadFromResourceName(hInstance, imageName);
+  end;
 end;
 
@@ -4098,13 +4241,24 @@
 
 procedure TORComboBox.FwdKeyPress(Sender: TObject; var Key: Char);
+var
+  KeyCode: integer;
 { prevents return from being used by editbox (otherwise sends a newline & text vanishes) }
 begin
-  // may want to make the tab beep if tab key (#9) - can't tab until list raised
-  if (Key in [#9, #13]) or (FListBox.FCheckBoxes and (Key = #32)) then
-  begin
+  KeyCode := ord(Key);
+  if (KeyCode = VK_RETURN) and (Style = orcsDropDown) and DroppedDown then
+  begin
+    DroppedDown := FALSE;
     Key := #0;
-    Exit;
-  end;
-  if Assigned(FOnKeyPress) then FOnKeyPress(Self, Key);
+  end
+  else
+  begin
+    // may want to make the tab beep if tab key (#9) - can't tab until list raised
+    if (KeyCode = VK_RETURN) or (KeyCode = VK_TAB) or (FListBox.FCheckBoxes and (KeyCode = VK_SPACE)) then
+    begin
+      Key := #0;
+      Exit;
+    end;
+    if Assigned(FOnKeyPress) then FOnKeyPress(Self, Key);
+  end;
 end;
 
@@ -4168,4 +4322,5 @@
       FCheckedState := FListBox.GetCheckedString;
     end;
+    DropDownStatusChanged(TRUE);
     FDropPanel.Visible := True;
     FDropPanel.BringToFront;
@@ -4178,4 +4333,5 @@
     uItemTip.Hide;
     FDropPanel.Hide;
+    DropDownStatusChanged(FALSE);
     if(FListBox.FCheckBoxes) and (assigned(FOnChange)) and
       (FCheckedState <> FListBox.GetCheckedString) then
@@ -4265,5 +4421,9 @@
     begin
       if FDropBtn <> nil then FDropBtn.Free;
-      if FDropPanel <> nil then FDropPanel.Free;
+      if FDropPanel <> nil then
+      begin
+        ClearDropDownStatus;
+        FDropPanel.Free;
+      end;
       FDropBtn := nil;
       FDropPanel := nil;
@@ -4280,5 +4440,6 @@
       if(assigned(FEditPanel) and (csDesigning in ComponentState)) then
         FEditPanel.ControlStyle := FEditPanel.ControlStyle - [csAcceptsControls];
-      FDropBtn.Glyph.LoadFromResourceName(hInstance, ComboBoxImages[inherited Enabled]);
+      LoadComboBoxImage;
+//      FDropBtn.Glyph.LoadFromResourceName(hInstance, ComboBoxImages[inherited Enabled]);
       FDropBtn.OnMouseDown := DropButtonDown;
       FDropBtn.OnMouseUp := DropButtonUp;
@@ -4292,4 +4453,5 @@
         FListBox.FParentCombo := Self;
         FListBox.Parent := FDropPanel;
+        ClearDropDownStatus;
         if FListBox.FScrollBar <> nil then FListBox.FScrollBar.Parent := FDropPanel;  // if long
       end else
@@ -4328,4 +4490,9 @@
 end;
 
+function TORComboBox.SupportsDynamicProperty(PropertyID: integer): boolean;
+begin
+  Result := (PropertyID = DynaPropAccesibilityCaption);
+end;
+
 // Since TORComboBox is composed of several controls (FEditBox, FListBox, FDropBtn), the
 // following functions and procedures map public and published properties to their related
@@ -4373,4 +4540,17 @@
 end;
 
+procedure TORComboBox.Invalidate;
+begin
+  inherited;
+  FEditBox.Invalidate;
+  FListBox.Invalidate;
+  if assigned(FEditPanel) then
+    FEditPanel.Invalidate;
+  if assigned(FDropBtn) then
+    FDropBtn.Invalidate;
+  if assigned(FDropPanel) then
+    FDropPanel.Invalidate;
+end;
+
 function TORComboBox.GetAutoSelect: Boolean;
 begin
@@ -4393,4 +4573,12 @@
 end;
 
+function TORComboBox.GetDynamicProperty(PropertyID: integer): string;
+begin
+  if PropertyID = DynaPropAccesibilityCaption then
+    Result := GetCaption
+  else
+    Result := '';
+end;
+
 function TORComboBox.GetItemHeight: Integer;
 begin
@@ -4516,4 +4704,14 @@
 begin
   FEditBox.AutoSelect := Value;
+end;
+
+procedure TORComboBox.SetBlackColorMode(Value: boolean);
+begin
+  if FBlackColorMode <> Value then
+  begin
+    FBlackColorMode := Value;
+    FListBox.SetBlackColorMode(Value);
+    LoadComboBoxImage;
+  end;
 end;
 
@@ -4774,7 +4972,9 @@
   if (inherited GetEnabled <> Value) then
   begin
+    DroppedDown := FALSE;
     inherited SetEnabled(Value);
     if assigned(FDropBtn) then
-      FDropBtn.Glyph.LoadFromResourceName(hInstance, ComboBoxImages[Value]);
+      LoadComboBoxImage;
+//      FDropBtn.Glyph.LoadFromResourceName(hInstance, ComboBoxImages[Value]);
   end;
 end;
@@ -4837,10 +5037,4 @@
 begin
   result := FListBox.Caption;
-end;
-
-function TORComboBox.MakeAccessible(Accessible: IAccessible): TORListBox;
-begin
-  FListBox.MakeAccessible(Accessible);
-  result := FListBox;
 end;
 
@@ -5261,22 +5455,4 @@
         ORCtrls.SetPiece(FStringData, FDelim, FPiece, Value);
     end;
-end;
-
-procedure TORTreeNode.MakeAccessible(Accessible: IAccessible);
-begin
-  if Assigned(FAccessible) and Assigned(Accessible) then
-    raise Exception.Create(Text + ' Tree Node is already Accessible!')
-  else
-  begin
-    FAccessible := Accessible;
-  end;
-end;
-
-procedure TORTreeNode.WMGetObject(var Message: TMessage);
-begin
-  if (Message.LParam = integer(OBJID_CLIENT)) and Assigned(FAccessible) then
-    Message.Result := GetLResult(Message.wParam, FAccessible)
-  else
-    inherited;
 end;
 
@@ -5522,22 +5698,4 @@
   else
     Result := '';
-end;
-
-procedure TORTreeView.MakeAccessible(Accessible: IAccessible);
-begin
-  if Assigned(FAccessible) and Assigned(Accessible) then
-    raise Exception.Create(Text + ' Tree View is already Accessible!')
-  else
-  begin
-    FAccessible := Accessible;
-  end;
-end;
-
-procedure TORTreeView.WMGetObject(var Message: TMessage);
-begin
-  if (Message.LParam = integer(OBJID_CLIENT)) and Assigned(FAccessible) then
-    Message.Result := GetLResult(Message.wParam, FAccessible)
-  else
-    inherited;
 end;
 
@@ -5908,5 +6066,5 @@
               end;
             end;
-            Bitmap := GetORCBBitmap(ImgIdx);
+            Bitmap := GetORCBBitmap(ImgIdx, FBlackColorMode);
           end
           else
@@ -6050,6 +6208,8 @@
             R.Top:= FocusRect.Top
           else
+          begin
             R.Top:= ((ClientHeight - Bitmap.Height + 1) div 2) - 1;
-
+            if R.Top < 0 then R.Top := 0            
+          end;
           Draw(R.Left, R.Top, Bitmap);
         end;
@@ -6145,4 +6305,13 @@
 end;
 
+procedure TORCheckBox.SetBlackColorMode(Value: boolean);
+begin
+  if FBlackColorMode <> Value then
+  begin
+    FBlackColorMode := Value;
+    Invalidate;
+  end;
+end;
+
 procedure TORCheckBox.AutoAdjustSize;
 var
@@ -6276,5 +6445,11 @@
     if DoCtrl then
       Ctrl.Enabled := Checked;
-    if(Ctrl is TWinControl) then
+
+    // added (csAcceptsControls in Ctrl.ControlStyle) below to prevent disabling of
+    // child sub controls, like the TBitBtn in the TORComboBox.  If the combo box is
+    // already disabled, we don't want to disable the button as well - when we do, we
+    // lose the disabled glyph that is stored on that button for the combo box.
+
+    if(Ctrl is TWinControl) and (csAcceptsControls in Ctrl.ControlStyle) then
     begin
       for i := 0 to TWinControl(Ctrl).ControlCount-1 do
@@ -6500,10 +6675,23 @@
 end;
 
-procedure TCaptionListBox.MakeAccessible(Accessible: IAccessible);
-begin
-  if Assigned(FAccessible) and Assigned(Accessible) then
-    raise Exception.Create(Caption + ' List Box is already Accessible!')
+function TCaptionListBox.GetDynamicProperty(PropertyID: integer): string;
+begin
+  if PropertyID = DynaPropAccesibilityCaption then
+    Result := GetCaption
   else
-    FAccessible := Accessible;
+    Result := '';
+end;
+
+
+procedure TCaptionListBox.MoveFocusUp;
+begin
+  if ItemIndex > 0 then
+    Perform(LB_SETCARETINDEX, ItemIndex - 1, 0);
+end;
+
+procedure TCaptionListBox.MoveFocusDown;
+begin
+  if ItemIndex < (Items.Count-1) then
+    Perform(LB_SETCARETINDEX, ItemIndex + 1, 0);
 end;
 
@@ -6522,10 +6710,25 @@
 end;
 
-procedure TCaptionListBox.WMGetObject(var Message: TMessage);
-begin
-  if (Message.LParam = integer(OBJID_CLIENT)) and Assigned(FAccessible) then
-    Message.Result := GetLResult(Message.wParam, FAccessible)
-  else
-    inherited;
+function TCaptionListBox.SupportsDynamicProperty(PropertyID: integer): boolean;
+begin
+  Result := (PropertyID = DynaPropAccesibilityCaption);
+end;
+
+procedure TCaptionListBox.WMKeyDown(var Message: TWMKeyDown);
+var
+  IsSelected: LongBool;
+begin
+  if Boolean(Hi(GetKeyState(VK_CONTROL))) and MultiSelect then
+    case Message.CharCode of
+      VK_SPACE:
+        begin
+          IsSelected := LongBool(Perform(LB_GETSEL, ItemIndex, 0));
+          Perform(LB_SETSEL, Longint(not IsSelected), ItemIndex);
+        end;
+      VK_LEFT, VK_UP: MoveFocusUp;
+      VK_RIGHT, VK_DOWN: MoveFocusDown;
+      else inherited;
+    end
+  else inherited;
 end;
 
@@ -6591,4 +6794,12 @@
 end;
 
+function TCaptionCheckListBox.GetDynamicProperty(PropertyID: integer): string;
+begin
+  if PropertyID = DynaPropAccesibilityCaption then
+    Result := GetCaption
+  else
+    Result := '';
+end;
+
 procedure TCaptionCheckListBox.SetCaption(const Value: string);
 begin
@@ -6605,4 +6816,10 @@
 end;
 
+function TCaptionCheckListBox.SupportsDynamicProperty(
+  PropertyID: integer): boolean;
+begin
+  Result := (PropertyID = DynaPropAccesibilityCaption);
+end;
+
 { TCaptionMemo }
 
@@ -6613,4 +6830,12 @@
   else
     result := FCaptionComponent.Caption;
+end;
+
+function TCaptionMemo.GetDynamicProperty(PropertyID: integer): string;
+begin
+  if PropertyID = DynaPropAccesibilityCaption then
+    Result := GetCaption
+  else
+    Result := '';
 end;
 
@@ -6629,4 +6854,9 @@
 end;
 
+function TCaptionMemo.SupportsDynamicProperty(PropertyID: integer): boolean;
+begin
+  Result := (PropertyID = DynaPropAccesibilityCaption);
+end;
+
 { TCaptionEdit }
 
@@ -6637,4 +6867,12 @@
   else
     result := FCaptionComponent.Caption;
+end;
+
+function TCaptionEdit.GetDynamicProperty(PropertyID: integer): string;
+begin
+  if PropertyID = DynaPropAccesibilityCaption then
+    Result := GetCaption
+  else
+    Result := '';
 end;
 
@@ -6653,27 +6891,38 @@
 end;
 
+function TCaptionEdit.SupportsDynamicProperty(PropertyID: integer): boolean;
+begin
+  Result := (PropertyID = DynaPropAccesibilityCaption);
+end;
+
 { TCaptionRichEdit }
 
-procedure TCaptionRichEdit.MakeAccessible(Accessible: IAccessible);
-begin
-  if Assigned(FAccessible) and Assigned(Accessible) then
-    raise Exception.Create(Caption + ' Rich Edit is already Accessible!')
+function TCaptionRichEdit.GetDynamicProperty(PropertyID: integer): string;
+begin
+  if PropertyID = DynaPropAccesibilityCaption then
+    Result := FCaption
   else
-    FAccessible := Accessible;
-end;
-
-procedure TCaptionRichEdit.WMGetObject(var Message: TMessage);
-begin
-  if (Message.LParam = integer(OBJID_CLIENT)) and Assigned(FAccessible) then
-    Message.Result := GetLResult(Message.wParam, FAccessible)
+    Result := '';
+end;
+
+
+function TCaptionRichEdit.SupportsDynamicProperty(PropertyID: integer): boolean;
+begin
+  Result := (PropertyID = DynaPropAccesibilityCaption);
+end;
+
+{ TCaptionTreeView}
+
+function TCaptionTreeView.GetCaption: string;
+begin
+    result := inherited Caption;
+end;
+
+function TCaptionTreeView.GetDynamicProperty(PropertyID: integer): string;
+begin
+  if PropertyID = DynaPropAccesibilityCaption then
+    Result := GetCaption
   else
-    inherited;
-end;
-
-{ TCaptionTreeView}
-
-function TCaptionTreeView.GetCaption: string;
-begin
-    result := inherited Caption;
+    Result := '';
 end;
 
@@ -6693,4 +6942,9 @@
 end;
 
+function TCaptionTreeView.SupportsDynamicProperty(PropertyID: integer): boolean;
+begin
+  Result := (PropertyID = DynaPropAccesibilityCaption);
+end;
+
 { TCaptionComboBox }
 
@@ -6701,4 +6955,12 @@
   else
     result := FCaptionComponent.Caption;
+end;
+
+function TCaptionComboBox.GetDynamicProperty(PropertyID: integer): string;
+begin
+  if PropertyID = DynaPropAccesibilityCaption then
+    Result := GetCaption
+  else
+    Result := '';
 end;
 
@@ -6717,4 +6979,9 @@
 end;
 
+function TCaptionComboBox.SupportsDynamicProperty(PropertyID: integer): boolean;
+begin
+  Result := (PropertyID = DynaPropAccesibilityCaption);
+end;
+
 { TORAlignSpeedButton }
 
@@ -6742,4 +7009,12 @@
   result := (ColCount - FixedCols) * (Row - FixedRows) +
       (Col - FixedCols) + 1;
+end;
+
+function TCaptionStringGrid.GetDynamicProperty(PropertyID: integer): string;
+begin
+  if PropertyID = DynaPropAccesibilityCaption then
+    Result := FCaption
+  else
+    Result := '';
 end;
 
@@ -6761,18 +7036,9 @@
 end;
 
-procedure TCaptionStringGrid.MakeAccessible(Accessible: IAccessible);
-begin
-  if Assigned(FAccessible) and Assigned(Accessible) then
-    raise Exception.Create(Caption + 'String Grid is already Accessible!')
-  else
-    FAccessible := Accessible;
-end;
-
-procedure TCaptionStringGrid.WMGetObject(var Message: TMessage);
-begin
-  if (Message.LParam = integer(OBJID_CLIENT)) and Assigned(FAccessible) then
-    Message.Result := GetLResult(Message.wParam, FAccessible)
-  else
-    inherited;
+
+function TCaptionStringGrid.SupportsDynamicProperty(
+  PropertyID: integer): boolean;
+begin
+  Result := (PropertyID = DynaPropAccesibilityCaption);
 end;
 
@@ -6810,7 +7076,8 @@
     if LongList then
     begin
-      //Currently Do nothing for LongLists
-     { if CompareText(iText, Copy(DisplayText[SelectIndex+1], 1, Length(iText))) = 0 then
-        Result := -1;}
+      //Implemented for CQ: 10092, PSI-04-057
+      //asume long lists are alphabetically ordered...
+      if CompareText(iText, Copy(DisplayText[SelectIndex+1], 1, Length(iText))) = 0 then
+        Result := -1;
     end
     else //Not a LongList
@@ -6836,4 +7103,19 @@
 end;
 
+{ TCaptionListView }
+
+function TCaptionListView.GetDynamicProperty(PropertyID: integer): string;
+begin
+  if PropertyID = DynaPropAccesibilityCaption then
+    Result := Caption
+  else
+    Result := '';
+end;
+
+function TCaptionListView.SupportsDynamicProperty(PropertyID: integer): boolean;
+begin
+  Result := (PropertyID = DynaPropAccesibilityCaption);
+end;
+
 initialization
   //uItemTip := TItemTip.Create(Application);  // all listboxes share a single ItemTip window
