Ignore:
Timestamp:
May 8, 2015, 7:52:55 AM (10 years ago)
Author:
healthsevak
Message:

Committing the files for first time to this new branch

Location:
cprs/branches/HealthSevak-CPRS/CPRS-Lib
Files:
44 added
7 edited

Legend:

Unmodified
Added
Removed
  • cprs/branches/HealthSevak-CPRS/CPRS-Lib/ORCtrls.pas

    r829 r1693  
    1 unit ORCtrls;                                    // Oct 26, 1997 @ 10:00am
     1unit ORCtrls; // Oct 26, 1997 @ 10:00am
    22
    33// To Do:  eliminate topindex itemtip on mousedown (seen when choosing clinic pts)
    44
    5 interface  // --------------------------------------------------------------------------------
     5interface // --------------------------------------------------------------------------------
    66
    77uses Windows, Messages, SysUtils, Classes, Graphics, Controls, StdCtrls, Forms,
    8      ComCtrls, Commctrl, Buttons, ExtCtrls, Grids, ImgList, Menus, CheckLst,
    9      Variants, VAClasses;
     8  ComCtrls, Commctrl, Buttons, ExtCtrls, Grids, ImgList, Menus, CheckLst,
     9  Variants, VAClasses, typinfo;
    1010
    1111const
    12   UM_SHOWTIP  = (WM_USER + 9436);                // message id to display item tip         **was 300
    13   UM_GOTFOCUS = (WM_USER + 9437);                // message to post when combo gets focus  **was 301
    14   MAX_TABS = 40;                                 // maximum number of tab stops or pieces
    15   LL_REVERSE  = -1;                              // long list scrolling in reverse direction
    16   LL_POSITION =  0;                              // long list thumb moved
    17   LL_FORWARD  =  1;                              // long list scrolling in forward direction
    18   LLS_LINE  = '^____________________________________________________________________________';
    19   LLS_DASH  = '^----------------------------------------------------------------------------';
     12  UM_SHOWTIP = (WM_USER + 9436); // message id to display item tip         **was 300
     13  UM_GOTFOCUS = (WM_USER + 9437); // message to post when combo gets focus  **was 301
     14  MAX_TABS = 40; // maximum number of tab stops or pieces
     15  LL_REVERSE = -1; // long list scrolling in reverse direction
     16  LL_POSITION = 0; // long list thumb moved
     17  LL_FORWARD = 1; // long list scrolling in forward direction
     18  LLS_LINE = '^____________________________________________________________________________';
     19  LLS_DASH = '^----------------------------------------------------------------------------';
    2020  LLS_SPACE = '^ ';
    2121
    2222type
    2323  IORBlackColorModeCompatible = interface(IInterface)
    24   ['{3554985C-F524-45FA-8C27-4CDD8357DB08}']
     24    ['{3554985C-F524-45FA-8C27-4CDD8357DB08}']
    2525    procedure SetBlackColorMode(Value: boolean);
    2626  end;
    2727
    28   TORComboBox = class;                           // forward declaration for FParentCombo
    29 
    30   TTranslator = function (MString: string): string of object;
     28  TORComboBox = class; // forward declaration for FParentCombo
     29
     30  TTranslator = function(MString: string): string of object;
    3131
    3232  TORStrings = class(TStrings)
     
    3838    procedure Verify;
    3939  protected
    40     function Get( index:integer): string; override;
     40    function Get(index: integer): string; override;
    4141    function GetCount: integer; override;
    42     function GetObject(index:integer): TObject; override;
     42    function GetObject(index: integer): TObject; override;
    4343    procedure Put(Index: Integer; const S: string); override;
    44     procedure PutObject(index:integer; Value: TObject); override;
    45     procedure SetUpdateState( Value: boolean); override;
     44    procedure PutObject(index: integer; Value: TObject); override;
     45    procedure SetUpdateState(Value: boolean); override;
    4646  public
    4747    function Add(const S: string): integer; override;
     
    4949    destructor Destroy; override;
    5050    procedure Clear; override;
    51     procedure Delete( index: integer); override;
     51    procedure Delete(index: integer); override;
    5252    procedure Insert(Index: Integer; const S: string); override;
    5353    function IndexOf(const S: string): Integer; override;
     
    5757  end;
    5858
    59   TORDirection = -1..1;                          // for compatibility, type is now integer
    60   TORNeedDataEvent       = procedure(Sender: TObject; const StartFrom: string;
    61                                      Direction, InsertAt: Integer) of object;
    62   TORBeforeDrawEvent     = procedure(Sender: TObject; Index: Integer; Rect: TRect;
    63                                      State: TOwnerDrawState) of object;
    64   TORItemNotifyEvent     = procedure(Sender: TObject; Index: integer) of object;
     59  TORDirection = -1..1; // for compatibility, type is now integer
     60  TORNeedDataEvent = procedure(Sender: TObject; const StartFrom: string;
     61    Direction, InsertAt: Integer) of object;
     62  TORBeforeDrawEvent = procedure(Sender: TObject; Index: Integer; Rect: TRect;
     63    State: TOwnerDrawState) of object;
     64  TORItemNotifyEvent = procedure(Sender: TObject; Index: integer) of object;
    6565  TORCheckComboTextEvent = procedure(Sender: TObject; NumChecked: integer; var Text: string) of object;
    66   TORSynonymCheckEvent   = procedure(Sender: TObject; const Text: string;
    67                                      var IsSynonym: boolean) of object;
     66  TORSynonymCheckEvent = procedure(Sender: TObject; const Text: string;
     67    var IsSynonym: boolean) of object;
    6868
    6969  PItemRec = ^TItemRec;
    7070  TItemRec = record
    71     Reference: Variant;                          // variant value associated with item
    72     UserObject: TObject;                         // Objects[n] property of listbox item
    73     CheckedState: TCheckBoxState;                // Used to indicate check box values
     71    Reference: Variant; // variant value associated with item
     72    UserObject: TObject; // Objects[n] property of listbox item
     73    CheckedState: TCheckBoxState; // Used to indicate check box values
     74  end;
     75
     76  THintRecords = record
     77    ObjectName: string;
     78    ObjectHint: string;
    7479  end;
    7580
    7681  TORListBox = class(TListBox, IVADynamicProperty, IORBlackColorModeCompatible)
    7782  private
    78     FFocusIndex: Integer;                        // item with focus when using navigation keys
    79     FLargeChange: Integer;                       // visible items less one
    80     FTipItem: Integer;                           // item currently displaying ItemTip
    81     FItemTipActive: Boolean;                     // used to delay appearance of the ItemTip
    82     FItemTipColor: TColor;                       // background color for ItemTip window
    83     FItemTipEnable: Boolean;                     // allows display of ItemTips over items
    84     FLastMouseX: Integer;                        // mouse X position on last MouseMove event
    85     FLastMouseY: Integer;                        // mouse Y position on last MouseMove event
    86     FLastItemIndex: Integer;                     // used for the OnChange event
    87     FFromSelf: Boolean;                          // true if listbox message sent from this unit
    88     FDelimiter: Char;                            // delimiter used by Pieces property
    89     FWhiteSpace: Char;                           // may be space or tab (between pieces)
    90     FTabPosInPixels: boolean;                    // determines if TabPosition is Pixels or Chars
    91     FTabPos: array[0..MAX_TABS] of Integer;      // character based positions of tab stops
    92     FTabPix: array[0..MAX_TABS] of Integer;      // pixel positions of tab stops
    93     FPieces: array[0..MAX_TABS] of Integer;      // pieces that should be displayed for item
    94     FLongList: Boolean;                          // if true, enables special LongList properties
    95     FScrollBar: TScrollBar;                      // scrollbar used when in LongList mode
    96     FFirstLoad: Boolean;                         // true if NeedData has never been called
    97     FFromNeedData: Boolean;                      // true means items added to LongList part
    98     FDataAdded: Boolean;                         // true if items added during NeedData call
    99     FCurrentTop: Integer;                        // TopIndex, changes when inserting to LongList
    100     FWaterMark: Integer;                         // first LongList item after the short list
    101     FDirection: Integer;                         // direction of the current NeedData call
    102     FInsertAt: Integer;                          // insert point for the current NeedData call
    103     FParentCombo: TORComboBox;                   // used when listbox is part of dropdown combo
    104     FOnChange: TNotifyEvent;                     // event called when ItemIndex changes
    105     FOnNeedData: TORNeedDataEvent;               // event called when LongList needs more items
    106     FHideSynonyms: boolean;                      // Hides Synonyms from the list
    107     FSynonymChars: string;                       // Chars a string must contain to be considered a synonym
    108     FOnSynonymCheck: TORSynonymCheckEvent;       // Event that allows for custom synonym checking
    109     FCreatingItem: boolean;                      // Used by Synonyms to prevent errors when adding new items
    110     FCreatingText: string;                       // Used by Synonyms to prevent errors when adding new items
    111     FOnBeforeDraw: TORBeforeDrawEvent;           // event called prior to drawing an item
    112     FRightClickSelect: boolean;                  // When true, a right click selects teh item
    113     FCheckBoxes: boolean;                        // When true, list box contains check boxes
    114     FFlatCheckBoxes: boolean;                    // When true, list box check boxes are flat
    115     FCheckEntireLine: boolean;                   // When checked, clicking anywhere on the line checks the checkbox
    116     FOnClickCheck: TORItemNotifyEvent;           // Event notifying of checkbox change
    117     FDontClose: boolean;                         // Used to keep drop down open when checkboxes
    118     FItemsDestroyed: boolean;                    // Used to make sure items are not destroyed multiple times
     83    FFocusIndex: Integer; // item with focus when using navigation keys
     84    FLargeChange: Integer; // visible items less one
     85    FTipItem: Integer; // item currently displaying ItemTip
     86    FItemTipActive: Boolean; // used to delay appearance of the ItemTip
     87    FItemTipColor: TColor; // background color for ItemTip window
     88    FItemTipEnable: Boolean; // allows display of ItemTips over items
     89    FLastMouseX: Integer; // mouse X position on last MouseMove event
     90    FLastMouseY: Integer; // mouse Y position on last MouseMove event
     91    FLastItemIndex: Integer; // used for the OnChange event
     92    FFromSelf: Boolean; // true if listbox message sent from this unit
     93    FDelimiter: Char; // delimiter used by Pieces property
     94    FWhiteSpace: Char; // may be space or tab (between pieces)
     95    FTabPosInPixels: boolean; // determines if TabPosition is Pixels or Chars
     96    FTabPos: array[0..MAX_TABS] of Integer; // character based positions of tab stops
     97    FTabPix: array[0..MAX_TABS] of Integer; // pixel positions of tab stops
     98    FPieces: array[0..MAX_TABS] of Integer; // pieces that should be displayed for item
     99    FLongList: Boolean; // if true, enables special LongList properties
     100    FScrollBar: TScrollBar; // scrollbar used when in LongList mode
     101    FFirstLoad: Boolean; // true if NeedData has never been called
     102    FFromNeedData: Boolean; // true means items added to LongList part
     103    FDataAdded: Boolean; // true if items added during NeedData call
     104    FCurrentTop: Integer; // TopIndex, changes when inserting to LongList
     105    FWaterMark: Integer; // first LongList item after the short list
     106    FDirection: Integer; // direction of the current NeedData call
     107    FInsertAt: Integer; // insert point for the current NeedData call
     108    FParentCombo: TORComboBox; // used when listbox is part of dropdown combo
     109    FOnChange: TNotifyEvent; // event called when ItemIndex changes
     110    FOnNeedData: TORNeedDataEvent; // event called when LongList needs more items
     111    FHideSynonyms: boolean; // Hides Synonyms from the list
     112    FSynonymChars: string; // Chars a string must contain to be considered a synonym
     113    FOnSynonymCheck: TORSynonymCheckEvent; // Event that allows for custom synonym checking
     114    FCreatingItem: boolean; // Used by Synonyms to prevent errors when adding new items
     115    FCreatingText: string; // Used by Synonyms to prevent errors when adding new items
     116    FOnBeforeDraw: TORBeforeDrawEvent; // event called prior to drawing an item
     117    FRightClickSelect: boolean; // When true, a right click selects teh item
     118    FCheckBoxes: boolean; // When true, list box contains check boxes
     119    FFlatCheckBoxes: boolean; // When true, list box check boxes are flat
     120    FCheckEntireLine: boolean; // When checked, clicking anywhere on the line checks the checkbox
     121    FOnClickCheck: TORItemNotifyEvent; // Event notifying of checkbox change
     122    FDontClose: boolean; // Used to keep drop down open when checkboxes
     123    FItemsDestroyed: boolean; // Used to make sure items are not destroyed multiple times
    119124    FAllowGrayed: boolean;
    120     FMItems: TORStrings;                         // Used to save corresponding M strings ("the pieces")
    121     FCaption: TStaticText;                       // Used to supply a title to IAccessible interface
    122     FCaseChanged: boolean;                       // If true, the names are stored in the database as all caps, but loaded and displayed in mixed-case
    123     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
     125    FMItems: TORStrings; // Used to save corresponding M strings ("the pieces")
     126    FCaption: TStaticText; // Used to supply a title to IAccessible interface
     127    FCaseChanged: boolean; // If true, the names are stored in the database as all caps, but loaded and displayed in mixed-case
     128    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
    124129    FIsPartOfComboBox: boolean;
    125130    FBlackColorMode: boolean;
     
    156161    function IsSynonym(const TestStr: string): boolean;
    157162    function TextToShow(S: string): string;
    158     procedure LBGetText      (var Message: TMessage);        message LB_GETTEXT;
    159     procedure LBGetTextLen   (var Message: TMessage);        message LB_GETTEXTLEN;
    160     procedure LBGetItemData  (var Message: TMessage);        message LB_GETITEMDATA;
    161     procedure LBSetItemData  (var Message: TMessage);        message LB_SETITEMDATA;
    162     procedure LBAddString    (var Message: TMessage);        message LB_ADDSTRING;
    163     procedure LBInsertString (var Message: TMessage);        message LB_INSERTSTRING;
    164     procedure LBDeleteString (var Message: TMessage);        message LB_DELETESTRING;
    165     procedure LBResetContent (var Message: TMessage);        message LB_RESETCONTENT;
    166     procedure LBSetCurSel    (var Message: TMessage);        message LB_SETCURSEL;
    167     procedure CMFontChanged  (var Message: TMessage);        message CM_FONTCHANGED;
    168     procedure CNDrawItem     (var Message: TWMDrawItem);      message CN_DRAWITEM;
    169     procedure WMDestroy      (var Message: TWMDestroy);      message WM_DESTROY;
    170     procedure WMKeyDown      (var Message: TWMKeyDown);      message WM_KEYDOWN;
    171     procedure WMLButtonDown  (var Message: TWMLButtonDown);  message WM_LBUTTONDOWN;
    172     procedure WMLButtonUp    (var Message: TWMLButtonUp);    message WM_LBUTTONUP;
    173     procedure WMRButtonUp    (var Message: TWMRButtonUp);    message WM_RBUTTONUP;
     163    procedure LBGetText(var Message: TMessage); message LB_GETTEXT;
     164    procedure LBGetTextLen(var Message: TMessage); message LB_GETTEXTLEN;
     165    procedure LBGetItemData(var Message: TMessage); message LB_GETITEMDATA;
     166    procedure LBSetItemData(var Message: TMessage); message LB_SETITEMDATA;
     167    procedure LBAddString(var Message: TMessage); message LB_ADDSTRING;
     168    procedure LBInsertString(var Message: TMessage); message LB_INSERTSTRING;
     169    procedure LBDeleteString(var Message: TMessage); message LB_DELETESTRING;
     170    procedure LBResetContent(var Message: TMessage); message LB_RESETCONTENT;
     171    procedure LBSetCurSel(var Message: TMessage); message LB_SETCURSEL;
     172    procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
     173    procedure CNDrawItem(var Message: TWMDrawItem); message CN_DRAWITEM;
     174    procedure WMDestroy(var Message: TWMDestroy); message WM_DESTROY;
     175    procedure WMKeyDown(var Message: TWMKeyDown); message WM_KEYDOWN;
     176    procedure WMLButtonDown(var Message: TWMLButtonDown); message WM_LBUTTONDOWN;
     177    procedure WMLButtonUp(var Message: TWMLButtonUp); message WM_LBUTTONUP;
     178    procedure WMRButtonUp(var Message: TWMRButtonUp); message WM_RBUTTONUP;
    174179    procedure WMLButtonDblClk(var Message: TWMLButtonDblClk); message WM_LBUTTONDBLCLK;
    175     procedure WMCancelMode   (var Message: TMessage);        message WM_CANCELMODE;
    176     procedure WMMove         (var Message: TWMMove);          message WM_MOVE;
    177     procedure WMSize         (var Message: TWMSize);          message WM_SIZE;
    178     procedure WMVScroll      (var Message: TWMVScroll);      message WM_VSCROLL;
    179     procedure CMHintShow     (var Message: TMessage);        message CM_HINTSHOW;
    180     procedure UMShowTip      (var Message: TMessage);        message UM_SHOWTIP;
     180    procedure WMCancelMode(var Message: TMessage); message WM_CANCELMODE;
     181    procedure WMMove(var Message: TWMMove); message WM_MOVE;
     182    procedure WMSize(var Message: TWMSize); message WM_SIZE;
     183    procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL;
     184    procedure CMHintShow(var Message: TMessage); message CM_HINTSHOW;
     185    procedure UMShowTip(var Message: TMessage); message UM_SHOWTIP;
    181186    function GetChecked(Index: Integer): Boolean;
    182187    procedure SetChecked(Index: Integer; const Value: Boolean);
     
    187192    procedure SetCheckedState(Index: Integer; const Value: TCheckBoxState);
    188193    function GetMItems: TStrings;
    189     procedure SetMItems( Value: TStrings);
     194    procedure SetMItems(Value: TStrings);
    190195    procedure SetCaption(const Value: string);
    191196    function GetCaption: string;
     
    207212    procedure MeasureItem(Index: Integer; var Height: Integer); override;
    208213    procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState); override;
    209     function GetIndexFromY(YPos :integer) :integer;
     214    function GetIndexFromY(YPos: integer): integer;
    210215    property isPartOfComboBox: boolean read FIsPartOfComboBox write FIsPartOfComboBox default False;
    211216    property HideSynonyms: boolean read FHideSynonyms write SetHideSynonyms default FALSE;
     
    236241    property CheckedState[Index: Integer]: TCheckBoxState read GetCheckedState write SetCheckedState;
    237242    property MItems: TStrings read GetMItems write SetMItems;
    238     function VerifyUnique(SelectIndex: Integer; iText: String): integer;
     243    function VerifyUnique(SelectIndex: Integer; iText: string): integer;
    239244    procedure SetBlackColorMode(Value: boolean);
    240245    function SupportsDynamicProperty(PropertyID: integer): boolean;
    241246    function GetDynamicProperty(PropertyID: integer): string;
     247    procedure SetHintProperties(Restore: Boolean; MainForm: TComponent);
    242248    property HideSelection: boolean read FHideSelection write FHideSelection;
    243249  published
     
    303309  TORComboBox = class(TWinControl, IVADynamicProperty, IORBlackColorModeCompatible)
    304310  private
    305     FItems: TStrings;                            // points to Items in FListBox
    306     FMItems: TStrings;                           // points to MItems in FListBox
    307     FListBox: TORListBox;                        // listbox control for the combobox
    308     FEditBox: TORComboEdit;                      // edit control for the combobox
    309     FEditPanel: TORComboPanelEdit;               // Used to enable Multi-Select Combo Boxes
    310     FDropBtn: TBitBtn;                           // drop down button for dropdown combo
    311     FDropPanel: TORDropPanel;                    // panel for dropdown combo (parent=desktop)
    312     FDroppedDown: Boolean;                       // true if the list part is dropped down
    313     FStyle: TORComboStyle;                       // style is simple or dropdown for combo
    314     FDropDownCount: Integer;                     // number of items to display when list appears
    315     FFromSelf: Boolean;                          // prevents recursive calls to change event
    316     FFromDropBtn: Boolean;                       // determines when to capture mouse on drop
    317     FKeyTimerActive: Boolean;                    // true when timer running for OnKeyPause
    318     FKeyIsDown: Boolean;                         // true between KeyDown & KeyUp events
     311    FItems: TStrings; // points to Items in FListBox
     312    FMItems: TStrings; // points to MItems in FListBox
     313    FListBox: TORListBox; // listbox control for the combobox
     314    FEditBox: TORComboEdit; // edit control for the combobox
     315    FEditPanel: TORComboPanelEdit; // Used to enable Multi-Select Combo Boxes
     316    FDropBtn: TBitBtn; // drop down button for dropdown combo
     317    FDropPanel: TORDropPanel; // panel for dropdown combo (parent=desktop)
     318    FDroppedDown: Boolean; // true if the list part is dropped down
     319    FStyle: TORComboStyle; // style is simple or dropdown for combo
     320    FDropDownCount: Integer; // number of items to display when list appears
     321    FFromSelf: Boolean; // prevents recursive calls to change event
     322    FFromDropBtn: Boolean; // determines when to capture mouse on drop
     323    FKeyTimerActive: Boolean; // true when timer running for OnKeyPause
     324    FKeyIsDown: Boolean; // true between KeyDown & KeyUp events
    319325    FChangePending: Boolean;
    320326    FListItemsOnly: Boolean;
    321327    FLastFound: string;
    322     FLastInput: string;                          // last thing the user typed into the edit box
    323     FOnChange: TNotifyEvent;                     // maps to editbox change event
    324     FOnClick: TNotifyEvent;                      // maps to listbox click event
    325     FOnDblClick: TNotifyEvent;                   // maps to listbox double click event
    326     FOnDropDown: TNotifyEvent;                   // event called when listbox appears
    327     FOnDropDownClose: TNotifyEvent;              // event called when listbox disappears
    328     FOnKeyDown: TKeyEvent;                       // maps to editbox keydown event
    329     FOnKeyPress: TKeyPressEvent;                 // maps to editbox keypress event
    330     FOnKeyUp: TKeyEvent;                         // maps to editbox keyup event
    331     FOnKeyPause: TNotifyEvent;                   // delayed change event when using keyboard
    332     FOnMouseClick: TNotifyEvent;                 // called when click event triggered by mouse
    333     FOnNeedData: TORNeedDataEvent;               // called for longlist when more items needed
    334     FCheckedState: string;                       // Used to refresh checkboxes when combo box cancel is pressed
    335     FOnCheckedText: TORCheckComboTextEvent;      // Used to modify the edit box display text when using checkboxes
    336     FCheckBoxEditColor: TColor;                  // Edit Box color for Check Box Combo List, when not in Focus
     328    FLastInput: string; // last thing the user typed into the edit box
     329    FOnChange: TNotifyEvent; // maps to editbox change event
     330    FOnClick: TNotifyEvent; // maps to listbox click event
     331    FOnDblClick: TNotifyEvent; // maps to listbox double click event
     332    FOnDropDown: TNotifyEvent; // event called when listbox appears
     333    FOnDropDownClose: TNotifyEvent; // event called when listbox disappears
     334    FOnKeyDown: TKeyEvent; // maps to editbox keydown event
     335    FOnKeyPress: TKeyPressEvent; // maps to editbox keypress event
     336    FOnKeyUp: TKeyEvent; // maps to editbox keyup event
     337    FOnKeyPause: TNotifyEvent; // delayed change event when using keyboard
     338    FOnMouseClick: TNotifyEvent; // called when click event triggered by mouse
     339    FOnNeedData: TORNeedDataEvent; // called for longlist when more items needed
     340    FCheckedState: string; // Used to refresh checkboxes when combo box cancel is pressed
     341    FOnCheckedText: TORCheckComboTextEvent; // Used to modify the edit box display text when using checkboxes
     342    FCheckBoxEditColor: TColor; // Edit Box color for Check Box Combo List, when not in Focus
    337343    FTemplateField: boolean;
    338     FCharsNeedMatch: integer;                    // how many text need to be matched for auto selection
    339     FUniqueAutoComplete: Boolean;                // If true only perform autocomplete for unique list items.
     344    FCharsNeedMatch: integer; // how many text need to be matched for auto selection
     345    FUniqueAutoComplete: Boolean; // If true only perform autocomplete for unique list items.
    340346    FBlackColorMode: boolean;
    341     FDisableHints: boolean;                      // true if hints have been disabled because drop down window was opened
    342     FDropDownStatusChangedCount: integer;        // prevents multiple calls to disabling hint window
     347    FDisableHints: boolean; // true if hints have been disabled because drop down window was opened
     348    FDropDownStatusChangedCount: integer; // prevents multiple calls to disabling hint window
     349    fRpcCall: String;
    343350    procedure DropDownStatusChanged(opened: boolean);
    344351    procedure ClearDropDownStatus;
     
    413420    procedure StartKeyTimer;
    414421    procedure StopKeyTimer;
    415     procedure WMDestroy     (var Message: TWMDestroy); message WM_DESTROY;
    416     procedure CMFontChanged (var Message: TMessage); message CM_FONTCHANGED;
    417     procedure WMMove        (var Message: TWMMove); message WM_MOVE;
    418     procedure WMSize        (var Message: TWMSize); message WM_SIZE;
    419     procedure WMTimer       (var Message: TWMTimer); message WM_TIMER;
    420     procedure UMGotFocus    (var Message: TMessage); message UM_GOTFOCUS;
     422    procedure WMDestroy(var Message: TWMDestroy); message WM_DESTROY;
     423    procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
     424    procedure WMMove(var Message: TWMMove); message WM_MOVE;
     425    procedure WMSize(var Message: TWMSize); message WM_SIZE;
     426    procedure WMTimer(var Message: TWMTimer); message WM_TIMER;
     427    procedure UMGotFocus(var Message: TMessage); message UM_GOTFOCUS;
    421428    function GetCheckBoxes: boolean;
    422429    function GetChecked(Index: Integer): Boolean;
     
    464471    procedure InsertSeparator;
    465472    procedure Invalidate; override;
    466     procedure SetTextAutoComplete(TextToMatch : String);
     473    procedure SetTextAutoComplete(TextToMatch: string);
    467474    function GetIEN(AnIndex: Integer): Int64;
    468475    function SelectByIEN(AnIEN: Int64): Integer;
     
    490497    property MItems: TStrings read GetMItems;
    491498  published
     499    Property RpcCall :String read fRpcCall write fRpcCall;
    492500    property Anchors;
    493501    property CaseChanged: boolean read GetCaseChanged write SetCaseChanged default TRUE;
     
    548556    property OnResize;
    549557    property OnSynonymCheck: TORSynonymCheckEvent read GetOnSynonymCheck write SetOnSynonymCheck;
    550     property CharsNeedMatch: integer  read FCharsNeedMatch write SetNumForMatch;
     558    property CharsNeedMatch: integer read FCharsNeedMatch write SetNumForMatch;
    551559{UniqueAutoComplete Was added as a result of the following defects:
    552560 7293 - PTM 85:  Backspace and Dosage:  Desired dosage does not populate if dosage is not in local dosage field
     
    560568  private
    561569    FSizes: TList;
    562     procedure BuildSizes( Control: TWinControl);
    563     procedure DoResize( Control: TWinControl; var CurrentIndex: Integer);
     570    procedure BuildSizes(Control: TWinControl);
     571    procedure DoResize(Control: TWinControl; var CurrentIndex: Integer);
    564572  protected
    565573    procedure Loaded; override;
     
    569577  end;
    570578
    571   TOROffsetLabel = class(TGraphicControl)        // see TCustomLabel in the VCL
     579  TOROffsetLabel = class(TGraphicControl) // see TCustomLabel in the VCL
    572580  private
    573     FHorzOffset: Integer;                        // offset from left of label in pixels
    574     FVertOffset: Integer;                        // offset from top of label in pixels
    575     FWordWrap: Boolean;                          // true if word wrap should occur
     581    FHorzOffset: Integer; // offset from left of label in pixels
     582    FVertOffset: Integer; // offset from top of label in pixels
     583    FWordWrap: Boolean; // true if word wrap should occur
    576584    function GetTransparent: Boolean;
    577585    procedure AdjustSizeOfSelf;
     
    648656  end;
    649657
    650   TORAlignEdit =  class(TEdit) //Depricated -- Use TCaptionEdit instead
     658  TORAlignEdit = class(TEdit) //Depricated -- Use TCaptionEdit instead
    651659  published
    652660    property Align;
     
    722730    constructor Create(AOwner: TComponent); override;
    723731    function FindPieceNode(Value: string;
    724                            ParentDelim: Char = #0; StartNode: TTreeNode = nil): TORTreeNode; overload;
     732      ParentDelim: Char = #0; StartNode: TTreeNode = nil): TORTreeNode; overload;
    725733    function FindPieceNode(Value: string; APiece: integer;
    726                            ParentDelim: Char = #0; StartNode: TTreeNode = nil): TORTreeNode; overload;
     734      ParentDelim: Char = #0; StartNode: TTreeNode = nil): TORTreeNode; overload;
    727735    procedure RenameNodes;
    728736    function GetExpandedIDStr(APiece: integer; ParentDelim: char = #0): string;
    729737    procedure SetExpandedIDStr(APiece: integer; const Value: string); overload;
    730738    procedure SetExpandedIDStr(APiece: integer; ParentDelim: char;
    731                                                 const Value: string); overload;
     739      const Value: string); overload;
    732740    function GetNodeID(Node: TORTreeNode; ParentDelim: Char = #0): string; overload;
    733741    function GetNodeID(Node: TORTreeNode; APiece: integer; ParentDelim: Char = #0): string; overload;
     
    770778    destructor Destroy; override;
    771779  published
    772     property CheckedEnabledIndex:    integer read FCheckedEnabledIndex    write SetCheckedEnabledIndex;
    773     property CheckedDisabledIndex:   integer read FCheckedDisabledIndex  write SetCheckedDisabledIndex;
    774     property GrayedEnabledIndex:     integer read FGrayedEnabledIndex    write SetGrayedEnabledIndex;
    775     property GrayedDisabledIndex:    integer read FGrayedDisabledIndex    write SetGrayedDisabledIndex;
    776     property UncheckedEnabledIndex:  integer read FUncheckedEnabledIndex write SetUncheckedEnabledIndex;
     780    property CheckedEnabledIndex: integer read FCheckedEnabledIndex write SetCheckedEnabledIndex;
     781    property CheckedDisabledIndex: integer read FCheckedDisabledIndex write SetCheckedDisabledIndex;
     782    property GrayedEnabledIndex: integer read FGrayedEnabledIndex write SetGrayedEnabledIndex;
     783    property GrayedDisabledIndex: integer read FGrayedDisabledIndex write SetGrayedDisabledIndex;
     784    property UncheckedEnabledIndex: integer read FUncheckedEnabledIndex write SetUncheckedEnabledIndex;
    777785    property UncheckedDisabledIndex: integer read FUncheckedDisabledIndex write SetUncheckedDisabledIndex;
    778786  end;
     
    799807    FBlackColorMode: boolean;
    800808    procedure SetFocusOnBox(value: boolean);
    801     procedure CNMeasureItem    (var Message: TWMMeasureItem);  message CN_MEASUREITEM;
    802     procedure CNDrawItem       (var Message: TWMDrawItem);      message CN_DRAWITEM;
    803     procedure CMFontChanged    (var Message: TMessage);        message CM_FONTCHANGED;
    804     procedure CMEnabledChanged (var Message: TMessage);        message CM_ENABLEDCHANGED;
    805     procedure WMLButtonDblClk  (var Message: TWMLButtonDblClk); message WM_LBUTTONDBLCLK;
    806     procedure WMSize           (var Message: TWMSize);          message WM_SIZE;
    807     procedure BMSetCheck       (var Message: TMessage);        message BM_SETCHECK;
    808     procedure BMGetCheck       (var Message: TMessage);        message BM_GETCHECK;
    809     procedure BMGetState       (var Message: TMessage);        message BM_GETSTATE;
     809    procedure CNMeasureItem(var Message: TWMMeasureItem); message CN_MEASUREITEM;
     810    procedure CNDrawItem(var Message: TWMDrawItem); message CN_DRAWITEM;
     811    procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
     812    procedure CMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED;
     813    procedure WMLButtonDblClk(var Message: TWMLButtonDblClk); message WM_LBUTTONDBLCLK;
     814    procedure WMSize(var Message: TWMSize); message WM_SIZE;
     815    procedure BMSetCheck(var Message: TMessage); message BM_SETCHECK;
     816    procedure BMGetCheck(var Message: TMessage); message BM_GETCHECK;
     817    procedure BMGetState(var Message: TMessage); message BM_GETSTATE;
    810818    function GetImageList: TCustomImageList;
    811819    function GetImageIndexes: string;
     
    823831    procedure SetAutoSize(Value: boolean); override;
    824832    procedure GetDrawData(CanvasHandle: HDC; var Bitmap: TBitmap;
    825                                              var FocRect, Rect: TRect;
    826                                              var DrawOptions: UINT;
    827                                              var TempBitMap: boolean);
     833      var FocRect, Rect: TRect;
     834      var DrawOptions: UINT;
     835      var TempBitMap: boolean);
    828836    procedure DrawItem(const DrawItemStruct: TDrawItemStruct); dynamic;
    829837    procedure Toggle; override;
     
    908916  private
    909917    FHoverItemPos: integer;
    910     FRightClickSelect: boolean;                  // When true, a right click selects teh item
     918    FRightClickSelect: boolean; // When true, a right click selects teh item
    911919    FHintOnItem: boolean;
    912920    procedure SetCaption(const Value: string);
     
    941949  published
    942950    property Caption: string read GetCaption write SetCaption;
     951    Property CheckWidth: integer Read GetCheckWidth;
    943952  end;
    944953
     
    10101019    procedure KeyUp(var Key: Word; Shift: TShiftState); override;
    10111020  public
    1012     procedure IndexToColRow( index: integer; var Col: integer; var Row: integer);
    1013     function ColRowToIndex( Col: integer; Row: Integer): integer;
     1021    procedure IndexToColRow(index: integer; var Col: integer; var Row: integer);
     1022    function ColRowToIndex(Col: integer; Row: Integer): integer;
    10141023    function SupportsDynamicProperty(PropertyID: integer): boolean;
    10151024    function GetDynamicProperty(PropertyID: integer): string;
     
    10261035procedure GoodNotifyWinEvent(event: DWORD; hwnd: HWND; idObject, idChild: Longint); stdcall;
    10271036
    1028 function CalcShortName( LongName: string; PrevLongName: string): string;
     1037function CalcShortName(LongName: string; PrevLongName: string): string;
    10291038
    10301039{Returns True if any one of 3 mouse buttons are down left, right, or middle}
    1031 function IsAMouseButtonDown : boolean;
    1032 
    1033 implementation  // ---------------------------------------------------------------------------
     1040function IsAMouseButtonDown: boolean;
     1041
     1042implementation // ---------------------------------------------------------------------------
    10341043
    10351044{$R ORCTRLS}
     
    10371046uses
    10381047  VAUtils;
    1039  
     1048
    10401049const
    1041   ALPHA_DISTRIBUTION: array[0..100] of string[3] = ('',' ','ACE','ADG','ALA','AMI','ANA','ANT',
    1042     'ARE','ASU','AZO','BCP','BIC','BOO','BST','CAF','CAR','CD6','CHE','CHO','CMC','CON','CPD',
    1043     'CVI','DAA','DEF','DEP','DIA','DIH','DIP','DP ','EAR','EM ','EPI','ETH','F2G','FIB','FML',
    1044     'FUM','GEL','GLU','GPQ','HAL','HEM','HIS','HUN','HYL','IDS','IND','INT','ISO','KEX','LAN',
    1045     'LEV','LOY','MAG','MAX','MER','MET','MIC','MON','MUD','NAI','NEU','NIT','NUC','OMP','OTH',
    1046     'P42','PAR','PEN','PHA','PHO','PLA','POL','PRA','PRO','PSE','PYR','RAN','REP','RIB','SAA',
    1047     'SCL','SFL','SMO','SPO','STR','SUL','TAG','TET','THI','TOL','TRI','TRY','UNC','VAR','VIT',
    1048     'WRO','ZYM',#127#127#127);
    1049 
    1050   CBO_CYMARGIN =  8;          // vertical whitespace in the edit portion of combobox
    1051   CBO_CXBTN    = 13;          // width of drop down button in combobox
    1052   CBO_CXFRAME  =  5;          // offset to account for frame around the edit part of combobox
    1053 
    1054   NOREDRAW = 0;                // suspend screen updates
    1055   DOREDRAW = 1;                // allow screen updates
    1056 
    1057   KEY_TIMER_DELAY = 500;       // 500 ms delay after key up before OnKeyPause called
    1058   KEY_TIMER_ID = 5800;         // arbitrary, use high number in case TListBox uses timers
     1050  ALPHA_DISTRIBUTION: array[0..100] of string[3] = ('', ' ', 'ACE', 'ADG', 'ALA', 'AMI', 'ANA', 'ANT',
     1051    'ARE', 'ASU', 'AZO', 'BCP', 'BIC', 'BOO', 'BST', 'CAF', 'CAR', 'CD6', 'CHE', 'CHO', 'CMC', 'CON', 'CPD',
     1052    'CVI', 'DAA', 'DEF', 'DEP', 'DIA', 'DIH', 'DIP', 'DP ', 'EAR', 'EM ', 'EPI', 'ETH', 'F2G', 'FIB', 'FML',
     1053    'FUM', 'GEL', 'GLU', 'GPQ', 'HAL', 'HEM', 'HIS', 'HUN', 'HYL', 'IDS', 'IND', 'INT', 'ISO', 'KEX', 'LAN',
     1054    'LEV', 'LOY', 'MAG', 'MAX', 'MER', 'MET', 'MIC', 'MON', 'MUD', 'NAI', 'NEU', 'NIT', 'NUC', 'OMP', 'OTH',
     1055    'P42', 'PAR', 'PEN', 'PHA', 'PHO', 'PLA', 'POL', 'PRA', 'PRO', 'PSE', 'PYR', 'RAN', 'REP', 'RIB', 'SAA',
     1056    'SCL', 'SFL', 'SMO', 'SPO', 'STR', 'SUL', 'TAG', 'TET', 'THI', 'TOL', 'TRI', 'TRY', 'UNC', 'VAR', 'VIT',
     1057    'WRO', 'ZYM', #127#127#127);
     1058
     1059  CBO_CYMARGIN = 8; // vertical whitespace in the edit portion of combobox
     1060  CBO_CXBTN = 13; // width of drop down button in combobox
     1061  CBO_CXFRAME = 5; // offset to account for frame around the edit part of combobox
     1062
     1063  NOREDRAW = 0; // suspend screen updates
     1064  DOREDRAW = 1; // allow screen updates
     1065
     1066  KEY_TIMER_DELAY = 500; // 500 ms delay after key up before OnKeyPause called
     1067  KEY_TIMER_ID = 5800; // arbitrary, use high number in case TListBox uses timers
    10591068
    10601069  { use high word to pass positioning flags since listbox is limited to 32767 items }
    10611070  //SFI_TOP = $80000000;         // top of listbox (decimal value: -2147483648)
    10621071  //SFI_END = $90000000;         // end of listbox (decimal value: -1879048192)
    1063   SFI_TOP = -2147483646;       // top of listbox (hex value: $80000001)
    1064   SFI_END = -1879048192;       // end of listbox (hex value: $90000000)
    1065 
    1066   CheckWidth = 15;  // CheckBox Width space to reserve for TORListBox
     1072  SFI_TOP = -2147483646; // top of listbox (hex value: $80000001)
     1073  SFI_END = -1879048192; // end of listbox (hex value: $90000000)
     1074
     1075  CheckWidth = 15; // CheckBox Width space to reserve for TORListBox
    10671076  CheckComboBtnHeight = 21;
    10681077  MaxNeedDataLen = 64;
     
    10711080  TItemTip = class(TCustomControl)
    10721081  private
    1073     FShowing: Boolean;                           // true when itemtip is visible
    1074     FListBox: TORListBox;                        // current listbox displaying itemtips
     1082    FShowing: Boolean; // true when itemtip is visible
     1083    FListBox: TORListBox; // current listbox displaying itemtips
    10751084    FListItem: integer;
    10761085    FPoint: TPoint;
    10771086    FSelected: boolean;
    1078     FTabs: array[0..MAX_TABS] of Integer;         // Holds the pixel offsets for tabs
     1087    FTabs: array[0..MAX_TABS] of Integer; // Holds the pixel offsets for tabs
    10791088    procedure GetTabSettings;
    10801089  protected
     
    10881097  end;
    10891098
    1090   TSizeRatio = class                             // relative sizes and positions for resizing
     1099  TSizeRatio = class // relative sizes and positions for resizing
    10911100    CLeft: Extended;
    10921101    CTop: Extended;
     
    10971106
    10981107var
    1099   uKeyHookHandle: HHOOK;       // handle to capture key events & hide ItemTip window
    1100   uItemTip: TItemTip;          // ItemTip window
    1101   uItemTipCount: Integer;      // number of ItemTip clients
    1102   uNewStyle: Boolean;          // True if using Windows 95 interface
    1103 
     1108  uKeyHookHandle: HHOOK; // handle to capture key events & hide ItemTip window
     1109  uItemTip: TItemTip; // ItemTip window
     1110  uItemTipCount: Integer; // number of ItemTip clients
     1111  uNewStyle: Boolean; // True if using Windows 95 interface
     1112  HintArray: array of THintRecords;
    11041113{ General functions and procedures --------------------------------------------------------- }
    11051114
     
    11301139    try
    11311140      GetTextExtentPoint32(DC, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 52, Extent);
    1132       Result := Trunc((Extent.cx / 26 + 1) / 2);     // Round() doesn't line up with dialog units
     1141      //Find the average of the width then round up
     1142      Result := Trunc(Extent.cx / 52 ) + 1;
    11331143    finally
    11341144      SelectObject(DC, SaveFont);
     
    12051215  if i < PieceNum
    12061216    then x := x + StringOfChar(Delim, PieceNum - i) + NewPiece
    1207     else x := Copy(x, 1, Strt - PChar(x)) + NewPiece + StrPas(Next);
     1217  else x := Copy(x, 1, Strt - PChar(x)) + NewPiece + StrPas(Next);
    12081218end;
    12091219
     
    12361246    end;
    12371247    ANum := StrToIntDef(Trim(APiece), 0);
    1238     if(ANum > 0) or (AllowNeg and (ANum < 0)) then
     1248    if (ANum > 0) or (AllowNeg and (ANum < 0)) then
    12391249    begin
    12401250      Inc(IntArray[0]);
     
    12621272{ TItemTip --------------------------------------------------------------------------------- }
    12631273
    1264 procedure AddItemTipRef;     // kcm
    1265 begin
    1266   if uItemTipCount = 0 then uItemTip := TItemTip.Create(Application);  // all listboxes share a single ItemTip window
     1274procedure AddItemTipRef; // kcm
     1275begin
     1276  if uItemTipCount = 0 then uItemTip := TItemTip.Create(Application); // all listboxes share a single ItemTip window
    12671277  Inc(uItemTipCount);
    12681278end;
    12691279
    1270 procedure RemoveItemTipRef;  // kcm
     1280procedure RemoveItemTipRef; // kcm
    12711281begin
    12721282  Dec(uItemTipCount);
     
    12951305  Params.Style := WS_POPUP or WS_DISABLED or WS_BORDER;
    12961306  if uNewStyle then Params.ExStyle := WS_EX_TOOLWINDOW;
    1297   Params.ExStyle := Params.ExStyle or WS_EX_TOPMOST;  // - test this!!
     1307  Params.ExStyle := Params.ExStyle or WS_EX_TOPMOST; // - test this!!
    12981308end;
    12991309
     
    13141324// WARNING - Do NOT change the X pos or the tab starting pos - this will cause a missmatch
    13151325// between the hint window and what the control displayes
    1316     TabbedTextOut(Handle, 0, y, PChar(AString), Length(AString), MAX_TABS+1, FTabs[0], 0);
     1326    TabbedTextOut(Handle, 0, y, PChar(AString), Length(AString), MAX_TABS + 1, FTabs[0], 0);
    13171327  end;
    13181328end;
     
    13351345var
    13361346  DX, X, i, count: integer;
    1337  
     1347
    13381348begin
    13391349  Count := FListBox.FTabPix[0];
    1340   FTabs[0] := 1;     // Set first tab stop to location 1 for display purposes
    1341   if(Count = 1) then
     1350  FTabs[0] := 1; // Set first tab stop to location 1 for display purposes
     1351  if (Count = 1) then
    13421352  begin
    13431353    DX := FListBox.FTabPix[1];
     
    13531363  for i := 1 to MAX_TABS do
    13541364  begin
    1355     if(i <= Count) then
     1365    if (i <= Count) then
    13561366      FTabs[i] := FListBox.FTabPix[i] - 1
    13571367    else
     
    13751385    Canvas.Brush.Color := clHighlight;
    13761386    Canvas.Font.Color := clHighlightText;
    1377   end else                                            // the item is not selected
     1387  end else // the item is not selected
    13781388  begin
    13791389    Canvas.Brush.Color := FListBox.ItemTipColor;
     
    13811391  end;
    13821392  Caption := #9 + FListBox.DisplayText[FListItem];
    1383   if Copy(Caption, 1, 2) = '__' then Caption := ' ';  // so separators don't extend past window
     1393  if Copy(Caption, 1, 2) = '__' then Caption := ' '; // so separators don't extend past window
    13841394
    13851395  GetTabSettings;
    13861396
    13871397  AWidth := LOWORD(GetTabbedTextExtent(Canvas.Handle, PChar(Caption), Length(Caption),
    1388     MAX_TABS+1, FTabs[0]));
     1398    MAX_TABS + 1, FTabs[0]));
    13891399  // inherent scrollbar may not always be visible in a long list
    13901400  if FListBox.LongList
    13911401    then ListClientWidth := ClientWidthOfList(FListBox)
    1392     else ListClientWidth := FListBox.ClientWidth;
     1402  else ListClientWidth := FListBox.ClientWidth;
    13931403  X := FPoint.X;
    1394   if(FListBox.FCheckBoxes) then
     1404  if (FListBox.FCheckBoxes) then
    13951405  begin
    13961406    dec(ListClientWidth, CheckWidth);
     
    14141424  if (GetCaptureControl = nil) and CatchMouse then FListBox.MouseCapture := True;
    14151425  SetWindowPos(Handle, HWND_TOP, X, FPoint.Y, AWidth, FListBox.ItemHeight,
    1416                SWP_SHOWWINDOW or SWP_NOACTIVATE);
     1426    SWP_SHOWWINDOW or SWP_NOACTIVATE);
    14171427  Invalidate;
    14181428end;
     
    14221432{ sets the canvas properties and window size and text depending on the item in the listbox }
    14231433begin
    1424   if not AListBox.Visible then Exit;                  // added to support DropDown lists
     1434  if not AListBox.Visible then Exit; // added to support DropDown lists
    14251435  FListBox := AListBox;
    14261436  FListItem := AnItem;
     
    14321442type
    14331443  TORCBImgIdx = (iiUnchecked, iiChecked, iiGrayed, iiQMark, iiBlueQMark,
    1434                  iiDisUnchecked, iiDisChecked, iiDisGrayed, iiDisQMark,
    1435                  iiFlatUnChecked, iiFlatChecked, iiFlatGrayed,
    1436                  iiRadioUnchecked, iiRadioChecked, iiRadioDisUnchecked, iiRadioDisChecked);
     1444    iiDisUnchecked, iiDisChecked, iiDisGrayed, iiDisQMark,
     1445    iiFlatUnChecked, iiFlatChecked, iiFlatGrayed,
     1446    iiRadioUnchecked, iiRadioChecked, iiRadioDisUnchecked, iiRadioDisChecked);
    14371447
    14381448const
     
    14451455    'ORCB_RADIO_DISABLED_UNCHECKED', 'ORCB_RADIO_DISABLED_CHECKED');
    14461456
    1447    BlackCheckBoxImageResNames: array[TORCBImgIdx] of PChar = (
     1457  BlackCheckBoxImageResNames: array[TORCBImgIdx] of PChar = (
    14481458    'BLACK_ORLB_FLAT_UNCHECKED', 'BLACK_ORLB_FLAT_CHECKED', 'BLACK_ORLB_FLAT_GRAYED',
    14491459    'BLACK_ORCB_QUESTIONMARK', 'BLACK_ORCB_BLUEQUESTIONMARK',
     
    14531463    'BLACK_ORCB_RADIO_UNCHECKED', 'BLACK_ORCB_RADIO_CHECKED',
    14541464    'BLACK_ORCB_RADIO_DISABLED_UNCHECKED', 'BLACK_ORCB_RADIO_DISABLED_CHECKED');
    1455  
     1465
    14561466var
    14571467  ORCBImages: array[TORCBImgIdx, Boolean] of TBitMap;
     
    14611471  ResName: string;
    14621472begin
    1463   if(not assigned(ORCBImages[Idx, BlackMode])) then
     1473  if (not assigned(ORCBImages[Idx, BlackMode])) then
    14641474  begin
    14651475    ORCBImages[Idx, BlackMode] := TBitMap.Create;
     
    14831493    for Mode := false to true do
    14841494    begin
    1485       if(assigned(ORCBImages[i, Mode])) then
     1495      if (assigned(ORCBImages[i, Mode])) then
    14861496        ORCBImages[i, Mode].Free;
    14871497    end;
     
    14911501{ TORStrings }
    14921502
    1493 function TORStrings.Add(const S: string): integer; 
     1503function TORStrings.Add(const S: string): integer;
    14941504var
    14951505  RealVerification: Boolean;
     
    15801590var
    15811591  RealVerification: Boolean;
    1582 begin  //If this method weren't overridden, the listbox would forget which item was selected.
     1592begin //If this method weren't overridden, the listbox would forget which item was selected.
    15831593  MList[Index] := S;
    15841594  RealVerification := Verification;
     
    16111621  if Verification then begin
    16121622    if not Assigned(FPlainText) then
    1613       raise Exception.Create( 'ORStrings is missing PlainText property.');
     1623      raise Exception.Create('ORStrings is missing PlainText property.');
    16141624    if not Assigned(FTranslator) then
    1615       raise Exception.Create( 'ORStrings is missing Translator property.');
     1625      raise Exception.Create('ORStrings is missing Translator property.');
    16161626    Errors := TStringList.Create;
    16171627    try
    16181628      TotalCount := MList.Count;
    16191629      if MList.Count <> PlainText.Count then begin
    1620         Errors.Add('M string count:'+IntToStr(MList.Count));
    1621         Errors.Add('Plain string count:'+IntToStr(PlainText.Count));
     1630        Errors.Add('M string count:' + IntToStr(MList.Count));
     1631        Errors.Add('Plain string count:' + IntToStr(PlainText.Count));
    16221632        if PlainText.Count > TotalCount then
    16231633          TotalCount := PlainText.Count;
     
    16251635      for i := 0 to TotalCount - 1 do begin
    16261636        if i >= MList.Count then
    1627           Errors.Add('PlainText['+IntToStr(i)+']: '+PlainText[i])
     1637          Errors.Add('PlainText[' + IntToStr(i) + ']: ' + PlainText[i])
    16281638        else if i >= PlainText.Count then
    1629           Errors.Add('ORStrings['+IntToStr(i)+']: '+Translator(MList[i]))
     1639          Errors.Add('ORStrings[' + IntToStr(i) + ']: ' + Translator(MList[i]))
    16301640        else begin
    16311641          M := Translator(MList[i]);
    16321642          Plain := PlainText[i];
    16331643          if M <> Plain then begin
    1634             if UpperCase(M) = UpperCase(Plain) then  //Listboxes don't always sort cases right, so we give them a little help here.
     1644            if UpperCase(M) = UpperCase(Plain) then //Listboxes don't always sort cases right, so we give them a little help here.
    16351645            begin
    16361646              PlainText[i] := M;
     
    16381648            else
    16391649            begin
    1640               Errors.Add('PlainText['+IntToStr(i)+']: '+Plain);
    1641               Errors.Add('ORStrings['+IntToStr(i)+']: '+M);
     1650              Errors.Add('PlainText[' + IntToStr(i) + ']: ' + Plain);
     1651              Errors.Add('ORStrings[' + IntToStr(i) + ']: ' + M);
    16421652            end;
    16431653          end;
     
    16451655      end;
    16461656      if Errors.Count > 0 then begin
    1647         Errors.Insert( 0, 'OR strings are out of sync with plain text strings :');
    1648         raise Exception.Create( Errors.Text);
     1657        Errors.Insert(0, 'OR strings are out of sync with plain text strings :');
     1658        raise Exception.Create(Errors.Text);
    16491659      end;
    16501660    finally
     
    16911701  if uItemTip <> nil then uItemTip.Hide;
    16921702  DestroyItems;
    1693   RemoveItemTipRef;  //kcm
     1703  RemoveItemTipRef; //kcm
    16941704  inherited Destroy;
    16951705end;
     
    17111721  FFromSelf := True;
    17121722  RealVerification := True;
    1713   if Assigned( FMItems ) then
     1723  if Assigned(FMItems) then
    17141724  begin
    17151725    RealVerification := FMItems.Verification;
     
    17171727  end;
    17181728  inherited CreateWnd;
    1719   if Assigned( FMItems ) then
     1729  if Assigned(FMItems) then
    17201730  begin
    17211731    FMItems.Verification := RealVerification;
     
    17631773function TORListBox.IsSynonym(const TestStr: string): boolean;
    17641774var
    1765   i,cnt,len :integer;
     1775  i, cnt, len: integer;
    17661776
    17671777begin
    17681778  Result := FALSE;
    1769   if((FHideSynonyms) and (FSynonymChars <> '')) then
     1779  if ((FHideSynonyms) and (FSynonymChars <> '')) then
    17701780  begin
    17711781    len := length(FSynonymChars);
    17721782    cnt := 0;
    17731783    for i := 1 to len do
    1774       if(pos(FSynonymChars[i], TestStr)>0) then inc(cnt);
    1775     if(cnt = len) then Result := TRUE;
     1784      if (pos(FSynonymChars[i], TestStr) > 0) then inc(cnt);
     1785    if (cnt = len) then Result := TRUE;
    17761786    if assigned(FOnSynonymCheck) then
    17771787      FOnSynonymCheck(Self, TestStr, Result);
     
    17871797  Result := '';
    17881798  FFromSelf := True;
    1789   Len := SendMessage(Handle,LB_GETTEXT, Index, Integer(@Buf));
     1799  Len := SendMessage(Handle, LB_GETTEXT, Index, Integer(@Buf));
    17901800  FFromSelf := False;
    17911801  if Len > 0 then
     
    18181828  inherited;
    18191829  if not FFromSelf then with Message do
    1820   begin
    1821     ItemRec := PItemRec(Result);
    1822     if(assigned(ItemRec)) then
    1823       Result := Integer(ItemRec^.UserObject)
    1824     else
    1825       Result := 0;
    1826   end;
     1830    begin
     1831      ItemRec := PItemRec(Result);
     1832      if (assigned(ItemRec)) then
     1833        Result := Integer(ItemRec^.UserObject)
     1834      else
     1835        Result := 0;
     1836    end;
    18271837end;
    18281838
     
    18331843begin
    18341844  if not FFromSelf then with Message do
    1835   begin
    1836     FFromSelf := True;
    1837     ItemRec := PItemRec(SendMessage(Handle,LB_GETITEMDATA, WParam, 0)); // WParam: list index
    1838     FFromSelf := False;
    1839     if(assigned(ItemRec)) then
    1840       ItemRec^.UserObject := TObject(LParam);
    1841     LParam := Integer(ItemRec);
    1842     if uItemTip.FShowing and (uItemTip.FListBox = Self) and (uItemTip.FListItem = WParam) then
    1843       uItemTip.UpdateText(FALSE);
    1844   end;
     1845    begin
     1846      FFromSelf := True;
     1847      ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, WParam, 0)); // WParam: list index
     1848      FFromSelf := False;
     1849      if (assigned(ItemRec)) then
     1850        ItemRec^.UserObject := TObject(LParam);
     1851      LParam := Integer(ItemRec);
     1852      if uItemTip.FShowing and (uItemTip.FListBox = Self) and (uItemTip.FListItem = WParam) then
     1853        uItemTip.UpdateText(FALSE);
     1854    end;
    18451855  inherited;
    18461856end;
     
    18541864  inherited;
    18551865  if (not FFromSelf) and (Message.Result <> LB_ERR) then with Message do
    1856   begin
    1857     FFromSelf := True;
    1858     ItemRec := PItemRec(SendMessage(Handle,LB_GETITEMDATA, WParam, 0));  // WParam: list index
    1859     FFromSelf := False;
    1860     if(assigned(ItemRec)) then
    18611866    begin
    18621867      FFromSelf := True;
    1863       Text := TListBox(self).Items[WParam];
    1864       StrCopy(PChar(LParam), PChar(Text));          // LParam: points string buffer
    1865       Result := Length(Text);                       // Result: length of string
     1868      ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, WParam, 0)); // WParam: list index
    18661869      FFromSelf := False;
    1867     end
    1868     else
    1869     begin
    1870       StrPCopy(PChar(LParam),'');
    1871       Result := 0;
    1872     end;
    1873   end;
    1874 end;
     1870      if (assigned(ItemRec)) then
     1871      begin
     1872        FFromSelf := True;
     1873        Text := TListBox(self).Items[WParam];
     1874        StrCopy(PChar(LParam), PChar(Text)); // LParam: points string buffer
     1875        Result := Length(Text); // Result: length of string
     1876        FFromSelf := False;
     1877      end
     1878      else
     1879      begin
     1880        StrPCopy(PChar(LParam), '');
     1881        Result := 0;
     1882      end;
     1883    end;
     1884end;
     1885
    18751886procedure TORListBox.LBGetTextLen(var Message: TMessage);
    18761887{ intercept LB_GETTEXTLEN and return true length of ItemRec^.FullText }
     
    18811892  inherited;
    18821893  if (not FFromSelf) and (Message.Result <> LB_ERR) then with Message do
    1883   begin
    1884     FFromSelf := True;
    1885     ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, WParam, 0));
    1886     if(assigned(ItemRec)) then
    1887       Result := Length(TListBox(self).Items[WParam])    // Result:length of string
    1888     else
    1889       Result := 0;
    1890     FFromSelf := False;
    1891   end;
     1894    begin
     1895      FFromSelf := True;
     1896      ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, WParam, 0));
     1897      if (assigned(ItemRec)) then
     1898        Result := Length(TListBox(self).Items[WParam]) // Result:length of string
     1899      else
     1900        Result := 0;
     1901      FFromSelf := False;
     1902    end;
    18921903end;
    18931904
     
    19001911  if not FFromSelf then
    19011912  begin
    1902     if FLongList then                               // -- special long list processing - begin
     1913    if FLongList then // -- special long list processing - begin
    19031914    begin
    19041915      if FFromNeedData then FDataAdded := True else with Message do
    1905       begin
    1906         WParam := FWaterMark;
    1907         Result := Perform(LB_INSERTSTRING, WParam, LParam);  // always insert into short list
    1908         Exit;
    1909       end;
    1910     end;                                            // -- special long list processing - end
     1916        begin
     1917          WParam := FWaterMark;
     1918          Result := Perform(LB_INSERTSTRING, WParam, LParam); // always insert into short list
     1919          Exit;
     1920        end;
     1921    end; // -- special long list processing - end
    19111922    New(ItemRec);
    19121923    with ItemRec^, Message do
     
    19221933    DoChange;
    19231934    with Message do if Result <> LB_ERR then
    1924     begin
    1925       FFromSelf := True;
    1926       SendMessage(Handle,LB_SETITEMDATA, Result, Integer(ItemRec)); // Result: new item index
    1927       FFromSelf := False;
    1928     end
    1929     else Dispose(ItemRec);
     1935      begin
     1936        FFromSelf := True;
     1937        SendMessage(Handle, LB_SETITEMDATA, Result, Integer(ItemRec)); // Result: new item index
     1938        FFromSelf := False;
     1939      end
     1940      else Dispose(ItemRec);
    19301941  end
    19311942  else inherited;
     
    19391950  if not FFromSelf then
    19401951  begin
    1941     if FLongList then                               // -- special long list processing - begin
     1952    if FLongList then // -- special long list processing - begin
    19421953    begin
    19431954      if FFromNeedData then
     
    19471958      end
    19481959      else with Message do
    1949       begin
    1950         if WParam > FWaterMark then
    1951         begin                                       // make sure insert above watermark
    1952           FMItems.MList.Move(WParam,FWaterMark);
    1953           WParam := FWaterMark;
     1960        begin
     1961          if WParam > FWaterMark then
     1962          begin // make sure insert above watermark
     1963            FMItems.MList.Move(WParam, FWaterMark);
     1964            WParam := FWaterMark;
     1965          end;
     1966          Inc(FWaterMark);
    19541967        end;
    1955         Inc(FWaterMark);
    1956       end;
    1957     end;                                            // -- special long list processing - end
     1968    end; // -- special long list processing - end
    19581969    New(ItemRec);
    19591970    with ItemRec^, Message do
     
    19681979    DoChange;
    19691980    with Message do if Result <> LB_ERR then
    1970     begin
    1971       FFromSelf := True;
    1972       SendMessage(Handle,LB_SETITEMDATA, Result, Integer(ItemRec)); // Result: new item index
    1973       FFromSelf := False;
    1974     end
    1975     else Dispose(ItemRec);
     1981      begin
     1982        FFromSelf := True;
     1983        SendMessage(Handle, LB_SETITEMDATA, Result, Integer(ItemRec)); // Result: new item index
     1984        FFromSelf := False;
     1985      end
     1986      else Dispose(ItemRec);
    19761987  end
    19771988  else inherited;
     
    19861997  begin
    19871998    FFromSelf := True;
    1988     ItemRec := PItemRec(SendMessage(Handle,LB_GETITEMDATA, WParam, 0)); // WParam: list index
     1999    ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, WParam, 0)); // WParam: list index
    19892000    FFromSelf := False;
    1990     if(assigned(ItemRec)) then
     2001    if (assigned(ItemRec)) then
    19912002    begin
    19922003      if FLongList and not FFromNeedData then
     
    19952006    end;
    19962007  end;
    1997   FFromSelf := True;   // FFromSelf is set here because, under NT, LBResetContent is called
    1998   inherited;           // when deleting the last string from the listbox.  Since ItemRec is
    1999   FFromSelf := False;  // already disposed, it shouldn't be disposed again.
     2008  FFromSelf := True; // FFromSelf is set here because, under NT, LBResetContent is called
     2009  inherited; // when deleting the last string from the listbox.  Since ItemRec is
     2010  FFromSelf := False; // already disposed, it shouldn't be disposed again.
    20002011  DoChange;
    20012012end;
     
    20132024    begin
    20142025      FFromSelf := True;
    2015       ItemRec := PItemRec(SendMessage(Handle,LB_GETITEMDATA, i, 0));
     2026      ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, i, 0));
    20162027      FFromSelf := False;
    20172028      Dispose(ItemRec);
     
    20492060  case Message.CharCode of
    20502061    VK_LBUTTON, VK_RETURN, VK_SPACE:
    2051     begin
    2052       if (FocusIndex < 0) and (CheckBoxes or MultiSelect) and (Count > 0) then // JNM - 508 compliance
    2053         SetFocusIndex(0);
    2054       if FocusIndex > -1 then
    20552062      begin
    2056         if MultiSelect then
     2063        if (FocusIndex < 0) and (CheckBoxes or MultiSelect) and (Count > 0) then // JNM - 508 compliance
     2064          SetFocusIndex(0);
     2065        if FocusIndex > -1 then
    20572066        begin
    2058           IsSelected := LongBool(Perform(LB_GETSEL, FocusIndex, 0));
    2059           Perform(LB_SETSEL, Longint(not IsSelected), FocusIndex);
    2060         end
    2061         else Perform(LB_SETCURSEL, FocusIndex, 0);
     2067          if MultiSelect then
     2068          begin
     2069            IsSelected := LongBool(Perform(LB_GETSEL, FocusIndex, 0));
     2070            Perform(LB_SETSEL, Longint(not IsSelected), FocusIndex);
     2071          end
     2072          else Perform(LB_SETCURSEL, FocusIndex, 0);
    20622073        // Send WM_COMMAND here because LBN_SELCHANGE not triggered by LB_SETSEL
    20632074        // and LBN_SELCHANGE is what eventually triggers the Click event.
     
    20672078        //PostMessage() not SendMessage() is Required here for checkboxes, SendMessage() doesn't
    20682079        //Allow the Checkbox state on the control to be updated
    2069         if CheckBoxes then
    2070           PostMessage(Parent.Handle, WM_COMMAND, MAKELONG(FocusIndex, LBN_SELCHANGE), LPARAM(Handle))
    2071         else
    2072           SendMessage(Parent.Handle, WM_COMMAND, MAKELONG(FocusIndex, LBN_SELCHANGE), LPARAM(Handle));
     2080          if CheckBoxes then
     2081            PostMessage(Parent.Handle, WM_COMMAND, MAKELONG(FocusIndex, LBN_SELCHANGE), LPARAM(Handle))
     2082          else
     2083            SendMessage(Parent.Handle, WM_COMMAND, MAKELONG(FocusIndex, LBN_SELCHANGE), LPARAM(Handle));
     2084        end;
    20732085      end;
    2074     end;
    2075     VK_PRIOR:          SetFocusIndex(FocusIndex - FLargeChange);
    2076     VK_NEXT:           SetFocusIndex(FocusIndex + FLargeChange);
    2077     VK_END:            SetFocusIndex(SFI_END);
    2078     VK_HOME:           SetFocusIndex(SFI_TOP);
    2079     VK_LEFT, VK_UP:    SetFocusIndex(FocusIndex - 1);
     2086    VK_PRIOR: SetFocusIndex(FocusIndex - FLargeChange);
     2087    VK_NEXT: SetFocusIndex(FocusIndex + FLargeChange);
     2088    VK_END: SetFocusIndex(SFI_END);
     2089    VK_HOME: SetFocusIndex(SFI_TOP);
     2090    VK_LEFT, VK_UP: SetFocusIndex(FocusIndex - 1);
    20802091    VK_RIGHT, VK_DOWN: SetFocusIndex(FocusIndex + 1);
    2081     else inherited;
     2092  else inherited;
    20822093  end;
    20832094  Message.Result := 0;
     
    20942105begin
    20952106  if FParentCombo <> nil then with Message do
    2096   begin
    2097     FDontClose := FALSE;
    2098     ListRect := ClientRect;                                                      //+
    2099     if FLongList then ListRect.Right := ListRect.Left + ClientWidthOfList(Self); //+
     2107    begin
     2108      FDontClose := FALSE;
     2109      ListRect := ClientRect; //+
     2110      if FLongList then ListRect.Right := ListRect.Left + ClientWidthOfList(Self); //+
    21002111    // if the mouse was clicked in the client area set ItemIndex ourselves
    2101     if PtInRect(ListRect, Point(XPos, YPos)) then                                //~
    2102     begin
    2103       AnItem := GetIndexFromY(YPos);
    2104       if AnItem < Items.Count then ItemIndex := AnItem;
    2105       FParentCombo.FwdClick(FParentCombo);
    2106       FDontClose := TRUE;
    2107     end;
     2112      if PtInRect(ListRect, Point(XPos, YPos)) then //~
     2113      begin
     2114        AnItem := GetIndexFromY(YPos);
     2115        if AnItem < Items.Count then ItemIndex := AnItem;
     2116        FParentCombo.FwdClick(FParentCombo);
     2117        FDontClose := TRUE;
     2118      end;
    21082119    // if the mouse was clicked on the scrollbar, send a message to make the scrolling happen
    21092120    // this is done with WM_NCLBUTTONDOWN, which is ignored if mousecapture is on, so we have
    21102121    // to turn mousecapture off, then back on since it's needed to hide the listbox
    2111     with ListRect do ScrollRect := Rect(Right + 1, Top, Self.Width - 2, Bottom); //~
    2112     if {(Items.Count > (FLargeChange + 1)) and} PtInRect(ScrollRect, Point(XPos, YPos)) then //~
    2113     begin
    2114       if FLongList then                                                    // for long lists
     2122      with ListRect do ScrollRect := Rect(Right + 1, Top, Self.Width - 2, Bottom); //~
     2123      if {(Items.Count > (FLargeChange + 1)) and} PtInRect(ScrollRect, Point(XPos, YPos)) then //~
    21152124      begin
    2116         ScreenPoint := PointToSmallPoint(FScrollBar.ScreenToClient(
    2117                                          Self.ClientToScreen(Point(XPos, YPos))));
    2118         MouseCapture := False;
    2119         SendMessage(FScrollBar.Handle, WM_LBUTTONDOWN, Message.Keys,
    2120                     MakeLParam(ScreenPoint.X, ScreenPoint.Y));
    2121         MouseCapture := True;
    2122       end else                                                             // for normal lists
    2123       begin
    2124         ScreenPoint := PointToSmallPoint(Self.ClientToScreen(Point(XPos, YPos)));
    2125         MouseCapture := False;
    2126         SendMessage(Self.Handle, WM_NCLBUTTONDOWN, HTVSCROLL,
    2127                     MakeLParam(ScreenPoint.X, ScreenPoint.Y));
    2128         MouseCapture := True;
    2129       end;
    2130     end
    2131     else
    2132     if(FCheckBoxes) then
    2133     begin
    2134       TmpRect := ListRect;
    2135       TmpRect.Top := TmpRect.Bottom;
    2136       TmpRect.Right := TmpRect.Left + Width;
    2137       inc(TmpRect.Bottom, CheckComboBtnHeight);
    2138       if PtInRect(TmpRect, Point(XPos, YPos)) then
    2139       begin
    2140         inc(TmpRect.Left, (TmpRect.right - TmpRect.Left) div 2);
    2141         FParentCombo.DropPanelBtnPressed(XPos <= TmpRect.Left, FALSE);
    2142       end;
    2143     end;
    2144   end;
     2125        if FLongList then // for long lists
     2126        begin
     2127          ScreenPoint := PointToSmallPoint(FScrollBar.ScreenToClient(
     2128            Self.ClientToScreen(Point(XPos, YPos))));
     2129          MouseCapture := False;
     2130          SendMessage(FScrollBar.Handle, WM_LBUTTONDOWN, Message.Keys,
     2131            MakeLParam(ScreenPoint.X, ScreenPoint.Y));
     2132          MouseCapture := True;
     2133        end else // for normal lists
     2134        begin
     2135          ScreenPoint := PointToSmallPoint(Self.ClientToScreen(Point(XPos, YPos)));
     2136          MouseCapture := False;
     2137          SendMessage(Self.Handle, WM_NCLBUTTONDOWN, HTVSCROLL,
     2138            MakeLParam(ScreenPoint.X, ScreenPoint.Y));
     2139          MouseCapture := True;
     2140        end;
     2141      end
     2142      else
     2143        if (FCheckBoxes) then
     2144        begin
     2145          TmpRect := ListRect;
     2146          TmpRect.Top := TmpRect.Bottom;
     2147          TmpRect.Right := TmpRect.Left + Width;
     2148          inc(TmpRect.Bottom, CheckComboBtnHeight);
     2149          if PtInRect(TmpRect, Point(XPos, YPos)) then
     2150          begin
     2151            inc(TmpRect.Left, (TmpRect.right - TmpRect.Left) div 2);
     2152            FParentCombo.DropPanelBtnPressed(XPos <= TmpRect.Left, FALSE);
     2153          end;
     2154        end;
     2155    end;
    21452156  inherited;
    21462157end;
     
    21622173
    21632174begin
    2164   if(FRightClickSelect and (FParentCombo = nil)) then with Message do // List Boxes only, not Combo Boxes
    2165   begin
    2166     ListRect := ClientRect;                                                      //+
    2167     if FLongList then ListRect.Right := ListRect.Left + ClientWidthOfList(Self); //+
     2175  if (FRightClickSelect and (FParentCombo = nil)) then with Message do // List Boxes only, not Combo Boxes
     2176    begin
     2177      ListRect := ClientRect; //+
     2178      if FLongList then ListRect.Right := ListRect.Left + ClientWidthOfList(Self); //+
    21682179    // if the mouse was clicked in the client area set ItemIndex ourselves
    2169     if PtInRect(ListRect, Point(XPos, YPos)) then                                //~
    2170     begin
    2171       AnItem := GetIndexFromY(YPos);
    2172       if AnItem >= Items.Count then AnItem := -1;
    2173     end
    2174     else
    2175       AnItem := -1;
    2176     ItemIndex := AnItem;
    2177   end;
     2180      if PtInRect(ListRect, Point(XPos, YPos)) then //~
     2181      begin
     2182        AnItem := GetIndexFromY(YPos);
     2183        if AnItem >= Items.Count then AnItem := -1;
     2184      end
     2185      else
     2186        AnItem := -1;
     2187      ItemIndex := AnItem;
     2188    end;
    21782189  inherited;
    21792190end;
     
    21862197begin
    21872198  if FParentCombo <> nil then with Message do
    2188   begin
    2189     if(FCheckBoxes) then FDontClose := TRUE;
     2199    begin
     2200      if (FCheckBoxes) then FDontClose := TRUE;
    21902201    // if the mouse was clicked on the scrollbar, send a message to make the scrolling happen
    21912202    // this is done with WM_NCLBUTTONDOWN, which is ignored if mousecapture is on, so we have
    21922203    // to turn mousecapture off, then back on since it's needed to hide the listbox
    2193     with ClientRect do ScrollRect := Rect(Right + 1, Top, Self.Width - 2, Bottom);
    2194     if (Items.Count > (FLargeChange + 1)) and PtInRect(ScrollRect, Point(XPos, YPos)) then
    2195     begin
    2196       if FLongList then                                                    // for long lists
     2204      with ClientRect do ScrollRect := Rect(Right + 1, Top, Self.Width - 2, Bottom);
     2205      if (Items.Count > (FLargeChange + 1)) and PtInRect(ScrollRect, Point(XPos, YPos)) then
    21972206      begin
    2198         ScreenPoint := PointToSmallPoint(FScrollBar.ScreenToClient(
    2199                                          Self.ClientToScreen(Point(XPos, YPos))));
    2200         MouseCapture := False;
    2201         SendMessage(FScrollBar.Handle, WM_LBUTTONDOWN, Message.Keys,
    2202                     MakeLParam(ScreenPoint.X, ScreenPoint.Y));
    2203         MouseCapture := True;
    2204       end else                                                             // for normal lists
    2205       begin
    2206         ScreenPoint := PointToSmallPoint(Self.ClientToScreen(Point(XPos, YPos)));
    2207         MouseCapture := False;
    2208         SendMessage(Self.Handle, WM_NCLBUTTONDOWN, HTVSCROLL,
    2209                     MakeLParam(ScreenPoint.X, ScreenPoint.Y));
    2210         MouseCapture := True;
    2211       end; {if FLongList}
    2212     end; {if (Items.Count)}
    2213   end; {if FParentCombo}
     2207        if FLongList then // for long lists
     2208        begin
     2209          ScreenPoint := PointToSmallPoint(FScrollBar.ScreenToClient(
     2210            Self.ClientToScreen(Point(XPos, YPos))));
     2211          MouseCapture := False;
     2212          SendMessage(FScrollBar.Handle, WM_LBUTTONDOWN, Message.Keys,
     2213            MakeLParam(ScreenPoint.X, ScreenPoint.Y));
     2214          MouseCapture := True;
     2215        end else // for normal lists
     2216        begin
     2217          ScreenPoint := PointToSmallPoint(Self.ClientToScreen(Point(XPos, YPos)));
     2218          MouseCapture := False;
     2219          SendMessage(Self.Handle, WM_NCLBUTTONDOWN, HTVSCROLL,
     2220            MakeLParam(ScreenPoint.X, ScreenPoint.Y));
     2221          MouseCapture := True;
     2222        end; {if FLongList}
     2223      end; {if (Items.Count)}
     2224    end; {if FParentCombo}
    22142225  inherited;
    22152226end;
     
    22582269  GetCursorPos(APoint);
    22592270  APoint := ScreenToClient(APoint);
    2260   MouseMove([], APoint.X, APoint.Y);                // assume nothing in ShiftState for now
     2271  MouseMove([], APoint.X, APoint.Y); // assume nothing in ShiftState for now
    22612272end;
    22622273
     
    23112322procedure TORListBox.DestroyItems;
    23122323var
    2313   ItemCount,i: Integer;
     2324  ItemCount, i: Integer;
    23142325  ItemRec: PItemRec;
    23152326
    23162327begin
    2317   if(not FItemsDestroyed) then
     2328  if (not FItemsDestroyed) then
    23182329  begin
    23192330    ItemCount := Perform(LB_GETCOUNT, 0, 0);
     
    23212332    begin
    23222333      FFromSelf := True;
    2323       ItemRec := PItemRec(SendMessage(Handle,LB_GETITEMDATA, i, 0));
     2334      ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, i, 0));
    23242335      FFromSelf := False;
    23252336      if Assigned(ItemRec) then
     
    23382349
    23392350begin
    2340   if(not FCheckBoxes) or (idx < 0) or (idx >= Items.Count) then exit;
     2351  if (not FCheckBoxes) or (idx < 0) or (idx >= Items.Count) then exit;
    23412352  OldFromSelf := FFromSelf;
    23422353  FFromSelf := True;
    2343   ItemRec := PItemRec(SendMessage(Handle,LB_GETITEMDATA, idx, 0));
     2354  ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, idx, 0));
    23442355  FFromSelf := OldFromSelf;
    2345   if(assigned(ItemRec)) then
    2346   begin
    2347     if(FAllowGrayed) then
     2356  if (assigned(ItemRec)) then
     2357  begin
     2358    if (FAllowGrayed) then
    23482359    begin
    23492360      case ItemRec^.CheckedState of
    23502361        cbUnchecked: ItemRec^.CheckedState := cbGrayed;
    2351         cbGrayed:    ItemRec^.CheckedState := cbChecked;
    2352         cbChecked:   ItemRec^.CheckedState := cbUnchecked;
     2362        cbGrayed: ItemRec^.CheckedState := cbChecked;
     2363        cbChecked: ItemRec^.CheckedState := cbUnchecked;
    23532364      end;
    23542365    end
    23552366    else
    23562367    begin
    2357       if(ItemRec^.CheckedState = cbUnchecked) then
     2368      if (ItemRec^.CheckedState = cbUnchecked) then
    23582369        ItemRec^.CheckedState := cbChecked
    23592370      else
     
    23632374  Rect := ItemRect(Idx);
    23642375  InvalidateRect(Handle, @Rect, FALSE);
    2365   if(assigned(FOnClickCheck)) then
     2376  if (assigned(FOnClickCheck)) then
    23662377    FOnClickCheck(Self, idx);
    2367   if(assigned(FParentCombo)) then
     2378  if (assigned(FParentCombo)) then
    23682379    FParentCombo.UpdateCheckEditBoxText;
    23692380end;
     
    23892400  uItemTip.Hide;
    23902401  inherited MouseDown(Button, Shift, X, Y);
    2391   if(FCheckBoxes) and (X >= 0) and (X <= Width) and (Y >= 0) and (Y <= Height) then
     2402  if (FCheckBoxes) and (X >= 0) and (X <= Width) and (Y >= 0) and (Y <= Height) then
    23922403  begin
    23932404    idx := GetIndexFromY(Y);
    2394     if(idx >= 0) then
    2395     begin
    2396       if(FCheckEntireLine) then
     2405    if (idx >= 0) then
     2406    begin
     2407      if (FCheckEntireLine) then
    23972408        ToggleCheckBox(idx)
    23982409      else
    2399         if(X < CheckWidth) then ToggleCheckBox(idx);
    2400     end;
     2410        if (X < CheckWidth) then ToggleCheckBox(idx);
     2411    end;
     2412  end;
     2413end;
     2414
     2415procedure TORListBox.SetHintProperties(Restore: Boolean; MainForm: TComponent);
     2416var
     2417  i, x: integer;
     2418  Component: TComponent;
     2419begin
     2420   //Clear the array if we are not restoring it
     2421  if not restore then SetLength(HintArray, 0);
     2422
     2423  //Loop through all the components on the form
     2424  for i := 0 to TForm(MainForm).ComponentCount - 1 do begin
     2425    Component := TForm(MainForm).Components[i];
     2426    if (Component is TControl) then begin
     2427      if not restore then begin
     2428        //Increase our array and set our record
     2429        SetLength(HintArray, Length(HintArray) + 1);
     2430        HintArray[high(HintArray)].ObjectName := Component.Name;
     2431        HintArray[high(HintArray)].ObjectHint := GetStrProp(Component, 'Hint');
     2432        //Now clear out the component's hint
     2433        SetStrProp(Component, 'Hint', '');
     2434      end else begin
     2435        //Loop through the array and find this component's hint
     2436        for x := Low(HintArray) to High(HintArray) do begin
     2437          if Component.Name = HintArray[x].ObjectName then begin
     2438            //Once found reset the hint and break out of the loop
     2439            SetStrProp(Component, 'Hint', HintArray[x].ObjectHint);
     2440            break;
     2441          end;
     2442        end;
     2443      end;
     2444    end;
     2445  end;
     2446
     2447  //Now deal with the form itself
     2448  if not restore then begin
     2449    //Increase our array and set our record
     2450    SetLength(HintArray, Length(HintArray) + 1);
     2451    HintArray[high(HintArray)].ObjectName := TForm(MainForm).Name;
     2452    HintArray[high(HintArray)].ObjectHint := TForm(MainForm).Hint;
     2453    //Now clear out the Forms's hint
     2454    TForm(MainForm).Hint := '';
     2455  end else begin
     2456      //Loop through the array and find this Forms's hint
     2457    for x := Low(HintArray) to High(HintArray) do begin
     2458      if TForm(MainForm).Name = HintArray[x].ObjectName then begin
     2459        //Once found reset the hint and break out of the loop
     2460        TForm(MainForm).Hint := HintArray[x].ObjectHint;
     2461        break;
     2462      end;
     2463    end;
     2464    //Now clear the arrau since we are done using it
     2465    SetLength(HintArray, 0);
    24012466  end;
    24022467end;
     
    24082473var
    24092474  AnItem: Integer;
    2410   TrueOffset :integer;
     2475  TrueOffset: integer;
    24112476  TipPos: TPoint;
    24122477begin
    24132478  inherited MouseMove(Shift, X, Y);
     2479
     2480  //If the drop down is visible and the hint hasn't been changed then clear the hint and save    the original hint
     2481  if assigned(FParentCombo) then begin
     2482    //agp change
     2483    //if (FParentCombo.FDropPanel.Visible) and (TForm(self.Owner.Owner).Hint <> '') then begin
     2484    if (FParentCombo.FDropPanel.Visible) and ((GetParentForm(self) <> nil) and (Length(HintArray) = 0)) then begin
     2485      SetHintProperties(False, GetParentForm(Self));
     2486    end;
     2487  end;
     2488
     2489
    24142490  if (not FItemTipEnable) or (not Application.Active) then Exit;
    24152491  { Make sure mouse really moved before continuing.  For some reason, MouseMove gets called
     
    24222498  if not PtInRect(ClientRect, Point(X, Y)) then
    24232499  begin
     2500    If FParentCombo = nil then MouseCapture := False;
    24242501    uItemTip.Hide;
    24252502    FItemTipActive := False;
     
    24492526procedure TORListBox.MeasureItem(Index: Integer; var Height: Integer);
    24502527var
    2451   Txt:string;
    2452 
    2453 begin
    2454   if(FHideSynonyms) and (fSynonymChars <> '') then
    2455   begin
    2456     if(FCreatingItem) then
     2528  Txt: string;
     2529
     2530begin
     2531  if (FHideSynonyms) and (fSynonymChars <> '') then
     2532  begin
     2533    if (FCreatingItem) then
    24572534      Txt := FCreatingText
    24582535    else
    2459       Txt :=  Items[Index];
    2460     if(IsSynonym(Txt)) then Height := 0;
     2536      Txt := Items[Index];
     2537    if (IsSynonym(Txt)) then Height := 0;
    24612538  end;
    24622539  inherited MeasureItem(Index, Height);
     
    24652542procedure TORListBox.WMDestroy(var Message: TWMDestroy);
    24662543begin
    2467   if(assigned(Owner)) and (csDestroying in Owner.ComponentState) then
     2544  if (assigned(Owner)) and (csDestroying in Owner.ComponentState) then
    24682545    DestroyItems;
    24692546  inherited;
     
    24722549procedure TORListBox.CNDrawItem(var Message: TWMDrawItem);
    24732550begin
    2474   if(FCheckBoxes) then
     2551  if (FCheckBoxes) then
    24752552    with Message.DrawItemStruct^ do
    24762553      inc(rcItem.Left, CheckWidth);
     
    24822559  Flags: Longint;
    24832560  ItemRec: PItemRec;
    2484   OldFromSelf :boolean;
     2561  OldFromSelf: boolean;
    24852562  BMap: TBitMap;
    24862563  i, DY: integer;
     
    24892566  ShowText: string;
    24902567begin
    2491   if(assigned(FOnBeforeDraw)) then
     2568  if (assigned(FOnBeforeDraw)) then
    24922569    FOnBeforeDraw(Self, Index, Rect, State);
    24932570  if Assigned(OnDrawItem) then OnDrawItem(Self, Index, Rect, State)
     
    25042581      OldFromSelf := FFromSelf;
    25052582      FFromSelf := True;
    2506       ItemRec := PItemRec(SendMessage(Handle,LB_GETITEMDATA, Index, 0)); // WParam: list index
     2583      ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Index, 0)); // WParam: list index
    25072584      FFromSelf := OldFromSelf;
    25082585
    2509       if(FCheckBoxes) then
     2586      if (FCheckBoxes) then
    25102587      begin
    2511         if(assigned(ItemRec)) then
     2588        if (assigned(ItemRec)) then
    25122589        begin
    25132590          case ItemRec^.CheckedState of
    25142591            cbUnchecked:
    25152592              begin
    2516                 if(FFlatCheckBoxes) then
     2593                if (FFlatCheckBoxes) then
    25172594                  BMap := GetORCBBitmap(iiFlatUnChecked, FBlackColorMode)
    25182595                else
     
    25212598            cbChecked:
    25222599              begin
    2523                 if(FFlatCheckBoxes) then
     2600                if (FFlatCheckBoxes) then
    25242601                  BMap := GetORCBBitmap(iiFlatChecked, FBlackColorMode)
    25252602                else
    25262603                  BMap := GetORCBBitmap(iiChecked, FBlackColorMode);
    25272604              end;
    2528             else // cbGrayed:
    2529               begin
    2530                 if(FFlatCheckBoxes) then
    2531                   BMap := GetORCBBitmap(iiFlatGrayed, FBlackColorMode)
    2532                 else
    2533                   BMap := GetORCBBitmap(iiGrayed, FBlackColorMode);
    2534               end;
     2605          else // cbGrayed:
     2606            begin
     2607              if (FFlatCheckBoxes) then
     2608                BMap := GetORCBBitmap(iiFlatGrayed, FBlackColorMode)
     2609              else
     2610                BMap := GetORCBBitmap(iiGrayed, FBlackColorMode);
     2611            end;
    25352612          end;
    25362613        end
    25372614        else
    25382615        begin
    2539           if(FFlatCheckBoxes) then
     2616          if (FFlatCheckBoxes) then
    25402617            BMap := GetORCBBitmap(iiFlatGrayed, FBlackColorMode)
    25412618          else
     
    25442621        TmpR := Rect;
    25452622        TmpR.Right := TmpR.Left;
    2546         dec(TmpR.Left, CheckWidth+1);
     2623        dec(TmpR.Left, CheckWidth + 1);
    25472624        DY := ((TmpR.Bottom - TmpR.Top) - BMap.Height) div 2;
    25482625        Canvas.Draw(TmpR.Left, TmpR.Top + DY, BMap);
    25492626      end;
    25502627
    2551       if(FTabPos[0] > 0) then
     2628      if (FTabPos[0] > 0) then
    25522629        Flags := (FTabPos[1] * 256) or Flags or DT_TABSTOP or DT_EXPANDTABS;
    25532630
    25542631      ShowText := GetDisplayText(Index);
    2555       if(Style <> lbStandard) and (FTabPos[0] > 0) then
     2632      if (Style <> lbStandard) and (FTabPos[0] > 0) then
    25562633      begin
    25572634        for i := 1 to FTabPix[0] do
     
    25592636          Neg := (FTabPix[i] < 0);
    25602637          if Neg then FTabPix[i] := -FTabPix[i];
    2561           inc(FTabPix[i],Rect.Left-1);
     2638          inc(FTabPix[i], Rect.Left - 1);
    25622639          if Neg then FTabPix[i] := -FTabPix[i];
    25632640        end;
    2564         TabbedTextOut(Canvas.Handle, Rect.Left, Rect.Top+1, PChar(ShowText), Length(ShowText),
     2641        TabbedTextOut(Canvas.Handle, Rect.Left, Rect.Top + 1, PChar(ShowText), Length(ShowText),
    25652642          FTabPix[0], FTabPix[1], -1);
    25662643        for i := 1 to FTabPix[0] do
     
    25682645          Neg := (FTabPix[i] < 0);
    25692646          if Neg then FTabPix[i] := -FTabPix[i];
    2570           dec(FTabPix[i],Rect.Left-1);
     2647          dec(FTabPix[i], Rect.Left - 1);
    25712648          if Neg then FTabPix[i] := -FTabPix[i];
    25722649        end;
     
    25782655end;
    25792656
    2580 function TORListBox.GetIndexFromY(YPos :integer) :integer;
    2581 begin
    2582   if(FHideSynonyms) then
    2583   begin
    2584     Result := TopIndex-1;
     2657function TORListBox.GetIndexFromY(YPos: integer): integer;
     2658begin
     2659  if (FHideSynonyms) then
     2660  begin
     2661    Result := TopIndex - 1;
    25852662    repeat
    25862663      inc(Result);
    2587       if(Perform(LB_GETITEMHEIGHT, Result, 0) > 0) then
    2588         dec(YPos,ItemHeight);
    2589     until((YPos < 0) or (Result >= Items.Count));
     2664      if (Perform(LB_GETITEMHEIGHT, Result, 0) > 0) then
     2665        dec(YPos, ItemHeight);
     2666    until ((YPos < 0) or (Result >= Items.Count));
    25902667  end
    25912668  else
     
    26022679  ScrollCount, ScrollPos, InitialTop, i: Integer;
    26032680begin
    2604   if FLongList then                                 // -- special long list processing - begin
    2605   begin
    2606     if (Value = SFI_TOP) or (Value = SFI_END) then  // scroll to top or bottom
     2681  if FLongList then // -- special long list processing - begin
     2682  begin
     2683    if (Value = SFI_TOP) or (Value = SFI_END) then // scroll to top or bottom
    26072684    begin
    26082685      if Value = SFI_TOP then ScrollPos := 0 else ScrollPos := 100;
    2609       ScrollTo(Self, scPosition, ScrollPos);        // ScrollTo is scrollbar event
     2686      ScrollTo(Self, scPosition, ScrollPos); // ScrollTo is scrollbar event
    26102687      FScrollBar.Position := ScrollPos;
    26112688      if ScrollPos = 0 then Value := FFocusIndex else Value := FFocusIndex + FLargeChange;
     
    26142691      InitialTop := TopIndex;
    26152692      ScrollCount := Value - InitialTop;
    2616       ScrollPos := 50;                              // arbitrary, can be anything from 1-99
    2617       if ScrollCount < 0 then                       // scroll backwards
     2693      ScrollPos := 50; // arbitrary, can be anything from 1-99
     2694      if ScrollCount < 0 then // scroll backwards
    26182695      begin
    26192696        if ScrollCount = -FLargeChange then ScrollTo(Self, scPageUp, ScrollPos) else
     
    26222699        Value := Value + (FCurrentTop - InitialTop);
    26232700      end;
    2624       if ScrollCount > FLargeChange then            // scroll forwards
     2701      if ScrollCount > FLargeChange then // scroll forwards
    26252702      begin
    26262703        if ScrollCount = (FLargeChange * 2) then ScrollTo(Self, scPageDown, ScrollPos) else
     
    26282705        FScrollBar.Position := ScrollPos;
    26292706      end;
    2630       if(FHideSynonyms) then
     2707      if (FHideSynonyms) then
    26312708      begin
    2632         while((Perform(LB_GETITEMHEIGHT, Value, 0) = 0) and (Value >= 0) and (value < Items.Count)) do
     2709        while ((Perform(LB_GETITEMHEIGHT, Value, 0) = 0) and (Value >= 0) and (value < Items.Count)) do
    26332710        begin
    2634           if(Value < FFocusIndex) then
     2711          if (Value < FFocusIndex) then
    26352712            dec(Value)
    26362713          else
     
    26392716      end;
    26402717    end;
    2641   end;                                              // -- special long list processing - end
     2718  end; // -- special long list processing - end
    26422719  if (Value = SFI_END) or (not (Value < Items.Count)) then Value := Items.Count - 1;
    26432720  if (Value = SFI_TOP) or (Value < 0) then Value := 0;
     
    26702747var
    26712748  TipPos: TPoint;
    2672   TrueOffset :integer;
    2673   TmpIdx :integer;
     2749  TrueOffset: integer;
     2750  TmpIdx: integer;
    26742751begin
    26752752  // if listbox is dropdown combo but control is not focused -
     
    26802757  // if control is not focused -
    26812758  if (Screen.ActiveControl <> Self) and (Screen.ActiveControl <> Parent) then Exit;
    2682   if(FHideSynonyms) then
     2759  if (FHideSynonyms) then
    26832760  begin
    26842761    TrueOffset := TopIndex;
    26852762    TmpIdx := TopIndex;
    2686     while((TmpIdx < Message.wParam) and (TmpIdx < Items.Count)) do
    2687     begin
    2688       if(Perform(LB_GETITEMHEIGHT, TmpIdx, 0) > 0) then
     2763    while ((TmpIdx < Message.wParam) and (TmpIdx < Items.Count)) do
     2764    begin
     2765      if (Perform(LB_GETITEMHEIGHT, TmpIdx, 0) > 0) then
    26892766        inc(TrueOffset);
    26902767      inc(TmpIdx);
     
    26952772  TipPos := ClientToScreen(Point(0, (TrueOffset - TopIndex) * ItemHeight));
    26962773  //uItemTip.Show(Self, FFocusIndex, TipPos, NO_CATCH_MOUSE);
    2697   uItemTip.Show(Self, FFocusIndex, TipPos, FParentCombo = nil);  // if DropDown, no mousecapture
     2774  uItemTip.Show(Self, FFocusIndex, TipPos, FParentCombo = nil); // if DropDown, no mousecapture
    26982775end;
    26992776
     
    27032780  if (AnIndex < Items.Count) and (AnIndex > -1)
    27042781    then Result := StrToInt64Def(Piece(Items[AnIndex], FDelimiter, 1), 0)
    2705     else Result := 0;
     2782  else Result := 0;
    27062783end;
    27072784
     
    27112788  if ItemIndex > -1
    27122789    then Result := StrToInt64Def(Piece(Items[ItemIndex], FDelimiter, 1), 0)
    2713     else Result := 0;
     2790  else Result := 0;
    27142791end;
    27152792
     
    27392816  if FLongList then ListEnd := FWaterMark - 1 else ListEnd := Items.Count - 1;
    27402817  for i := 0 to ListEnd do if (GetIEN(i) = AnIEN) and (GetDisplayText(i) = AnItem) then
    2741   begin
    2742     ItemIndex := i;
    2743     Result := i;
    2744     ItemFound := True;
    2745     break;
    2746   end;
     2818    begin
     2819      ItemIndex := i;
     2820      Result := i;
     2821      ItemFound := True;
     2822      break;
     2823    end;
    27472824  if FLongList and not ItemFound then
    27482825  begin
     
    27812858    raise Exception.Create('List Index Out of Bounds');
    27822859  FFromSelf := True;
    2783   ItemRec := PItemRec(SendMessage(Handle,LB_GETITEMDATA, Index, 0));
     2860  ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Index, 0));
    27842861  FFromSelf := False;
    2785   if(assigned(ItemRec)) then
     2862  if (assigned(ItemRec)) then
    27862863    Result := ItemRec^.Reference
    27872864  else
     
    27972874    raise Exception.Create('List Index Out of Bounds');
    27982875  FFromSelf := True;
    2799   ItemRec := PItemRec(SendMessage(Handle,LB_GETITEMDATA, Index, 0));
     2876  ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Index, 0));
    28002877  FFromSelf := False;
    2801   if(assigned(ItemRec)) then
     2878  if (assigned(ItemRec)) then
    28022879    ItemRec^.Reference := AReference;
    28032880end;
     
    28342911{ returns the character based tab stops that are currently set, if any }
    28352912begin
    2836   if(FTabPosInPixels) then
     2913  if (FTabPosInPixels) then
    28372914    Result := IntArrayToString(FTabPix)
    28382915  else
     
    28492926  for i := 2 to TabTmp[0] do
    28502927    if (abs(TabTmp[i]) < abs(TabTmp[i - 1])) or
    2851        (TabTmp[i] = TabTmp[i - 1]) then
     2928      (TabTmp[i] = TabTmp[i - 1]) then
    28522929      raise Exception.Create('Tab positions must be in ascending order');
    2853   if(FTabPosInPixels) then
     2930  if (FTabPosInPixels) then
    28542931  begin
    28552932    for i := 0 to TabTmp[0] do FTabPix[i] := TabTmp[i];
     
    28662943procedure TORListBox.SetTabPosInPixels(const Value: boolean);
    28672944begin
    2868   if(FTabPosInPixels <> Value) then
     2945  if (FTabPosInPixels <> Value) then
    28692946  begin
    28702947    FTabPosInPixels := Value;
     
    28792956  i, AveWidth: Integer;
    28802957begin
    2881   FillChar(TabDlg,  SizeOf(TabDlg), 0);
     2958  FillChar(TabDlg, SizeOf(TabDlg), 0);
    28822959  AveWidth := FontWidthPixel(Self.Font.Handle);
    2883   if(FTabPosInPixels) then
     2960  if (FTabPosInPixels) then
    28842961  begin
    28852962    FillChar(FTabPos, SizeOf(FTabPos), 0);
     
    28882965    begin
    28892966      FTabPos[i] := FTabPix[i] div AveWidth;
    2890       TabDlg[i]  := (FTabPix[i] * 4) div AveWidth;
     2967      TabDlg[i] := (FTabPix[i] * 4) div AveWidth;
    28912968    end;
    28922969  end
     
    28982975    begin
    28992976      // do dialog units first so that pixels gets the same rounding error
    2900       TabDlg[i]  := FTabPos[i] * 4;        // 4 dialog units per character
     2977      TabDlg[i] := FTabPos[i] * 4; // 4 dialog units per character
    29012978      FTabPix[i] := (TabDlg[i] * AveWidth) div 4;
    29022979    end;
    29032980  end;
    2904   TabDlg[0]  := FTabPos[0];
     2981  TabDlg[0] := FTabPos[0];
    29052982  Perform(LB_SETTABSTOPS, TabDlg[0], Integer(@TabDlg[1]));
    29062983  Refresh;
     
    29122989end;
    29132990
    2914 procedure TORListBox.SetHideSynonyms(Value :boolean);
    2915 var
    2916   TmpIH :integer;
    2917 
    2918 begin
    2919   if(FHideSynonyms <> Value) then
    2920   begin
    2921     if((Value) and (not FLongList)) then
     2991procedure TORListBox.SetHideSynonyms(Value: boolean);
     2992var
     2993  TmpIH: integer;
     2994
     2995begin
     2996  if (FHideSynonyms <> Value) then
     2997  begin
     2998    if ((Value) and (not FLongList)) then
    29222999      raise Exception.Create('Hide Synonyms only allowed on Long Lists');
    29233000    FHideSynonyms := Value;
    2924     if(not FHideSynonyms) then
     3001    if (not FHideSynonyms) then
    29253002    begin
    29263003      Style := lbStandard;
     
    29283005    else
    29293006    begin
    2930       if(FSynonymChars = '') then
     3007      if (FSynonymChars = '') then
    29313008        FSynonymChars := '<>';
    29323009      TmpIH := ItemHeight;
     
    29373014end;
    29383015
    2939 procedure TORListBox.SetSynonymChars(Value :string);
    2940 begin
    2941   if(FSynonymChars <> Value) then
     3016procedure TORListBox.SetSynonymChars(Value: string);
     3017begin
     3018  if (FSynonymChars <> Value) then
    29423019  begin
    29433020    FSynonymChars := Value;
    2944     if((Value = '') and (FHideSynonyms)) then
     3021    if ((Value = '') and (FHideSynonyms)) then
    29453022      SetHideSynonyms(FALSE);
    2946     if(FHideSynonyms) then
     3023    if (FHideSynonyms) then
    29473024    begin
    29483025      SetHideSynonyms(FALSE);
     
    29593036procedure TORListBox.SetStyle(Value: TListBoxStyle);
    29603037begin
    2961   if(Value <> lbOwnerDrawVariable) and (FHideSynonyms) then
     3038  if (Value <> lbOwnerDrawVariable) and (FHideSynonyms) then
    29623039    FHideSynonyms := FALSE;
    2963   if(FCheckBoxes) and (Value = lbStandard) then
     3040  if (FCheckBoxes) and (Value = lbStandard) then
    29643041    FCheckBoxes := FALSE;
    29653042  inherited Style := Value;
     
    30023079  try
    30033080    TORStrings(Items).Verification := False;
    3004     HandleNeeded;                 // ensures that Items is valid if in the middle of RecreateWnd
     3081    HandleNeeded; // ensures that Items is valid if in the middle of RecreateWnd
    30053082    SaveListMode := FLongList;
    30063083    Strings := TStringList.Create;
    30073084    SaveItems := TList.Create;
    3008     FLongList := False;                               // so don't have to track WaterMark
     3085    FLongList := False; // so don't have to track WaterMark
    30093086    FFromSelf := True;
    3010     for i := 0 to Items.Count - 1 do                  // put pointers to TItemRec in SaveItems
     3087    for i := 0 to Items.Count - 1 do // put pointers to TItemRec in SaveItems
    30113088    begin
    30123089      ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, i, 0));
     
    30143091    end;
    30153092    Strings.Assign(Items);
    3016     Items.Clear;                                      // still FromSelf so don't dispose recs
     3093    Items.Clear; // still FromSelf so don't dispose recs
    30173094    FFromSelf := False;
    3018     for i := 0 to SaveItems.Count - 1 do              // use saved ItemRecs to rebuild listbox
     3095    for i := 0 to SaveItems.Count - 1 do // use saved ItemRecs to rebuild listbox
    30193096    begin
    30203097      ItemRec := SaveItems[i];
    3021       if(assigned(ItemRec)) then
     3098      if (assigned(ItemRec)) then
    30223099      begin
    30233100        Pos := Items.AddObject(Strings[i], ItemRec^.UserObject);
    30243101        // CQ 11491 - Changing TabPositions, etc. was wiping out check box status.
    30253102        FFromSelf := True;
    3026         ItemRec2 := PItemRec(SendMessage(Handle,LB_GETITEMDATA, Pos, 0));
     3103        ItemRec2 := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Pos, 0));
    30273104        FFromSelf := False;
    3028         if(assigned(ItemRec2)) then
     3105        if (assigned(ItemRec2)) then
    30293106        begin
    30303107          ItemRec2^.Reference := ItemRec^.Reference;
     
    30513128    begin
    30523129      FreeScrollBar;
    3053       if(FHideSynonyms) then
     3130      if (FHideSynonyms) then
    30543131        SetHideSynonyms(FALSE);
    30553132    end;
     
    30623139  L, T, W, H, OffsetLT, OffsetWH: Integer;
    30633140begin
    3064   if uNewStyle then begin OffsetLT := 2; OffsetWH := 4; end   // Win95
    3065                else begin OffsetLT := 0; OffsetWH := 0; end; // Win3.1
     3141  if uNewStyle then begin OffsetLT := 2; OffsetWH := 4; end // Win95
     3142  else begin OffsetLT := 0; OffsetWH := 0; end; // Win3.1
    30663143  W := GetSystemMetrics(SM_CXVSCROLL);
    30673144  L := Left + Width - W - OffsetLT;
     
    30763153begin
    30773154  FLongList := True;
    3078   if MultiSelect then MultiSelect := False;    // LongLists do not support multiple selections
     3155  if MultiSelect then MultiSelect := False; // LongLists do not support multiple selections
    30793156  FScrollBar := TScrollBar.Create(Self);
    30803157  FScrollBar.Kind := sbVertical;
     
    30853162  if FParentCombo = nil
    30863163    then FScrollBar.Parent := Parent
    3087     else FScrollBar.Parent := FParentCombo.FDropPanel;
     3164  else FScrollBar.Parent := FParentCombo.FDropPanel;
    30883165end;
    30893166
     
    30923169begin
    30933170  FLongList := False;
    3094   FScrollBar.Free;  // don't call from destroy because scrollbar may already be free
     3171  FScrollBar.Free; // don't call from destroy because scrollbar may already be free
    30953172  FScrollBar := nil;
    30963173end;
     
    31123189
    31133190  FirstItem := TextToShow(Strings[0]);
    3114   LastItem  := TextToShow(Strings[Strings.Count-1]);
     3191  LastItem := TextToShow(Strings[Strings.Count - 1]);
    31153192  Ascend := True;
    31163193  case FDirection of
    3117   LL_REVERSE: if CompareText(FirstItem, LastItem) < 0 then Ascend := False;
    3118   LL_FORWARD: if CompareText(FirstItem, LastItem) > 0 then Ascend := False;
    3119   end;
    3120   case Ascend of                              // should call AddObject & InsertObject instead?
    3121   False: case FDirection of
    3122          LL_REVERSE: for i := Strings.Count - 1 downto 0 do Items.Insert(FInsertAt, Strings[i]);
    3123          LL_FORWARD: for i := Strings.Count - 1 downto 0 do Items.Add(Strings[i]);
    3124          end;
    3125   True: case FDirection of
    3126          LL_REVERSE: for i := 0 to Strings.Count - 1 do Items.Insert(FInsertAt, Strings[i]);
    3127          LL_FORWARD: for i := 0 to Strings.Count - 1 do Items.Add(Strings[i]);
    3128          end;
     3194    LL_REVERSE: if CompareText(FirstItem, LastItem) < 0 then Ascend := False;
     3195    LL_FORWARD: if CompareText(FirstItem, LastItem) > 0 then Ascend := False;
     3196  end;
     3197  case Ascend of // should call AddObject & InsertObject instead?
     3198    False: case FDirection of
     3199        LL_REVERSE: for i := Strings.Count - 1 downto 0 do Items.Insert(FInsertAt, Strings[i]);
     3200        LL_FORWARD: for i := Strings.Count - 1 downto 0 do Items.Add(Strings[i]);
     3201      end;
     3202    True: case FDirection of
     3203        LL_REVERSE: for i := 0 to Strings.Count - 1 do Items.Insert(FInsertAt, Strings[i]);
     3204        LL_FORWARD: for i := 0 to Strings.Count - 1 do Items.Add(Strings[i]);
     3205      end;
    31293206  end;
    31303207end;
     
    31413218      index := GetStringIndex(S);
    31423219      if index > -1 then
    3143         S := Piece(Items[index],Delimiter,LookUpPiece);
     3220        S := Piece(Items[index], Delimiter, LookUpPiece);
    31443221    end;
    31453222    if CaseChanged then
     
    31573234  if FWaterMark > 0 then
    31583235  begin
    3159     Items.Insert(FWaterMark,LLS_LINE);
    3160     Items.Insert(FWaterMark,LLS_SPACE);
     3236    Items.Insert(FWaterMark, LLS_LINE);
     3237    Items.Insert(FWaterMark, LLS_SPACE);
    31613238  end;
    31623239end;
     
    31843261  begin
    31853262    case FDirection of
    3186     LL_REVERSE: for i := Items.Count - 1 downto
    3187                   HigherOf(FCurrentTop + FLargeChange, FWaterMark) do Items.Delete(i);
    3188     LL_POSITION: for i := Items.Count - 1 downto FWaterMark do Items.Delete(i);
    3189     LL_FORWARD: for i := FCurrentTop - 1 downto FWaterMark do Items.Delete(i);
     3263      LL_REVERSE: for i := Items.Count - 1 downto
     3264        HigherOf(FCurrentTop + FLargeChange, FWaterMark) do Items.Delete(i);
     3265      LL_POSITION: for i := Items.Count - 1 downto FWaterMark do Items.Delete(i);
     3266      LL_FORWARD: for i := FCurrentTop - 1 downto FWaterMark do Items.Delete(i);
    31903267    end;
    31913268  end;
     
    31993276  if Items.Count > 1000 then ClearLong;
    32003277  case FDirection of
    3201   LL_REVERSE: if FWaterMark < Items.Count then StartFrom := DisplayText[FWaterMark];
    3202   LL_POSITION: begin
    3203                  ClearLong;
    3204                  if StartFrom = #127#127#127 then
    3205                  begin
    3206                    FDirection := LL_REVERSE;
    3207                    StartFrom := '';
    3208                  end
    3209                  else FDirection := LL_FORWARD;
    3210                end;
    3211   LL_FORWARD: if (FWaterMark < Items.Count) and (Items.Count > 0)
    3212                  then StartFrom := DisplayText[Items.Count - 1];
     3278    LL_REVERSE: if FWaterMark < Items.Count then StartFrom := DisplayText[FWaterMark];
     3279    LL_POSITION: begin
     3280        ClearLong;
     3281        if StartFrom = #127#127#127 then
     3282        begin
     3283          FDirection := LL_REVERSE;
     3284          StartFrom := '';
     3285        end
     3286        else FDirection := LL_FORWARD;
     3287      end;
     3288    LL_FORWARD: if (FWaterMark < Items.Count) and (Items.Count > 0)
     3289      then StartFrom := DisplayText[Items.Count - 1];
    32133290  end;
    32143291  if LookupPiece <> 0 then
     
    32163293    index := GetStringIndex(StartFrom);
    32173294    if index > -1 then
    3218       StartFrom := Piece(Items[index],Delimiter,LookUpPiece);
     3295      StartFrom := Piece(Items[index], Delimiter, LookUpPiece);
    32193296  end;
    32203297  if CaseChanged then
    32213298    StartFrom := Uppercase(StartFrom);
    3222   StartFrom := Copy(StartFrom, 1, 128);       // limit length to 128 characters
    3223   CtrlPos := 0;                               // make sure no ctrl characters
     3299  StartFrom := Copy(StartFrom, 1, 128); // limit length to 128 characters
     3300  CtrlPos := 0; // make sure no ctrl characters
    32243301  for CharPos := 1 to Length(StartFrom) do if StartFrom[CharPos] in [#0..#31] then
    3225   begin
    3226     CtrlPos := CharPos;
    3227     break;
    3228   end;
     3302    begin
     3303      CtrlPos := CharPos;
     3304      break;
     3305    end;
    32293306  if CtrlPos > 0 then StartFrom := Copy(StartFrom, 1, CtrlPos - 1);
    32303307  if FDirection = LL_FORWARD then FInsertAt := Items.Count else FInsertAt := FWaterMark;
     
    32433320  x := DisplayText[TopIndex];
    32443321  if (FWaterMark > 0) and (TopIndex < FWaterMark)
    3245     then Result := 0  // short list visible
    3246     else while (CompareText(ALPHA_DISTRIBUTION[Result], x) < 0) and (Result < 100) do
    3247       Inc(Result);    // only long list visible
     3322    then Result := 0 // short list visible
     3323  else while (CompareText(ALPHA_DISTRIBUTION[Result], x) < 0) and (Result < 100) do
     3324      Inc(Result); // only long list visible
    32483325end;
    32493326
     
    32513328{ event code for the longlist scrollbar, adjusts TopIndex & calls OnNeedData as necessary }
    32523329var
    3253   Count, Goal, Dir :integer;
    3254   Done :boolean;
    3255 
    3256 begin
     3330  Count, Goal, Dir: integer;
     3331  Done: boolean;
     3332  DropDownPanel: TORListBox;
     3333begin
     3334  If Length(HintArray) > 0 then begin
     3335   DropDownPanel := TORListBox.Create(nil);
     3336   try
     3337    DropDownPanel.SetHintProperties(True, GetParentForm(Self));
     3338   finally
     3339    DropDownPanel.Free;
     3340   end;
     3341  end;
    32573342  uItemTip.Hide;
    32583343  FCurrentTop := TopIndex;
    3259   if(ScrollCode = scPosition) then
     3344  if (ScrollCode = scPosition) then
    32603345  begin
    32613346    NeedData(LL_POSITION, ALPHA_DISTRIBUTION[ScrollPos]);
    32623347    case ScrollPos of
    3263     0:    TopIndex := 0;
    3264     1..99: TopIndex := FWaterMark;
    3265     100:  TopIndex := HigherOf(Items.Count - FLargeChange, 0);
     3348      0: TopIndex := 0;
     3349      1..99: TopIndex := FWaterMark;
     3350      100: TopIndex := HigherOf(Items.Count - FLargeChange, 0);
    32663351    end;
    32673352    FFocusIndex := TopIndex;
    32683353  end
    32693354  else
    3270   if(HideSynonyms) then
    3271   begin
    3272     Count := 0;
    3273     case ScrollCode of
    3274       scLineUp:   begin Dir := -1; Goal := 1;            end;
    3275       scLineDown: begin Dir :=  1; Goal := 1;            end;
    3276       scPageUp:  begin Dir := -1; Goal := FLargeChange; end;
    3277       scPageDown: begin Dir := 1; Goal := FLargeChange; end;
     3355    if (HideSynonyms) then
     3356    begin
     3357      Count := 0;
     3358      case ScrollCode of
     3359        scLineUp: begin Dir := -1; Goal := 1; end;
     3360        scLineDown: begin Dir := 1; Goal := 1; end;
     3361        scPageUp: begin Dir := -1; Goal := FLargeChange; end;
     3362        scPageDown: begin Dir := 1; Goal := FLargeChange; end;
    32783363      else
    32793364        exit;
    3280     end;
    3281     repeat
    3282       Done := FALSE;
    3283       if(Dir > 0) then
    3284       begin
    3285         if (FCurrentTop + (FLargeChange * 2)) > (Items.Count - 1) then
    3286           NeedData(LL_FORWARD, '');
    3287         if(FCurrentTop >= Items.Count - 1) then
     3365      end;
     3366      repeat
     3367        Done := FALSE;
     3368        if (Dir > 0) then
    32883369        begin
    3289           FCurrentTop := Items.Count - 1;
    3290           Done := TRUE;
     3370          if (FCurrentTop + (FLargeChange * 2)) > (Items.Count - 1) then
     3371            NeedData(LL_FORWARD, '');
     3372          if (FCurrentTop >= Items.Count - 1) then
     3373          begin
     3374            FCurrentTop := Items.Count - 1;
     3375            Done := TRUE;
     3376          end;
     3377        end
     3378        else
     3379        begin
     3380          if (FCurrentTop - FLargeChange) < FWaterMark then NeedData(LL_REVERSE, '');
     3381          if (FCurrentTop <= 0) then
     3382          begin
     3383            FCurrentTop := 0;
     3384            Done := TRUE;
     3385          end;
    32913386        end;
    3292       end
    3293       else
    3294       begin
    3295         if (FCurrentTop - FLargeChange) < FWaterMark then NeedData(LL_REVERSE, '');
    3296         if(FCurrentTop <= 0) then
     3387        if (not Done) then
    32973388        begin
    3298           FCurrentTop := 0;
    3299           Done := TRUE;
     3389          FCurrentTop := FCurrentTop + Dir;
     3390          if (Perform(LB_GETITEMHEIGHT, FCurrentTop, 0) > 0) then
     3391          begin
     3392            inc(Count);
     3393            Done := (Count >= Goal);
     3394          end;
    33003395        end;
     3396      until Done;
     3397      TopIndex := FCurrentTop;
     3398    end
     3399    else
     3400    begin
     3401      case ScrollCode of
     3402        scLineUp: begin
     3403            if (FCurrentTop - FLargeChange) < FWaterMark then NeedData(LL_REVERSE, '');
     3404            TopIndex := HigherOf(FCurrentTop - 1, 0);
     3405          end;
     3406        scLineDown: begin
     3407            if (FCurrentTop + (FLargeChange * 2)) > (Items.Count - 1)
     3408              then NeedData(LL_FORWARD, '');
     3409            TopIndex := LowerOf(FCurrentTop + 1, Items.Count - 1);
     3410          end;
     3411        scPageUp: begin
     3412            if (FCurrentTop - FLargeChange) < FWaterMark then NeedData(LL_REVERSE, '');
     3413            TopIndex := HigherOf(FCurrentTop - FLargeChange, 0);
     3414          end;
     3415        scPageDown: begin
     3416            if (FCurrentTop + (FLargeChange * 2)) > (Items.Count - 1)
     3417              then NeedData(LL_FORWARD, '');
     3418            TopIndex := LowerOf(FCurrentTop + FLargeChange, Items.Count - 1);
     3419          end;
    33013420      end;
    3302       if(not Done) then
    3303       begin
    3304         FCurrentTop := FCurrentTop + Dir;
    3305         if(Perform(LB_GETITEMHEIGHT, FCurrentTop, 0) > 0) then
    3306         begin
    3307           inc(Count);
    3308           Done := (Count >= Goal);
    3309         end;
    3310       end;
    3311     until Done;
    3312     TopIndex := FCurrentTop;
    3313   end
    3314   else
    3315   begin
    3316     case ScrollCode of
    3317     scLineUp:   begin
    3318                   if (FCurrentTop - FLargeChange) < FWaterMark then NeedData(LL_REVERSE, '');
    3319                   TopIndex := HigherOf(FCurrentTop - 1, 0);
    3320                 end;
    3321     scLineDown: begin
    3322                   if (FCurrentTop + (FLargeChange * 2)) > (Items.Count - 1)
    3323                     then NeedData(LL_FORWARD, '');
    3324                   TopIndex := LowerOf(FCurrentTop + 1, Items.Count - 1);
    3325                 end;
    3326     scPageUp:   begin
    3327                   if (FCurrentTop - FLargeChange) < FWaterMark then NeedData(LL_REVERSE, '');
    3328                   TopIndex := HigherOf(FCurrentTop - FLargeChange, 0);
    3329                 end;
    3330     scPageDown: begin
    3331                   if (FCurrentTop + (FLargeChange * 2)) > (Items.Count - 1)
    3332                     then NeedData(LL_FORWARD, '');
    3333                   TopIndex := LowerOf(FCurrentTop + FLargeChange, Items.Count - 1);
    3334                 end;
    3335     end;
    3336   end;
     3421    end;
    33373422  if (ScrollPos > 0) and (ScrollPos < 100) then ScrollPos := PositionThumb;
    33383423end;
     
    33443429begin
    33453430  Result := -1;
    3346   if Length(AString) > 0 then                                             {*KCM*}
    3347   begin
    3348     if not FLongList then                                                 // Normal List
     3431  if Length(AString) > 0 then {*KCM*}
     3432  begin
     3433    if not FLongList then // Normal List
    33493434    begin
    33503435      Result := SendMessage(Handle, LB_FINDSTRING, -1, Longint(PChar(AString)));
    33513436      if Result = LB_ERR then Result := -1;
    3352     end else                                                              // Long List
     3437    end else // Long List
    33533438    begin
    33543439      if FScrollBar.Position = 0 then for i := 0 to FWatermark - 1 do
    3355       begin
    3356         if CompareText(AString, Copy(DisplayText[i], 1, Length(AString))) = 0 then
    33573440        begin
    3358           Result := i;
    3359           break;
     3441          if CompareText(AString, Copy(DisplayText[i], 1, Length(AString))) = 0 then
     3442          begin
     3443            Result := i;
     3444            break;
     3445          end;
    33603446        end;
    3361       end;
    33623447      if Result < 0 then
    33633448      begin
     
    33773462begin
    33783463  Result := -1;
    3379   if Length(AString) > 0 then                                             {*KCM*}
    3380   begin
    3381     if not FLongList then                                                 // Normal List
     3464  if Length(AString) > 0 then {*KCM*}
     3465  begin
     3466    if not FLongList then // Normal List
    33823467    begin
    33833468      Result := SendMessage(Handle, LB_FINDSTRING, -1, Longint(PChar(AString)));
     
    33853470      // use FFocusIndex instead of FocusIndex to reduce flashing
    33863471      FFocusIndex := Result;
    3387     end else                                                              // Long List
     3472    end else // Long List
    33883473    begin
    33893474      if FScrollBar.Position = 0 then for i := 0 to FWatermark - 1 do
    3390       begin
    3391         if CompareText(AString, Copy(DisplayText[i], 1, Length(AString))) = 0 then
    33923475        begin
    3393           Result := i;
    3394           break;
     3476          if CompareText(AString, Copy(DisplayText[i], 1, Length(AString))) = 0 then
     3477          begin
     3478            Result := i;
     3479            break;
     3480          end;
    33953481        end;
    3396       end;
    33973482      if not StringBetween(AString, DisplayText[FWaterMark], DisplayText[Items.Count - 1]) then
    33983483      begin
     
    34023487          index := GetStringIndex(x);
    34033488          if index > -1 then
    3404             x := Piece(Items[index],Delimiter,LookUpPiece);
     3489            x := Piece(Items[index], Delimiter, LookUpPiece);
    34053490        end;
    34063491        if CaseChanged then
     
    34213506  ItemIndex := Result;
    34223507  FFocusIndex := Result;
    3423   if Result > -1 then TopIndex := Result;                  // will scroll item into view
    3424   if FLongList then FScrollBar.Position := PositionThumb;  // done after topindex set
     3508  if Result > -1 then TopIndex := Result; // will scroll item into view
     3509  if FLongList then FScrollBar.Position := PositionThumb; // done after topindex set
    34253510end;
    34263511
    34273512procedure TORListBox.SetCheckBoxes(const Value: boolean);
    34283513begin
    3429   if(FCheckBoxes <> Value) then
     3514  if (FCheckBoxes <> Value) then
    34303515  begin
    34313516    FCheckBoxes := Value;
    3432     if(Value) then
    3433     begin
    3434       if(GetStyle = lbStandard) then
     3517    if (Value) then
     3518    begin
     3519      if (GetStyle = lbStandard) then
    34353520        SetStyle(lbOwnerDrawFixed);
    3436       if(inherited MultiSelect) then
     3521      if (inherited MultiSelect) then
    34373522        SetMultiSelect(FALSE);
    34383523    end;
     
    34433528procedure TORListBox.SetFlatCheckBoxes(const Value: boolean);
    34443529begin
    3445   if(FFlatCheckBoxes <> Value) then
     3530  if (FFlatCheckBoxes <> Value) then
    34463531  begin
    34473532    FFlatCheckBoxes := Value;
     
    34583543  if Index < 0 then exit;
    34593544  FFromSelf := True;
    3460   ItemRec := PItemRec(SendMessage(Handle,LB_GETITEMDATA, Index, 0));
     3545  ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Index, 0));
    34613546  FFromSelf := FALSE;
    3462   if(assigned(ItemRec)) then
     3547  if (assigned(ItemRec)) then
    34633548    Result := (ItemRec^.CheckedState = cbChecked)
    34643549  else
     
    34733558begin
    34743559  FFromSelf := True;
    3475   ItemRec := PItemRec(SendMessage(Handle,LB_GETITEMDATA, Index, 0));
     3560  ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Index, 0));
    34763561  FFromSelf := False;
    34773562  if (assigned(ItemRec)) and (Value <> (ItemRec^.CheckedState = cbChecked)) then
    34783563  begin
    3479     if(Value) then
     3564    if (Value) then
    34803565      ItemRec^.CheckedState := cbChecked
    34813566    else
     
    34833568    Rect := ItemRect(Index);
    34843569    InvalidateRect(Handle, @Rect, FALSE);
    3485     if(assigned(FOnClickCheck)) then
     3570    if (assigned(FOnClickCheck)) then
    34863571      FOnClickCheck(Self, Index);
    34873572  end;
     
    34943579begin
    34953580  FFromSelf := True;
    3496   ItemRec := PItemRec(SendMessage(Handle,LB_GETITEMDATA, Index, 0));
     3581  ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Index, 0));
    34973582  FFromSelf := FALSE;
    3498   if(assigned(ItemRec)) then
     3583  if (assigned(ItemRec)) then
    34993584    Result := ItemRec^.CheckedState
    35003585  else
     
    35103595begin
    35113596  FFromSelf := True;
    3512   ItemRec := PItemRec(SendMessage(Handle,LB_GETITEMDATA, Index, 0));
     3597  ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Index, 0));
    35133598  FFromSelf := False;
    35143599  if (assigned(ItemRec)) and (Value <> ItemRec^.CheckedState) then
     
    35173602    Rect := ItemRect(Index);
    35183603    InvalidateRect(Handle, @Rect, FALSE);
    3519     if(assigned(FOnClickCheck)) then
     3604    if (assigned(FOnClickCheck)) then
    35203605      FOnClickCheck(Self, Index);
    35213606  end;
     
    35303615begin
    35313616  inherited SetMultiSelect(Value);
    3532   if(Value) then SetCheckBoxes(FALSE);
     3617  if (Value) then SetCheckBoxes(FALSE);
    35333618end;
    35343619
     
    35393624begin
    35403625  Result := '';
    3541   if(FCheckBoxes) then
    3542   begin
    3543     for i := 0 to Items.Count-1 do
     3626  if (FCheckBoxes) then
     3627  begin
     3628    for i := 0 to Items.Count - 1 do
    35443629      Result := Result + Char(ord('0') + Ord(GetCheckedState(i)));
    35453630  end;
     
    35513636
    35523637begin
    3553   for i := 0 to Items.Count-1 do
    3554     SetCheckedState(i, TCheckBoxState(StrToIntDef(copy(Value,i+1,1),0)));
     3638  for i := 0 to Items.Count - 1 do
     3639    SetCheckedState(i, TCheckBoxState(StrToIntDef(copy(Value, i + 1, 1), 0)));
    35553640end;
    35563641
     
    35583643begin
    35593644  if not Assigned(FMItems) then
    3560     FMItems := TORStrings.Create(Tlistbox(Self).Items,TextToShow);
     3645    FMItems := TORStrings.Create(Tlistbox(Self).Items, TextToShow);
    35613646  result := FMItems;
    35623647end;
    35633648
    3564 procedure TORListBox.SetMItems( Value: TStrings);
     3649procedure TORListBox.SetMItems(Value: TStrings);
    35653650begin
    35663651  if not Assigned(FMItems) then
    3567     FMItems := TORStrings.Create(Tlistbox(Self).Items,TextToShow);
    3568   FMItems.Assign( Value );
     3652    FMItems := TORStrings.Create(Tlistbox(Self).Items, TextToShow);
     3653  FMItems.Assign(Value);
    35693654end;
    35703655
     
    35883673    FCaption.Width := 0;
    35893674    FCaption.Visible := True;
    3590     if Assigned (FParentCombo) then
     3675    if Assigned(FParentCombo) then
    35913676      FCaption.Parent := FParentCombo
    35923677    else
     
    36123697procedure DropDownPanelOpened;
    36133698begin
    3614   if uDropPanelOpenCount=0 then
     3699  if uDropPanelOpenCount = 0 then
    36153700    uOldShowHintsSetting := Application.ShowHint;
    3616   Application.ShowHint := FALSE;
     3701 // Application.ShowHint := FALSE;
    36173702  inc(uDropPanelOpenCount);
    36183703end;
     
    36213706begin
    36223707  dec(uDropPanelOpenCount);
    3623   if uDropPanelOpenCount<=0 then
     3708  if uDropPanelOpenCount <= 0 then
    36243709  begin
    36253710    uDropPanelOpenCount := 0;
    36263711    if not Application.ShowHint then
    3627       Application.ShowHint := uOldShowHintsSetting
     3712  //    Application.ShowHint := uOldShowHintsSetting
    36283713  end;
    36293714end;
     
    36493734  BevelOuter := bvNone;
    36503735  BorderStyle := bsNone;
    3651   Caption :='';
     3736  Caption := '';
    36523737  Ctl3D := False;
    36533738  Visible := False;
     
    36603745  inherited CreateParams(Params);
    36613746  if not (csDesigning in ComponentState) then with Params do
    3662   begin
    3663     if uNewStyle then Params.ExStyle := Params.ExStyle or WS_EX_TOOLWINDOW;
    3664     Params.ExStyle := Params.ExStyle or WS_EX_TOPMOST; // - incompatible with ItemTip
    3665     WindowClass.Style := WindowClass.Style or CS_SAVEBITS;
    3666     WndParent := GetDesktopWindow;
    3667   end;
     3747    begin
     3748      if uNewStyle then Params.ExStyle := Params.ExStyle or WS_EX_TOOLWINDOW;
     3749      Params.ExStyle := Params.ExStyle or WS_EX_TOPMOST; // - incompatible with ItemTip
     3750      WindowClass.Style := WindowClass.Style or CS_SAVEBITS;
     3751      WndParent := GetDesktopWindow;
     3752    end;
    36683753end;
    36693754
     
    36743759begin
    36753760  Result := nil;
    3676   if(FButtons) then
    3677   begin
    3678     for i := 0 to ControlCount-1 do
    3679       if(Controls[i] is TSpeedButton) then
     3761  if (FButtons) then
     3762  begin
     3763    for i := 0 to ControlCount - 1 do
     3764      if (Controls[i] is TSpeedButton) then
    36803765      begin
    3681         if((OKBtn and ((Controls[i] as TSpeedButton).Tag = OKBtnTag)) or
    3682            ((not OKBtn) and ((Controls[i] as TSpeedButton).Tag = CancelBtnTag))) then
     3766        if ((OKBtn and ((Controls[i] as TSpeedButton).Tag = OKBtnTag)) or
     3767          ((not OKBtn) and ((Controls[i] as TSpeedButton).Tag = CancelBtnTag))) then
    36833768        begin
    36843769          Result := TSpeedButton(Controls[i]);
     
    36953780begin
    36963781  sb := GetButton(TRUE);
    3697   if(assigned(sb)) then sb.Down := FALSE;
     3782  if (assigned(sb)) then sb.Down := FALSE;
    36983783  sb := GetButton(FALSE);
    3699   if(assigned(sb)) then sb.Down := FALSE;
     3784  if (assigned(sb)) then sb.Down := FALSE;
    37003785end;
    37013786
     
    37073792begin
    37083793  inherited;
    3709   if(FButtons) then
     3794  if (FButtons) then
    37103795  begin
    37113796    btn := GetButton(TRUE);
    3712     if(assigned(btn)) then
     3797    if (assigned(btn)) then
    37133798    begin
    37143799      half := width div 2;
    37153800      btn.Left := 0;
    37163801      btn.Width := Half;
    3717       btn.Top := Height-btn.Height;
     3802      btn.Top := Height - btn.Height;
    37183803      btn := GetButton(FALSE);
    37193804      btn.Left := Half;
    37203805      btn.Width := Width - Half;
    3721       btn.Top := Height-btn.Height;
     3806      btn.Top := Height - btn.Height;
    37223807    end;
    37233808  end;
     
    37283813  btn: TSpeedButton;
    37293814  cbo: TORComboBox;
    3730   i:integer;
     3815  i: integer;
    37313816
    37323817begin
    37333818  cbo := (Owner as TORComboBox);
    3734   if(cbo.FListBox.FCheckBoxes) then
    3735   begin
    3736     if(not FButtons) then
     3819  if (cbo.FListBox.FCheckBoxes) then
     3820  begin
     3821    if (not FButtons) then
    37373822    begin
    37383823      btn := TSpeedButton.Create(Self);
     
    37573842  end
    37583843  else
    3759   if(FButtons) then
    3760   begin
    3761     for i := ControlCount-1 downto 0 do
    3762       if(Controls[i] is TButton) then
    3763         Controls[i].Free;
    3764     FButtons := FALSE;
    3765     Resize;
    3766   end;
     3844    if (FButtons) then
     3845    begin
     3846      for i := ControlCount - 1 downto 0 do
     3847        if (Controls[i] is TButton) then
     3848          Controls[i].Free;
     3849      FButtons := FALSE;
     3850      Resize;
     3851    end;
    37673852end;
    37683853
     
    37823867begin
    37833868  inherited CreateParams(Params);
    3784   Params.Style := Params.Style or ES_MULTILINE or WS_CLIPCHILDREN;
     3869// JM - removed multi-line - broke lookup when MaxLength is set, besides, it didn't really
     3870// seem to have an effect on the editing rectangle anyway.
     3871// agp change cause tab characters to show on meds and lab order dialogs
     3872//  Params.Style := Params.Style {or ES_MULTILINE} or WS_CLIPCHILDREN;
     3873    if TForm(self.Owner.Owner) <> nil then Params.Style := Params.Style or ES_MULTILINE or WS_CLIPCHILDREN
     3874    else Params.Style := Params.Style {or ES_MULTILINE} or WS_CLIPCHILDREN;
     3875
    37853876end;
    37863877
     
    37913882  begin
    37923883    if (FListBox.FCheckBoxes) and assigned(FEditPanel) and
    3793        (Message.FocusedWnd <> FListBox.Handle) and
    3794        ((not assigned(FDropBtn)) or (Message.FocusedWnd <> FDropBtn.Handle)) then
     3884      (Message.FocusedWnd <> FListBox.Handle) and
     3885      ((not assigned(FDropBtn)) or (Message.FocusedWnd <> FDropBtn.Handle)) then
    37953886    begin
    37963887      FEditPanel.FFocused := FALSE;
     
    38453936  FEditBox.OnKeyUp := FwdKeyUp;
    38463937  FEditBox.Visible := True;
    3847   fCharsNeedMatch := 1; 
     3938  fCharsNeedMatch := 1;
    38483939end;
    38493940
    38503941procedure TORComboBox.WMDestroy(var Message: TWMDestroy);
    38513942begin
    3852   if(assigned(Owner)) and (csDestroying in Owner.ComponentState) then
     3943  if (assigned(Owner)) and (csDestroying in Owner.ComponentState) then
    38533944    FListBox.DestroyItems;
    38543945  inherited;
     
    38893980function TORComboBox.EditControl: TWinControl;
    38903981begin
    3891   if(assigned(FEditPanel)) then
     3982  if (assigned(FEditPanel)) then
    38923983    Result := FEditPanel
    38933984  else
     
    38993990var
    39003991  FontHeight: Integer;
    3901   cboBtnX,cboBtnY: integer;
     3992  cboBtnX, cboBtnY: integer;
    39023993  cboYMargin: integer;
    39033994
     
    39174008    cboBtnY := CBO_CXFRAME;
    39184009  end;
    3919   Height := HigherOf(FontHeight + cboYMargin, Height);   // must be at least as high as text
     4010  Height := HigherOf(FontHeight + cboYMargin, Height); // must be at least as high as text
    39204011  EditControl.SetBounds(0, 0, Width, FontHeight + cboYMargin);
    3921   if(assigned(FEditPanel)) then
     4012  if (assigned(FEditPanel)) then
    39224013    FEditBox.SetBounds(2, 3, FEditPanel.Width - 4, FEditPanel.Height - 5);
    39234014  if FStyle = orcsDropDown then
    39244015  begin
    3925     Height := FontHeight + cboYMargin;                   // DropDown can only be text height
     4016    Height := FontHeight + cboYMargin; // DropDown can only be text height
    39264017    FDropBtn.SetBounds(EditControl.Width - CBO_CXBTN - cboBtnX, 0,
    3927                        CBO_CXBTN, EditControl.Height - cboBtnY);
     4018      CBO_CXBTN, EditControl.Height - cboBtnY);
    39284019  end else
    39294020  begin
    39304021    FListBox.SetBounds(0, FontHeight + CBO_CYMARGIN,
    3931                        Width, Height - FontHeight - CBO_CYMARGIN);
     4022      Width, Height - FontHeight - CBO_CYMARGIN);
    39324023  end;
    39334024  SetEditRect;
     
    39504041{ shift the focus back to the editbox so the focus rectangle doesn't clutter the button }
    39514042begin
    3952   if FDroppedDown then FListBox.MouseCapture := True;  // do here so 1st buttonup not captured
     4043  if FDroppedDown then FListBox.MouseCapture := True; // do here so 1st buttonup not captured
    39534044  FEditBox.SetFocus;
    39544045end;
    39554046
    39564047procedure TORComboBox.DropDownStatusChanged(opened: boolean);
    3957 begin
    3958   if opened then
    3959   begin
    3960     if not FDropPanel.Visible then
    3961     begin
    3962       if FDropDownStatusChangedCount = 0 then
     4048var
     4049  DropDownPanel: TORListBox;
     4050begin
     4051  DropDownPanel := TORListBox.Create(nil);
     4052  try
     4053    if opened then
     4054    begin
     4055      if not FDropPanel.Visible then
    39634056      begin
    3964         FDisableHints := TRUE;
    3965         DropDownPanelOpened;
     4057        if FDropDownStatusChangedCount = 0 then
     4058        begin
     4059          FDisableHints := TRUE;
     4060          DropDownPanelOpened;
     4061        end;
     4062        inc(FDropDownStatusChangedCount);
    39664063      end;
    3967       inc(FDropDownStatusChangedCount);
    3968     end;
    3969   end
    3970   else
    3971   begin
    3972     dec(FDropDownStatusChangedCount);
    3973     if FDropDownStatusChangedCount <= 0 then
    3974     begin
    3975       if FDisableHints then
     4064    end
     4065    else
     4066    begin
     4067      dec(FDropDownStatusChangedCount);
     4068      if FDropDownStatusChangedCount <= 0 then
    39764069      begin
    3977         DropDownPanelClosed;
    3978         FDisableHints := FALSE;
     4070        //agp change
     4071        //if FDisableHints then
     4072        if (FDisableHints) and (Self.Owner <> nil) then
     4073        begin
     4074          DropDownPanelClosed;
     4075          FDisableHints := FALSE;
     4076          If (GetParentForm(Self) <> nil) then 
     4077           DropDownPanel.SetHintProperties(True, GetParentForm(Self));
     4078        end;
     4079        FDropDownStatusChangedCount := 0;
    39794080      end;
    3980       FDropDownStatusChangedCount := 0;
    3981     end;
     4081    end;
     4082  finally
     4083    DropDownPanel.Free;
    39824084  end;
    39834085end;
     
    40704172begin
    40714173  FChangePending := False;
    4072   if (not FListItemsOnly) and (Length(FEditBox.Text) > 0) and (FEditBox.SelStart = 0) then Exit;  // **KCM** test this!
     4174  if (not FListItemsOnly) and (Length(FEditBox.Text) > 0) and (FEditBox.SelStart = 0) then Exit; // **KCM** test this!
    40734175  with FEditBox do x := Copy(Text, 1, SelStart);
    40744176  FLastInput := x;
     
    40794181    SelectIndex := FListBox.SelectString(x);
    40804182  if UniqueAutoComplete then
    4081     SelectIndex := FListBox.VerifyUnique(SelectIndex,x);
     4183    SelectIndex := FListBox.VerifyUnique(SelectIndex, x);
    40824184  if FListItemsOnly and (SelectIndex < 0) and (x <> '') then
    40834185  begin
     
    40864188    SelectIndex := FListBox.SelectString(x);
    40874189    FEditBox.Text := GetEditBoxText(SelectIndex);
    4088     if(not FListBox.FCheckBoxes) then
     4190    if (not FListBox.FCheckBoxes) then
    40894191      SendMessage(FEditBox.Handle, EM_SETSEL, Length(FEditBox.Text), Length(x));
    40904192    FFromSelf := False;
    4091     Exit;                              // OnChange not called in this case
     4193    Exit; // OnChange not called in this case
    40924194  end;
    40934195  FFromSelf := True;
     
    40964198    FEditBox.Text := GetEditBoxText(SelectIndex);
    40974199    FLastFound := x;
    4098     if(not FListBox.FCheckBoxes) then
     4200    if (not FListBox.FCheckBoxes) then
    40994201      SendMessage(FEditBox.Handle, EM_SETSEL, Length(FEditBox.Text), Length(x));
    41004202  end else
    41014203  begin
    4102     if(FListBox.CheckBoxes) then
     4204    if (FListBox.CheckBoxes) then
    41034205      FEditBox.Text := GetEditBoxText(SelectIndex)
    41044206    else
    4105       FEditBox.Text := x;                // no match, so don't set FLastFound
     4207      FEditBox.Text := x; // no match, so don't set FLastFound
    41064208    FEditBox.SelStart := Length(x);
    41074209  end;
    41084210  FFromSelf := False;
    4109   if(not FListBox.FCheckBoxes) then
     4211  if (not FListBox.FCheckBoxes) then
    41104212    if Assigned(FOnChange) then FOnChange(Self);
    41114213end;
     
    41464248  begin
    41474249    FFromSelf := True;
    4148     FListBox.FFocusIndex := FListBox.ItemIndex;  // FFocusIndex used so ItemTip doesn't flash
     4250    FListBox.FFocusIndex := FListBox.ItemIndex; // FFocusIndex used so ItemTip doesn't flash
    41494251    FEditBox.Text := GetEditBoxText(FListBox.ItemIndex);
    41504252    FLastFound := FEditBox.Text;
     
    41524254    // not sure why this must be posted (put at the back of the message queue), but for some
    41534255    // reason FEditBox.SelectAll selects successfully then deselects on exiting this procedure
    4154     if(not FListBox.FCheckBoxes) then
     4256    if (not FListBox.FCheckBoxes) then
    41554257      PostMessage(FEditBox.Handle, EM_SETSEL, 0, Length(FEditBox.Text));
    41564258    FEditBox.SetFocus;
    41574259  end;
    41584260  if Assigned(FOnClick) then FOnClick(Self);
    4159   if(not FListBox.FCheckBoxes) then
    4160     if Assigned(FOnChange) then FOnChange(Self);   // click causes both click & change events
     4261  if (not FListBox.FCheckBoxes) then
     4262    if Assigned(FOnChange) then FOnChange(Self); // click causes both click & change events
    41614263end;
    41624264
     
    41704272{ passed selected navigation keys to listbox, applies special handling to backspace and F4 }
    41714273var
    4172   i,iPos: Integer;
    4173   x,AString: string;
     4274  i, iPos: Integer;
     4275  x, AString: string;
    41744276begin
    41754277  // special case: when default action taken (RETURN) make sure FwdChangeDelayed is called first
    41764278  if (Key = VK_RETURN) and FListBox.LongList and FChangePending then FwdChangeDelayed;
    4177   StopKeyTimer;  // stop timer after control keys so in case an exit event is triggered
     4279  StopKeyTimer; // stop timer after control keys so in case an exit event is triggered
    41784280  if Assigned(FOnKeyDown) then FOnKeyDown(Self, Key, Shift);
    4179   if Key in [VK_PRIOR, VK_NEXT, VK_UP, VK_DOWN] then                           // navigation
     4281  if Key in [VK_PRIOR, VK_NEXT, VK_UP, VK_DOWN] then // navigation
    41804282  begin
    41814283    if (FStyle = orcsDropDown) and not DroppedDown then DroppedDown := True;
     
    41924294        if iPos > -1 then
    41934295        begin
    4194           FListBox.FFocusIndex := iPos-1;
     4296          FListBox.FFocusIndex := iPos - 1;
    41954297          FListBox.ItemIndex := FListBox.FFocusIndex;
    41964298        end;
     
    41994301    FListBox.Perform(WM_KEYDOWN, Key, 1);
    42004302  end;
    4201   if Key in [VK_LBUTTON, VK_RETURN, VK_PRIOR, VK_NEXT, VK_UP, VK_DOWN] then    // select item
     4303  if Key in [VK_LBUTTON, VK_RETURN, VK_PRIOR, VK_NEXT, VK_UP, VK_DOWN] then // select item
    42024304  begin
    42034305    FListBox.Perform(WM_KEYDOWN, VK_LBUTTON, 1);
     
    42064308    begin
    42074309      FEditBox.Text := GetEditBoxText(FListBox.ItemIndex);
    4208       FLastFound := FEditBox.Text;  //kcm
     4310      FLastFound := FEditBox.Text; //kcm
    42094311    end;
    42104312    FFromSelf := False;
     
    42124314  // tell parent about RETURN, ESCAPE so that the default action is taken
    42134315  if Key in [VK_RETURN, VK_ESCAPE, VK_TAB] then SendMessage(Parent.Handle, CN_KEYDOWN, Key, 0);
    4214   if Key = VK_BACK then                                                        // backspace
     4316  if Key = VK_BACK then // backspace
    42154317  begin
    42164318    FFromSelf := True;
     
    42184320    i := FEditBox.SelStart;
    42194321    Delete(x, i + 1, Length(x));
    4220     if(FListBox.FCheckBoxes) then
     4322    if (FListBox.FCheckBoxes) then
    42214323      FEditBox.Text := GetEditBoxText(ItemIndex)
    42224324    else
     
    42954397{ for DropDown combo, display the listbox at the appropriate full screen coordinates }
    42964398const
    4297   MIN_ITEMS = 3;                                  // minimum visible items for long list
     4399  MIN_ITEMS = 3; // minimum visible items for long list
    42984400var
    42994401  ScreenPoint: TPoint;
     
    43084410    if FListBox.LongList
    43094411      then DropDownCnt := HigherOf(FDropDownCount, MIN_ITEMS)
    4310       else DropDownCnt := LowerOf(FDropDownCount, FListBox.Items.Count);
     4412    else DropDownCnt := LowerOf(FDropDownCount, FListBox.Items.Count);
    43114413    FListBox.SetBounds(0, 0, Width, (FListBox.ItemHeight * DropDownCnt) + CBO_CXFRAME);
    43124414    // need to make this smart enough to drop the list UP when necessary ***
     
    43144416
    43154417    PnlHeight := FListBox.Height;
    4316     if(FListBox.FCheckBoxes) then
     4418    if (FListBox.FCheckBoxes) then
    43174419      inc(PnlHeight, CheckComboBtnHeight);
    43184420    FDropPanel.SetBounds(ScreenPoint.X, ScreenPoint.Y, FListBox.Width, PnlHeight);
    4319     if(FListBox.FCheckBoxes) then
     4421    if (FListBox.FCheckBoxes) then
    43204422    begin
    43214423      FDropPanel.ResetButtons;
     
    43264428    FDropPanel.BringToFront;
    43274429    if FListBox.FScrollBar <> nil then FListBox.FScrollBar.BringToFront;
    4328     if not FFromDropBtn then FListBox.MouseCapture := True;  // otherwise ButtonUp captures
     4430    if not FFromDropBtn then FListBox.MouseCapture := True; // otherwise ButtonUp captures
    43294431  end else
    43304432  begin
     
    43344436    FDropPanel.Hide;
    43354437    DropDownStatusChanged(FALSE);
    4336     if(FListBox.FCheckBoxes) and (assigned(FOnChange)) and
     4438    if (FListBox.FCheckBoxes) and (assigned(FOnChange)) and
    43374439      (FCheckedState <> FListBox.GetCheckedString) then
    43384440      FOnChange(Self);
     
    43464448begin
    43474449  SendMessage(FEditBox.Handle, EM_GETRECT, 0, LongInt(@Loc));
    4348   Loc.Bottom := ClientHeight + 1;               // +1 is workaround for windows paint bug
     4450  Loc.Bottom := ClientHeight + 1; // +1 is workaround for windows paint bug
    43494451  if FStyle = orcsDropDown then
    43504452  begin
    4351     Loc.Right := ClientWidth - FDropBtn.Width - CBO_CXFRAME;  // edit up to button
    4352     if(FTemplateField) then
    4353       inc(Loc.Right,3);
     4453    Loc.Right := ClientWidth - FDropBtn.Width - CBO_CXFRAME; // edit up to button
     4454    if (FTemplateField) then
     4455      inc(Loc.Right, 3);
    43544456  end
    43554457  else
    4356     Loc.Right := ClientWidth - CBO_CXFRAME;                  // edit in full edit box
     4458    Loc.Right := ClientWidth - CBO_CXFRAME; // edit in full edit box
    43574459  Loc.Top := 0;
    4358   if(FTemplateField) then
     4460  if (FTemplateField) then
    43594461    Loc.Left := 2
    43604462  else
     
    43834485    if Value = -1 then FFocusIndex := -1 else FocusIndex := Value;
    43844486    uItemTip.Hide;
    4385     if(FListBox.CheckBoxes) then
     4487    if (FListBox.CheckBoxes) then
    43864488      SetEditText(GetEditBoxText(ItemIndex))
    43874489    else
     
    44304532      FListBox.FParentCombo := nil;
    44314533      FListBox.Parent := Self;
    4432       if FListBox.FScrollBar <> nil then FListBox.FScrollBar.Parent := Self;        // if long
     4534      if FListBox.FScrollBar <> nil then FListBox.FScrollBar.Parent := Self; // if long
    44334535      FListBox.Visible := True;
    44344536    end else
    44354537    begin
    44364538      FDropBtn := TBitBtn.Create(Self);
    4437       if(assigned(FEditPanel) and (csDesigning in ComponentState)) then
     4539      if (assigned(FEditPanel) and (csDesigning in ComponentState)) then
    44384540        FEditPanel.ControlStyle := FEditPanel.ControlStyle + [csAcceptsControls];
    44394541      FDropBtn.Parent := FEditBox;
    4440       if(assigned(FEditPanel) and (csDesigning in ComponentState)) then
     4542      if (assigned(FEditPanel) and (csDesigning in ComponentState)) then
    44414543        FEditPanel.ControlStyle := FEditPanel.ControlStyle - [csAcceptsControls];
    44424544      LoadComboBoxImage;
     
    44544556        FListBox.Parent := FDropPanel;
    44554557        ClearDropDownStatus;
    4456         if FListBox.FScrollBar <> nil then FListBox.FScrollBar.Parent := FDropPanel;  // if long
     4558        if FListBox.FScrollBar <> nil then FListBox.FScrollBar.Parent := FDropPanel; // if long
    44574559      end else
    44584560      begin
     
    47184820procedure TORComboBox.SetColor(Value: TColor);
    47194821begin
    4720   if(not FListBox.CheckBoxes) then
     4822  if (not FListBox.CheckBoxes) then
    47214823    FEditBox.Color := Value;
    47224824  FListBox.Color := Value;
     
    47954897procedure TORComboBox.SetText(const Value: string);
    47964898begin
    4797   FEditBox.Text := Value;        // kcm ???
     4899  FEditBox.Text := Value; // kcm ???
    47984900end;
    47994901
     
    48254927procedure TORComboBox.SetCheckBoxes(const Value: boolean);
    48264928begin
    4827   if(FListBox.FCheckBoxes <> Value) then
     4929  if (FListBox.FCheckBoxes <> Value) then
    48284930  begin
    48294931    FListBox.SetCheckBoxes(Value);
    4830     if(assigned(FDropPanel)) then
     4932    if (assigned(FDropPanel)) then
    48314933      FDropPanel.UpdateButtons;
    48324934    FEditBox.Visible := FALSE;
    48334935    try
    4834       if(Value) then
     4936      if (Value) then
    48354937      begin
    48364938        SetListItemsOnly(TRUE);
     
    48444946        FEditPanel.BorderWidth := 1;
    48454947        FEditBox.Parent := FEditPanel;
    4846         if(csDesigning in ComponentState) then
     4948        if (csDesigning in ComponentState) then
    48474949          FEditPanel.ControlStyle := FEditPanel.ControlStyle - [csAcceptsControls];
    48484950      end
     
    48654967begin
    48664968  FListBox.SetChecked(Index, Value);
    4867   if(assigned(FDropPanel)) then
     4969  if (assigned(FDropPanel)) then
    48684970    FDropPanel.UpdateButtons;
    4869   if(Value) then
     4971  if (Value) then
    48704972    SetListItemsOnly(TRUE);
    48714973end;
     
    48864988
    48874989begin
    4888   if(assigned(FDropPanel)) then
     4990  if (assigned(FDropPanel)) then
    48894991  begin
    48904992    btn := FDropPanel.GetButton(OKBtn);
    4891     if(assigned(Btn)) then
     4993    if (assigned(Btn)) then
    48924994      Btn.Down := TRUE;
    48934995  end;
    4894   if(not OKBtn) then FListBox.SetCheckedString(FCheckedState);
    4895   if(AutoClose) then
     4996  if (not OKBtn) then FListBox.SetCheckedString(FCheckedState);
     4997  if (AutoClose) then
    48964998  begin
    48974999    FListBox.FDontClose := FALSE;
     
    49135015procedure TORComboBox.SetCheckBoxEditColor(const Value: TColor);
    49145016begin
    4915   if(FCheckBoxEditColor <> Value) then
     5017  if (FCheckBoxEditColor <> Value) then
    49165018  begin
    49175019    FCheckBoxEditColor := Value;
    4918     if(FListBox.FCheckBoxes) then
     5020    if (FListBox.FCheckBoxes) then
    49195021      FEditBox.Color := FCheckBoxEditColor;
    49205022  end;
     
    49235025procedure TORComboBox.SetListItemsOnly(const Value: Boolean);
    49245026begin
    4925   if(FListItemsOnly <> Value) then
     5027  if (FListItemsOnly <> Value) then
    49265028  begin
    49275029    FListItemsOnly := Value;
    4928     if(not Value) then
     5030    if (not Value) then
    49295031      SetCheckBoxes(FALSE);
    49305032  end;
     
    49395041procedure TORComboBox.SetTemplateField(const Value: boolean);
    49405042begin
    4941   if(FTemplateField <> Value) then
     5043  if (FTemplateField <> Value) then
    49425044  begin
    49435045    FTemplateField := Value;
    4944     if(Value) then
     5046    if (Value) then
    49455047    begin
    49465048      SetStyle(orcsDropDown);
     
    49855087
    49865088begin
    4987   if(FListBox.FCheckBoxes) then
     5089  if (FListBox.FCheckBoxes) then
    49885090  begin
    49895091    Result := '';
    49905092    cnt := 0;
    4991     for i := 0 to FListBox.Items.Count-1 do
    4992     begin
    4993       if(FListBox.Checked[i]) then
     5093    for i := 0 to FListBox.Items.Count - 1 do
     5094    begin
     5095      if (FListBox.Checked[i]) then
    49945096      begin
    49955097        inc(cnt);
    4996         if(Result <> '') then
     5098        if (Result <> '') then
    49975099          Result := Result + ', ';
    49985100        Result := Result + FListBox.GetDisplayText(i);
    49995101      end;
    50005102    end;
    5001     if(assigned(FOnCheckedText)) then
     5103    if (assigned(FOnCheckedText)) then
    50025104      FOnCheckedText(FListBox, cnt, Result);
    50035105  end
     
    50085110procedure TORComboBox.UpdateCheckEditBoxText;
    50095111begin
    5010   if(FListBox.FCheckBoxes) then
     5112  if (FListBox.FCheckBoxes) then
    50115113  begin
    50125114    FFromSelf := TRUE;
     
    50205122begin
    50215123  UpdateCheckEditBoxText;
    5022   if(FStyle <> orcsDropDown) and (assigned(FOnChange)) then
     5124  if (FStyle <> orcsDropDown) and (assigned(FOnChange)) then
    50235125    FOnChange(Self);
    50245126end;
     
    50765178begin
    50775179  if FSizes <> nil then with FSizes do for i := 0 to Count - 1 do
    5078   begin
    5079     SizeRatio := Items[i];
    5080     SizeRatio.Free;
    5081   end;
     5180      begin
     5181        SizeRatio := Items[i];
     5182        SizeRatio.Free;
     5183      end;
    50825184  FSizes.Free;
    50835185  inherited Destroy;
    50845186end;
    50855187
    5086 procedure TORAutoPanel.BuildSizes( Control: TWinControl);
    5087 var
    5088   i,H,W: Integer;
     5188procedure TORAutoPanel.BuildSizes(Control: TWinControl);
     5189var
     5190  i, H, W: Integer;
    50895191  SizeRatio: TSizeRatio;
    50905192  Child: TControl;
     
    50975199    Child := Control.Controls[i];
    50985200    with Child do
    5099       SizeRatio := TSizeRatio.Create(Left/W, Top/H, Width/W, Height/H);
    5100     FSizes.Add(SizeRatio);  //FSizes is in tree traversal order.
     5201      SizeRatio := TSizeRatio.Create(Left / W, Top / H, Width / W, Height / H);
     5202    FSizes.Add(SizeRatio); //FSizes is in tree traversal order.
    51015203    //TGroupBox is currently the only type of container that is having these
    51025204    //resize problems
     
    51105212begin
    51115213  inherited Loaded;
    5112   if csDesigning in ComponentState then Exit;          // only want auto-resizing at run time
     5214  if csDesigning in ComponentState then Exit; // only want auto-resizing at run time
    51135215  FSizes := TList.Create;
    51145216  BuildSizes(Self);
    51155217end;
    51165218
    5117 procedure TORAutoPanel.DoResize( Control: TWinControl; var CurrentIndex: Integer);
    5118 var
    5119   i,H,W: Integer;
     5219procedure TORAutoPanel.DoResize(Control: TWinControl; var CurrentIndex: Integer);
     5220var
     5221  i, H, W: Integer;
    51205222  SizeRatio: TSizeRatio;
    51215223  Child: TControl;
     
    51325234    with SizeRatio do begin
    51335235      if (Child is TLabel) or (Child is TStaticText) then
    5134         Child.SetBounds(Round(CLeft*W), Round(CTop*H), Child.Width, Child.Height)
     5236        Child.SetBounds(Round(CLeft * W), Round(CTop * H), Child.Width, Child.Height)
    51355237      else
    5136         Child.SetBounds(Round(CLeft*W), Round(CTop*H), Round(CWidth*W), Round(CHeight*H));
     5238        Child.SetBounds(Round(CLeft * W), Round(CTop * H), Round(CWidth * W), Round(CHeight * H));
    51375239    end;
    51385240    if Child is TGroupBox then
     
    51475249begin
    51485250  inherited Resize;
    5149   if csDesigning in ComponentState then Exit;          // only want auto-resizing at run time
     5251  if csDesigning in ComponentState then Exit; // only want auto-resizing at run time
    51505252  i := 0;
    5151   DoResize( Self, i);
     5253  DoResize(Self, i);
    51525254end;
    51535255
     
    51915293    Flags := DT_EXPANDTABS or DT_CALCRECT;
    51925294    if FWordWrap then Flags := Flags or DT_WORDBREAK;
    5193     DoDrawText(ARect, Flags);                                      // returns size of text rect
     5295    DoDrawText(ARect, Flags); // returns size of text rect
    51945296    Canvas.Handle := 0;
    51955297    ReleaseDC(0, DC);
     
    52275329    ARect := ClientRect;
    52285330    Inc(ARect.Left, FHorzOffset);
    5229     Inc(ARect.Top,  FVertOffset);
     5331    Inc(ARect.Top, FVertOffset);
    52305332    Flags := DT_EXPANDTABS or DT_NOPREFIX or DT_LEFT;
    52315333    if FWordWrap then Flags := Flags or DT_WORDBREAK;
     
    52465348  begin
    52475349    if Value
    5248       then ControlStyle := ControlStyle - [csOpaque]   // transparent = true
    5249       else ControlStyle := ControlStyle + [csOpaque]; // transparent = false
     5350      then ControlStyle := ControlStyle - [csOpaque] // transparent = true
     5351    else ControlStyle := ControlStyle + [csOpaque]; // transparent = false
    52505352    Invalidate;
    52515353  end;
     
    53185420  inherited CreateParams(Params);
    53195421  Params.Style := Params.Style or ButtonAlignment[FAlignment] or
    5320                                   ButtonLayout[FLayout] or
    5321                                   ButtonWordWrap[FWordWrap];
     5422    ButtonLayout[FLayout] or
     5423    ButtonWordWrap[FWordWrap];
    53225424end;
    53235425
    53245426procedure TORAlignButton.SetAlignment(const Value: TAlignment);
    53255427begin
    5326   if(FAlignment <> Value) then
     5428  if (FAlignment <> Value) then
    53275429  begin
    53285430    FAlignment := Value;
     
    53335435procedure TORAlignButton.SetLayout(const Value: TTextLayout);
    53345436begin
    5335   if(FLayout <> Value) then
     5437  if (FLayout <> Value) then
    53365438  begin
    53375439    FLayout := Value;
     
    53425444procedure TORAlignButton.SetWordWrap(const Value: boolean);
    53435445begin
    5344   if(FWordWrap <> Value) then
     5446  if (FWordWrap <> Value) then
    53455447  begin
    53465448    FWordWrap := Value;
     
    53595461  MakeVisible;
    53605462  R := DisplayRect(FALSE);
    5361   if(R.Top < 0) then
     5463  if (R.Top < 0) then
    53625464    TreeView.TopItem := Self
    53635465  else
    5364   if(R.Bottom > TreeView.ClientHeight) then
    5365   begin
    5366     DY := R.Bottom - TreeView.ClientHeight;
    5367     LH := R.Bottom - R.Top + 1;
    5368     DY := (DY div LH) + 1;
    5369     GetORTreeView.SetVertScrollPos(GetORTreeView.GetVertScrollPos + DY);
    5370   end;
     5466    if (R.Bottom > TreeView.ClientHeight) then
     5467    begin
     5468      DY := R.Bottom - TreeView.ClientHeight;
     5469      LH := R.Bottom - R.Top + 1;
     5470      DY := (DY div LH) + 1;
     5471      GetORTreeView.SetVertScrollPos(GetORTreeView.GetVertScrollPos + DY);
     5472    end;
    53715473end;
    53725474
     
    53975499function TORTreeNode.GetText: string;
    53985500begin
    5399   Result := Inherited Text;
     5501  Result := inherited Text;
    54005502end;
    54015503
     
    54235525  begin
    54245526    ORCtrls.SetPiece(FStringData, FDelim, PieceNum, NewPiece);
    5425     if(PieceNum = FPiece) then
     5527    if (PieceNum = FPiece) then
    54265528      Text := NewPiece;
    54275529  end;
     
    54305532procedure TORTreeNode.SetStringData(const Value: string);
    54315533begin
    5432   if(FStringData <> Value) then
     5534  if (FStringData <> Value) then
    54335535  begin
    54345536    FStringData := Value;
     
    54475549procedure TORTreeNode.UpdateText(const Value: string; UpdateData: boolean);
    54485550begin
    5449   Inherited Text := Value;
     5551  inherited Text := Value;
    54505552  Caption := Text;
    5451   if(UpdateData) then
     5553  if (UpdateData) then
    54525554    with GetORTreeView do
    54535555    begin
     
    54575559end;
    54585560
    5459 function CalcShortName( LongName: string; PrevLongName: string): string;
     5561function CalcShortName(LongName: string; PrevLongName: string): string;
    54605562var
    54615563  WordBorder: integer;
     
    54655567  for j := 1 to Length(LongName) do
    54665568  begin
    5467     if (LongName[j] = ' ') or ((j > 1) and (LongName[j-1] = ' ')) or
     5569    if (LongName[j] = ' ') or ((j > 1) and (LongName[j - 1] = ' ')) or
    54685570      ((j = Length(LongName)) and (j = Length(PrevLongName)) and (LongName[j] = PrevLongName[j])) then
    54695571      WordBorder := j;
     
    54745576    result := LongName
    54755577  else if WordBorder = Length(LongName) then
    5476     result := 'Same as above ('+LongName+')'
     5578    result := 'Same as above (' + LongName + ')'
    54775579  else
    5478     result := Copy(LongName,WordBorder,Length(LongName)) + ' ('+Trim(Copy(LongName,1,WordBorder -1)) + ')';
     5580    result := Copy(LongName, WordBorder, Length(LongName)) + ' (' + Trim(Copy(LongName, 1, WordBorder - 1)) + ')';
    54795581end;
    54805582
     
    54895591      OnNodeCaptioning(self, TheCaption);
    54905592    if ShortNodeCaptions and (Self.GetPrevSibling <> nil) then
    5491       TheCaption := CalcShortName( TheCaption, Self.GetPrevSibling.Text);
     5593      TheCaption := CalcShortName(TheCaption, Self.GetPrevSibling.Text);
    54925594  end;
    54935595  FCaption := TheCaption;
     
    55035605begin
    55045606  DoInh := TRUE;
    5505   if(assigned(FOnDragging)) then
     5607  if (assigned(FOnDragging)) then
    55065608  begin
    55075609    with Message do
     
    55165618            end;
    55175619            FOnDragging(Self, DNode, DoInh);
    5518             if(not DoInh) then
     5620            if (not DoInh) then
    55195621            begin
    55205622              Message.Result := 1;
     
    55255627    end;
    55265628  end;
    5527   if(DoInh) then inherited;
     5629  if (DoInh) then inherited;
    55285630end;
    55295631
     
    55375639begin
    55385640  Result := TORTreeNode.Create(Items);
    5539   if Assigned( OnAddition ) then
     5641  if Assigned(OnAddition) then
    55405642    OnAddition(self, Result);
    55415643end;
    55425644
    55435645function TORTreeView.FindPieceNode(Value: string;
    5544                                    ParentDelim: Char = #0; StartNode: TTreeNode = nil): TORTreeNode;
     5646  ParentDelim: Char = #0; StartNode: TTreeNode = nil): TORTreeNode;
    55455647begin
    55465648  Result := FindPieceNode(Value, FPiece, ParentDelim, StartNode);
     
    55485650
    55495651function TORTreeView.FindPieceNode(Value: string; APiece: integer;
    5550                                    ParentDelim: Char = #0; StartNode: TTreeNode = nil): TORTreeNode;
     5652  ParentDelim: Char = #0; StartNode: TTreeNode = nil): TORTreeNode;
    55515653var
    55525654  StartIdx, i: integer;
     
    55555657begin
    55565658  if assigned(StartNode) then
    5557     StartIdx := StartNode.AbsoluteIndex+1
     5659    StartIdx := StartNode.AbsoluteIndex + 1
    55585660  else
    55595661    StartIdx := 0;
    55605662  Result := nil;
    5561   for i := StartIdx to Items.Count-1 do
     5663  for i := StartIdx to Items.Count - 1 do
    55625664  begin
    55635665    Node := (Items[i] as TORTreeNode);
    5564     if(GetNodeID(Node, APiece, ParentDelim) = Value) then
     5666    if (GetNodeID(Node, APiece, ParentDelim) = Value) then
    55655667    begin
    55665668      Result := Node;
     
    55765678begin
    55775679  Result := '';
    5578   for i := 0 to Items.Count-1 do
     5680  for i := 0 to Items.Count - 1 do
    55795681  begin
    55805682    with (Items[i] as TORTreeNode) do
    55815683    begin
    5582       if(Expanded) then
     5684      if (Expanded) then
    55835685      begin
    5584         if(Result <> '') then
     5686        if (Result <> '') then
    55855687          Result := Result + FDelim;
    55865688        Result := Result + GetNodeID(TORTreeNode(Items[i]), APiece, ParentDelim);
     
    55965698
    55975699procedure TORTreeView.SetExpandedIDStr(APiece: integer; ParentDelim: char;
    5598                                                         const Value: string);
     5700  const Value: string);
    55995701var
    56005702  i: integer;
     
    56145716    repeat
    56155717      i := pos(FDelim, NList);
    5616       if(i = 0) then i := length(NList)+1;
    5617       Srch := copy(NList,1,i-1);
     5718      if (i = 0) then i := length(NList) + 1;
     5719      Srch := copy(NList, 1, i - 1);
    56185720      Node := FindPieceNode(Srch, APiece, ParentDelim);
    5619       if(assigned(Node)) then
     5721      if (assigned(Node)) then
    56205722        Node.Expand(FALSE);
    5621       Nlist := copy(NList,i+1,MaxInt);
    5622     until(NList = '');
     5723      Nlist := copy(NList, i + 1, MaxInt);
     5724    until (NList = '');
    56235725    TopItem := Top;
    56245726    Selected := Sel;
     
    56405742procedure TORTreeView.RenameNodes;
    56415743var
    5642   i:integer;
    5643 
    5644 begin
    5645   if(FDelim <> #0) and (FPiece > 0) then
    5646   begin
    5647     for i := 0 to Items.Count-1 do
     5744  i: integer;
     5745
     5746begin
     5747  if (FDelim <> #0) and (FPiece > 0) then
     5748  begin
     5749    for i := 0 to Items.Count - 1 do
    56485750      with (Items[i] as TORTreeNode) do
    56495751        UpdateText(Piece(FStringData, FDelim, FPiece), FALSE);
     
    56535755procedure TORTreeView.SetNodeDelim(const Value: Char);
    56545756begin
    5655   if(FDelim <> Value) then
     5757  if (FDelim <> Value) then
    56565758  begin
    56575759    FDelim := Value;
     
    56625764procedure TORTreeView.SetHorzScrollPos(Value: integer);
    56635765begin
    5664   if(Value < 0) then Value := 0;
    5665   Perform(WM_HSCROLL,MakeWParam(SB_THUMBPOSITION, Value),0);
     5766  if (Value < 0) then Value := 0;
     5767  Perform(WM_HSCROLL, MakeWParam(SB_THUMBPOSITION, Value), 0);
    56665768end;
    56675769
    56685770procedure TORTreeView.SetNodePiece(const Value: integer);
    56695771begin
    5670   if(FPiece <> Value) then
     5772  if (FPiece <> Value) then
    56715773  begin
    56725774    FPiece := Value;
     
    56775779procedure TORTreeView.SetVertScrollPos(Value: integer);
    56785780begin
    5679   if(Value < 0) then Value := 0;
    5680   Perform(WM_VSCROLL,MakeWParam(SB_THUMBPOSITION, Value),0);
     5781  if (Value < 0) then Value := 0;
     5782  Perform(WM_VSCROLL, MakeWParam(SB_THUMBPOSITION, Value), 0);
    56815783end;
    56825784
     
    56905792  ParentDelim: Char): string;
    56915793begin
    5692   if(assigned(Node)) then
     5794  if (assigned(Node)) then
    56935795  begin
    56945796    Result := Piece(Node.FStringData, FDelim, APiece);
    5695     if((ParentDelim <> #0) and (ParentDelim <> FDelim) and (assigned(Node.Parent))) then
     5797    if ((ParentDelim <> #0) and (ParentDelim <> FDelim) and (assigned(Node.Parent))) then
    56965798      Result := Result + ParentDelim + GetNodeID(Node.Parent, APiece, ParentDelim);
    56975799  end
     
    57425844  function RStr(Value: integer): string;
    57435845  begin
    5744     if(Value <> -1) then
     5846    if (Value <> -1) then
    57455847      Result := IntToStr(Value)
    57465848    else
     
    57515853begin
    57525854  Result := RStr(FCheckedEnabledIndex) +
    5753             RStr(FGrayedEnabledIndex) +
    5754             RStr(FUncheckedEnabledIndex) +
    5755             RStr(FCheckedDisabledIndex) +
    5756             RStr(FGrayedDisabledIndex) +
    5757             RStr(FUncheckedDisabledIndex);
    5758   delete(Result,length(Result),1);
    5759   if(Result = ',,,,,') then Result := '';
     5855    RStr(FGrayedEnabledIndex) +
     5856    RStr(FUncheckedEnabledIndex) +
     5857    RStr(FCheckedDisabledIndex) +
     5858    RStr(FGrayedDisabledIndex) +
     5859    RStr(FUncheckedDisabledIndex);
     5860  delete(Result, length(Result), 1);
     5861  if (Result = ',,,,,') then Result := '';
    57605862end;
    57615863
    57625864procedure TORCBImageIndexes.SetIdxString(Value: string);
    57635865var
    5764   i,j,v: integer;
    5765   Sub: String;
    5766 
    5767 begin
    5768   if(Value = '') then
    5769   begin
    5770     FCheckedEnabledIndex    := -1;
    5771     FGrayedEnabledIndex     := -1;
    5772     FUncheckedEnabledIndex  := -1;
    5773     FCheckedDisabledIndex   := -1;
    5774     FGrayedDisabledIndex    := -1;
     5866  i, j, v: integer;
     5867  Sub: string;
     5868
     5869begin
     5870  if (Value = '') then
     5871  begin
     5872    FCheckedEnabledIndex := -1;
     5873    FGrayedEnabledIndex := -1;
     5874    FUncheckedEnabledIndex := -1;
     5875    FCheckedDisabledIndex := -1;
     5876    FGrayedDisabledIndex := -1;
    57755877    FUncheckedDisabledIndex := -1;
    57765878  end
     
    57805882    Sub := Value;
    57815883    repeat
    5782       j := pos(',',Sub);
    5783       if(j = 0) then j := length(Sub)+1;
    5784       v := StrToIntDef(copy(Sub,1,j-1),-1);
     5884      j := pos(',', Sub);
     5885      if (j = 0) then j := length(Sub) + 1;
     5886      v := StrToIntDef(copy(Sub, 1, j - 1), -1);
    57855887      case i of
    5786         0: FCheckedEnabledIndex    := v;
    5787         1: FGrayedEnabledIndex     := v;
    5788         2: FUncheckedEnabledIndex  := v;
    5789         3: FCheckedDisabledIndex   := v;
    5790         4: FGrayedDisabledIndex    := v;
     5888        0: FCheckedEnabledIndex := v;
     5889        1: FGrayedEnabledIndex := v;
     5890        2: FUncheckedEnabledIndex := v;
     5891        3: FCheckedDisabledIndex := v;
     5892        4: FGrayedDisabledIndex := v;
    57915893        5: FUncheckedDisabledIndex := v;
    57925894      end;
    57935895      inc(i);
    5794       Sub := copy(Sub,j+1,MaxInt);
    5795     until(Sub = '');
     5896      Sub := copy(Sub, j + 1, MaxInt);
     5897    until (Sub = '');
    57965898  end;
    57975899end;
     
    57995901procedure TORCBImageIndexes.ImageListChanged(Sender: TObject);
    58005902begin
    5801   if(Owner is TWinControl) then
     5903  if (Owner is TWinControl) then
    58025904    (Owner as TWinControl).Invalidate;
    58035905end;
     
    58115913procedure TORCBImageIndexes.SetCheckedDisabledIndex(const Value: integer);
    58125914begin
    5813   if(FCheckedDisabledIndex <> Value) then
     5915  if (FCheckedDisabledIndex <> Value) then
    58145916  begin
    58155917    FCheckedDisabledIndex := Value;
     
    58205922procedure TORCBImageIndexes.SetCheckedEnabledIndex(const Value: integer);
    58215923begin
    5822   if(FCheckedEnabledIndex <> Value) then
     5924  if (FCheckedEnabledIndex <> Value) then
    58235925  begin
    58245926    FCheckedEnabledIndex := Value;
     
    58295931procedure TORCBImageIndexes.SetGrayedDisabledIndex(const Value: integer);
    58305932begin
    5831   if(FGrayedDisabledIndex <> Value) then
     5933  if (FGrayedDisabledIndex <> Value) then
    58325934  begin
    58335935    FGrayedDisabledIndex := Value;
     
    58385940procedure TORCBImageIndexes.SetGrayedEnabledIndex(const Value: integer);
    58395941begin
    5840   if(FGrayedEnabledIndex <> Value) then
     5942  if (FGrayedEnabledIndex <> Value) then
    58415943  begin
    58425944    FGrayedEnabledIndex := Value;
     
    58475949procedure TORCBImageIndexes.SetUncheckedDisabledIndex(const Value: integer);
    58485950begin
    5849   if(FUncheckedDisabledIndex <> Value) then
     5951  if (FUncheckedDisabledIndex <> Value) then
    58505952  begin
    58515953    FUncheckedDisabledIndex := Value;
     
    58565958procedure TORCBImageIndexes.SetUncheckedEnabledIndex(const Value: integer);
    58575959begin
    5858   if(FUncheckedEnabledIndex <> Value) then
     5960  if (FUncheckedEnabledIndex <> Value) then
    58595961  begin
    58605962    FUncheckedEnabledIndex := Value;
     
    58895991destructor TORCheckBox.Destroy;
    58905992begin
    5891   if(FCustomImagesOwned) then FCustomImages.Free;
     5993  if (FCustomImagesOwned) then FCustomImages.Free;
    58925994  FCanvas.Free;
    58935995  inherited;
     
    59176019procedure TORCheckBox.Toggle;
    59186020begin
    5919   if(FGrayedToChecked) then
     6021  if (FGrayedToChecked) then
    59206022  begin
    59216023    case State of
     
    59696071
    59706072procedure TORCheckBox.GetDrawData(CanvasHandle: HDC; var Bitmap: TBitmap;
    5971                                          var FocRect, Rect: TRect;
    5972                                          var DrawOptions: UINT;
    5973                                          var TempBitMap: boolean);
     6073  var FocRect, Rect: TRect;
     6074  var DrawOptions: UINT;
     6075  var TempBitMap: boolean);
    59746076var
    59756077  i, l, TxtHeight, TxtWidth, AWidth: Integer;
     
    59836085  FSingleLine := TRUE;
    59846086
    5985   if(not (csDestroying in ComponentState)) then
     6087  if (not (csDestroying in ComponentState)) then
    59866088  begin
    59876089    with FCustomImages do
     
    59936095        begin
    59946096          CustomImgIdx := -1;
    5995           if(assigned(FImages)) then
     6097          if (assigned(FImages)) then
    59966098          begin
    5997             if(Enabled or (csDesigning in ComponentState)) then
     6099            if (Enabled or (csDesigning in ComponentState)) then
    59986100            begin
    59996101              case State of
    6000                 cbChecked:   CustomImgIdx := FCheckedEnabledIndex;
     6102                cbChecked: CustomImgIdx := FCheckedEnabledIndex;
    60016103                cbUnChecked: CustomImgIdx := FUncheckedEnabledIndex;
    6002                 cbGrayed:    CustomImgIdx := FGrayedEnabledIndex;
     6104                cbGrayed: CustomImgIdx := FGrayedEnabledIndex;
    60036105              end;
    60046106            end
     
    60066108            begin
    60076109              case State of
    6008                 cbChecked:   CustomImgIdx := FCheckedDisabledIndex;
     6110                cbChecked: CustomImgIdx := FCheckedDisabledIndex;
    60096111                cbUnChecked: CustomImgIdx := FUncheckedDisabledIndex;
    6010                 cbGrayed:    CustomImgIdx := FGrayedDisabledIndex;
     6112                cbGrayed: CustomImgIdx := FGrayedDisabledIndex;
    60116113              end;
    60126114            end;
    6013             if((CustomImgIdx < 0) or (CustomImgIdx >= FImages.Count)) then
     6115            if ((CustomImgIdx < 0) or (CustomImgIdx >= FImages.Count)) then
    60146116              CustomImgIdx := -1;
    60156117          end;
    6016           if(CustomImgIdx < 0) then
     6118          if (CustomImgIdx < 0) then
    60176119          begin
    60186120            ImgIdx := iiChecked;
    6019             if(Enabled or (csDesigning in ComponentState)) then
     6121            if (Enabled or (csDesigning in ComponentState)) then
    60206122            begin
    6021               if(FRadioStyle) then
     6123              if (FRadioStyle) then
    60226124              begin
    60236125                if State = cbChecked then
     
    60296131              begin
    60306132                case State of
    6031                   cbChecked:   ImgIdx := iiChecked;
     6133                  cbChecked: ImgIdx := iiChecked;
    60326134                  cbUnChecked: ImgIdx := iiUnchecked;
    60336135                  cbGrayed:
    60346136                    begin
    60356137                      case FGrayedStyle of
    6036                         gsNormal:           ImgIdx := iiGrayed;
    6037                         gsQuestionMark:     ImgIdx := iiQMark;
     6138                        gsNormal: ImgIdx := iiGrayed;
     6139                        gsQuestionMark: ImgIdx := iiQMark;
    60386140                        gsBlueQuestionMark: ImgIdx := iiBlueQMark;
    60396141                      end;
     
    60446146            else
    60456147            begin
    6046               if(FRadioStyle) then
     6148              if (FRadioStyle) then
    60476149              begin
    60486150                if State = cbChecked then
     
    60546156              begin
    60556157                case State of
    6056                   cbChecked:   ImgIdx := iiDisChecked;
     6158                  cbChecked: ImgIdx := iiDisChecked;
    60576159                  cbUnChecked: ImgIdx := iiDisUnchecked;
    60586160                  cbGrayed:
    60596161                    begin
    6060                       if(FGrayedStyle = gsNormal) then
     6162                      if (FGrayedStyle = gsNormal) then
    60616163                        ImgIdx := iiDisGrayed
    60626164                      else
     
    60826184            Rect.Left := Bitmap.Width + 5;
    60836185
    6084           if(FWordWrap) then
     6186          if (FWordWrap) then
    60856187            DrawOptions := DrawOptions or DT_WORDBREAK
    60866188          else
    60876189            DrawOptions := DrawOptions or DT_VCENTER or DT_SINGLELINE;
    60886190
    6089           if(FWordWrap) then
     6191          if (FWordWrap) then
    60906192          begin
    60916193            if Alignment = taLeftJustify then
     
    60946196              Rect.Right := Width;
    60956197            Rect.Top := 1;
    6096             Rect.Bottom := Height+1;
     6198            Rect.Bottom := Height + 1;
    60976199            dec(Rect.Right);
    60986200            FocRect := Rect;
    60996201            TxtHeight := DrawText(Handle, PChar(Caption), Length(Caption), FocRect,
    6100                                                           DrawOptions or DT_CALCRECT);
     6202              DrawOptions or DT_CALCRECT);
    61016203            FSingleLine := (TxtHeight = TextHeight(Caption));
    61026204            Rect.Bottom := Rect.Top + TxtHeight + 1;
     
    61106212            l := length(Caption);
    61116213            AWidth := TextWidth('&');
    6112             while(i < l) do
     6214            while (i < l) do
    61136215            begin
    61146216              inc(i);
    61156217              // '&&' is an escape char that should display one '&' wide.
    61166218              // This next part preserves the first '&' but drops all the others
    6117               if (Copy(Caption,i,2)<>'&&') and (Copy(Caption,i,1)='&') then
    6118                 dec(TxtWidth,AWidth);
     6219              if (Copy(Caption, i, 2) <> '&&') and (Copy(Caption, i, 1) = '&') then
     6220                dec(TxtWidth, AWidth);
    61196221            end;
    61206222            Rect.Right := Rect.Left + TxtWidth;
    61216223            TxtHeight := TextHeight(Caption);
    6122             if(TxtHeight < Bitmap.Height) then
     6224            if (TxtHeight < Bitmap.Height) then
    61236225              TxtHeight := Bitmap.Height;
    61246226            Rect.Top := ((((ClientHeight - TxtHeight) * 5) - 5) div 10);
     
    61436245
    61446246begin
    6145   if(not (csDestroying in ComponentState)) then
     6247  if (not (csDestroying in ComponentState)) then
    61466248  begin
    61476249    GetDrawData(DrawItemStruct.hDC, Bitmap, FocusRect, R, DrawOptions, TempBitMap);
     
    61606262          Font := Self.Font;
    61616263
    6162           if(Enabled or (csDesigning in ComponentState)) then
     6264          if (Enabled or (csDesigning in ComponentState)) then
    61636265          begin
    61646266            DrawText(Handle, PChar(Caption), Length(Caption), FocusRect, DrawOptions);
     
    61666268          else
    61676269          begin
    6168             OldColor:=Font.Color;
     6270            OldColor := Font.Color;
    61696271            try
    61706272              if Ctl3D then
     
    61756277                OffsetRect(FocusRect, -1, -1);
    61766278              end;
    6177               Font.Color:=clGrayText;
     6279              Font.Color := clGrayText;
    61786280              DrawText(Handle, PChar(Caption), Length(Caption), FocusRect, DrawOptions);
    61796281            finally
    6180               Font.Color:=OldColor;
     6282              Font.Color := OldColor;
    61816283            end;
    61826284
     
    61856287          end;
    61866288
    6187           if((DrawItemStruct.itemState and ODS_FOCUS) <> 0) then
     6289          if ((DrawItemStruct.itemState and ODS_FOCUS) <> 0) then
    61886290          begin
    61896291            InflateRect(FocusRect, 1, 1);
    6190             if(FFocusOnBox) then
     6292            if (FFocusOnBox) then
    61916293              //TempRect := Rect(0, 0, CheckWidth - 1, CheckWidth - 1)
    61926294              TempRect := Rect(0, 0, CheckWidth + 2, CheckWidth + 5)
     
    62056307          else
    62066308            R.Left := 0;
    6207           if(FWordWrap) then
    6208             R.Top:= FocusRect.Top
     6309          if (FWordWrap) then
     6310            R.Top := FocusRect.Top
    62096311          else
    62106312          begin
    6211             R.Top:= ((ClientHeight - Bitmap.Height + 1) div 2) - 1;
    6212             if R.Top < 0 then R.Top := 0           
     6313            R.Top := ((ClientHeight - Bitmap.Height + 1) div 2) - 1;
     6314            if R.Top < 0 then R.Top := 0
    62136315          end;
    62146316          Draw(R.Left, R.Top, Bitmap);
     
    62186320      end;
    62196321    finally
    6220       if(TempBitMap) then
     6322      if (TempBitMap) then
    62216323        Bitmap.Free;
    62226324    end;
     
    62266328procedure TORCheckBox.SetGrayedStyle(Value: TGrayedStyle);
    62276329begin
    6228   if(FGrayedStyle <> Value) then
     6330  if (FGrayedStyle <> Value) then
    62296331  begin
    62306332    FGrayedStyle := Value;
    6231     if(State = cbGrayed) then Invalidate;
     6333    if (State = cbGrayed) then Invalidate;
    62326334  end;
    62336335end;
     
    62416343begin
    62426344  inherited;
    6243   if(FSizable) and (csDesigning in ComponentState) then
     6345  if (FSizable) and (csDesigning in ComponentState) then
    62446346    AutoAdjustSize;
    62456347end;
     
    62546356  Message.Result := 0;
    62556357
    6256   if(assigned(Parent) and (FGroupIndex <> 0)) then
     6358  if (assigned(Parent) and (FGroupIndex <> 0)) then
    62576359  begin
    62586360    Chk := Checked;
    6259     if(Chk or (not FAllowAllUnchecked)) then
     6361    if (Chk or (not FAllowAllUnchecked)) then
    62606362    begin
    62616363      cnt := 0;
    6262       for i := 0 to Parent.ControlCount-1 do
     6364      for i := 0 to Parent.ControlCount - 1 do
    62636365      begin
    6264         if(Parent.Controls[i] is TORCheckBox) then
     6366        if (Parent.Controls[i] is TORCheckBox) then
    62656367        begin
    62666368          cb := TORCheckBox(Parent.Controls[i]);
    6267           if(cb <> Self) then
     6369          if (cb <> Self) then
    62686370          begin
    6269             if(cb.Checked and (cb.FGroupIndex = FGroupIndex)) then
     6371            if (cb.Checked and (cb.FGroupIndex = FGroupIndex)) then
    62706372            begin
    62716373              if Chk then
     
    62776379        end;
    62786380      end;
    6279       if(not Chk) and (Cnt = 0) then
     6381      if (not Chk) and (Cnt = 0) then
    62806382        Checked := TRUE;
    62816383    end;
     
    62876389procedure TORCheckBox.SetWordWrap(const Value: boolean);
    62886390begin
    6289   if(FWordWrap <> Value) then
     6391  if (FWordWrap <> Value) then
    62906392  begin
    62916393    FWordWrap := Value;
     
    62976399procedure TORCheckBox.SetAutoSize(Value: boolean);
    62986400begin
    6299   if(FAutoSize <> Value) then
     6401  if (FAutoSize <> Value) then
    63006402  begin
    63016403    FAutoSize := Value;
     
    63246426
    63256427begin
    6326   if(FAutoSize and (([csDestroying, csLoading] * ComponentState) = [])) then
     6428  if (FAutoSize and (([csDestroying, csLoading] * ComponentState) = [])) then
    63276429  begin
    63286430    FSizable := TRUE;
     
    63386440      ReleaseDC(0, DC);
    63396441    end;
    6340     if(FocusRect.Left   <> R.Left  ) or
    6341       (FocusRect.Right  <> R.Right ) or
    6342       (FocusRect.Top    <> R.Top   ) or
     6442    if (FocusRect.Left <> R.Left) or
     6443      (FocusRect.Right <> R.Right) or
     6444      (FocusRect.Top <> R.Top) or
    63436445      (FocusRect.Bottom <> R.Bottom) or
    63446446      (R.Right <> ClientRect.Right) or
     
    63486450      if Alignment = taLeftJustify then
    63496451      begin
    6350         dec(R.Left,2);
    6351         inc(R.Right,Bitmap.Width + 3);
     6452        dec(R.Left, 2);
     6453        inc(R.Right, Bitmap.Width + 3);
    63526454      end
    63536455      else
    6354         dec(R.Left,Bitmap.Width + 5);
    6355       Width := R.Right-R.Left+1;
    6356       Height :=  R.Bottom-R.Top+2;
     6456        dec(R.Left, Bitmap.Width + 5);
     6457      Width := R.Right - R.Left + 1;
     6458      Height := R.Bottom - R.Top + 2;
    63576459    end;
    63586460  end;
     
    63666468procedure TORCheckBox.SetCaption(const Value: TCaption);
    63676469begin
    6368   if(inherited Caption <> Value) then
     6470  if (inherited Caption <> Value) then
    63696471  begin
    63706472    inherited Caption := Value;
     
    63836485begin
    63846486  FGroupIndex := Value;
    6385   if(Value <> 0) and (csDesigning in ComponentState) and (not (csLoading in ComponentState)) then
     6487  if (Value <> 0) and (csDesigning in ComponentState) and (not (csLoading in ComponentState)) then
    63866488    SetRadioStyle(TRUE);
    63876489  SyncAllowAllUnchecked;
     
    63946496
    63956497begin
    6396   if(assigned(Parent) and (FGroupIndex <> 0)) then
    6397   begin
    6398     for i := 0 to Parent.ControlCount-1 do
    6399     begin
    6400       if(Parent.Controls[i] is TORCheckBox) then
     6498  if (assigned(Parent) and (FGroupIndex <> 0)) then
     6499  begin
     6500    for i := 0 to Parent.ControlCount - 1 do
     6501    begin
     6502      if (Parent.Controls[i] is TORCheckBox) then
    64016503      begin
    64026504        cb := TORCheckBox(Parent.Controls[i]);
    6403         if((cb <> Self) and (cb.FGroupIndex = FGroupIndex)) then
     6505        if ((cb <> Self) and (cb.FGroupIndex = FGroupIndex)) then
    64046506          cb.FAllowAllUnchecked := FAllowAllUnchecked;
    64056507      end;
     
    64226524procedure TORCheckBox.SetAssociate(const Value: TControl);
    64236525begin
    6424   if(FAssociate <> Value) then
    6425   begin
    6426     if(assigned(FAssociate)) then
     6526  if (FAssociate <> Value) then
     6527  begin
     6528    if (assigned(FAssociate)) then
    64276529      FAssociate.RemoveFreeNotification(Self);
    64286530    FAssociate := Value;
    6429     if(assigned(FAssociate)) then
     6531    if (assigned(FAssociate)) then
    64306532    begin
    64316533      FAssociate.FreeNotification(Self);
     
    64516553    // lose the disabled glyph that is stored on that button for the combo box.
    64526554
    6453     if(Ctrl is TWinControl) and (csAcceptsControls in Ctrl.ControlStyle) then
    6454     begin
    6455       for i := 0 to TWinControl(Ctrl).ControlCount-1 do
     6555    if (Ctrl is TWinControl) and (csAcceptsControls in Ctrl.ControlStyle) then
     6556    begin
     6557      for i := 0 to TWinControl(Ctrl).ControlCount - 1 do
    64566558      begin
    64576559        if DoCtrl then
     
    64666568
    64676569begin
    6468   if(assigned(FAssociate)) then
     6570  if (assigned(FAssociate)) then
    64696571    EnableCtrl(FAssociate, FALSE);
    64706572end;
     
    64746576begin
    64756577  inherited;
    6476   if(AComponent = FAssociate) and (Operation = opRemove) then
     6578  if (AComponent = FAssociate) and (Operation = opRemove) then
    64776579    FAssociate := nil;
    64786580end;
     
    65186620          if (Mask and HDI_WIDTH) <> 0 then
    65196621          begin
    6520             if(Column[Item].MinWidth > 0) and (cxy < Column[Item].MinWidth) then
     6622            if (Column[Item].MinWidth > 0) and (cxy < Column[Item].MinWidth) then
    65216623              cxy := Column[Item].MinWidth;
    6522             if(Column[Item].MaxWidth > 0) and (cxy > Column[Item].MaxWidth) then
     6624            if (Column[Item].MaxWidth > 0) and (cxy > Column[Item].MaxWidth) then
    65236625              cxy := Column[Item].MaxWidth;
    65246626            Column[Item].Width := cxy;
     
    65386640  with Message, TLVColumn(pointer(LParam)^) do
    65396641  begin
    6540     if(cx < Column[WParam].MinWidth) then
     6642    if (cx < Column[WParam].MinWidth) then
    65416643    begin
    65426644      NewW := Column[WParam].MinWidth;
     
    65446646      idx := WParam;
    65456647    end;
    6546     if(cx > Column[WParam].MaxWidth) then
     6648    if (cx > Column[WParam].MaxWidth) then
    65476649    begin
    65486650      NewW := Column[WParam].MaxWidth;
     
    65526654  end;
    65536655  inherited;
    6554   if(Changed) then
     6656  if (Changed) then
    65556657    Column[idx].Width := NewW;
    65566658end;
     
    65676669  with Message do
    65686670  begin
    6569     if(LParam < Column[WParam].MinWidth) then
     6671    if (LParam < Column[WParam].MinWidth) then
    65706672    begin
    65716673      LParam := Column[WParam].MinWidth;
     
    65746676      idx := WParam;
    65756677    end;
    6576     if(LParam > Column[WParam].MaxWidth) then
     6678    if (LParam > Column[WParam].MaxWidth) then
    65776679    begin
    65786680      LParam := Column[WParam].MaxWidth;
     
    65836685  end;
    65846686  inherited;
    6585   if(Changed) then
     6687  if (Changed) then
    65866688    Column[idx].Width := NewW;
    65876689end;
     
    65916693destructor TORComboPanelEdit.Destroy;
    65926694begin
    6593   if(assigned(FCanvas)) then
     6695  if (assigned(FCanvas)) then
    65946696    FCanvas.Free;
    65956697  inherited;
     
    66036705begin
    66046706  inherited;
    6605   if(FFocused) then
    6606   begin
    6607     if(not assigned(FCanvas)) then
     6707  if (FFocused) then
     6708  begin
     6709    if (not assigned(FCanvas)) then
    66086710      FCanvas := TControlCanvas.Create;
    66096711    DC := GetWindowDC(Handle);
     
    66206722
    66216723{ TKeyClickPanel ----------------------------------------------------------------------------- }
     6724
    66226725procedure TKeyClickPanel.KeyDown(var Key: Word; Shift: TShiftState);
    66236726begin
     
    66926795procedure TCaptionListBox.MoveFocusDown;
    66936796begin
    6694   if ItemIndex < (Items.Count-1) then
     6797  if ItemIndex < (Items.Count - 1) then
    66956798    Perform(LB_SETCARETINDEX, ItemIndex + 1, 0);
    66966799end;
     
    67286831      VK_LEFT, VK_UP: MoveFocusUp;
    67296832      VK_RIGHT, VK_DOWN: MoveFocusDown;
    6730       else inherited;
     6833    else inherited;
    67316834    end
    67326835  else inherited;
     
    67356838procedure TCaptionListBox.WMMouseMove(var Message: TWMMouseMove);
    67366839var
    6737   i : integer;
     6840  i: integer;
    67386841begin
    67396842  inherited;
     
    67606863begin
    67616864  if FRightClickSelect then with Message do
    6762   begin
    6763     APoint := Point(XPos, YPos);
     6865    begin
     6866      APoint := Point(XPos, YPos);
    67646867    // if the mouse was clicked in the client area set ItemIndex...
    6765     if PtInRect(ClientRect, APoint) then
    6766     begin
    6767       ItemIndex := ItemAtPos(APoint,True);
     6868      if PtInRect(ClientRect, APoint) then
     6869      begin
     6870        ItemIndex := ItemAtPos(APoint, True);
    67686871      // ...but not if its just going to deselect the current item
    6769       if ItemIndex > -1 then
    6770       begin
    6771         Items.BeginUpdate;
    6772         try
    6773           if not Selected[ItemIndex] then
    6774             for i := 0 to Items.Count-1 do
    6775               Selected[i] := False;
    6776           Selected[ItemIndex] := True;
    6777         finally
    6778           Items.EndUpdate;
     6872        if ItemIndex > -1 then
     6873        begin
     6874          Items.BeginUpdate;
     6875          try
     6876            if not Selected[ItemIndex] then
     6877              for i := 0 to Items.Count - 1 do
     6878                Selected[i] := False;
     6879            Selected[ItemIndex] := True;
     6880          finally
     6881            Items.EndUpdate;
     6882          end;
    67796883        end;
    67806884      end;
    67816885    end;
    6782   end;
    67836886  inherited;
    67846887end;
     
    69167019function TCaptionTreeView.GetCaption: string;
    69177020begin
    6918     result := inherited Caption;
     7021  result := inherited Caption;
    69197022end;
    69207023
     
    70087111begin
    70097112  result := (ColCount - FixedCols) * (Row - FixedRows) +
    7010       (Col - FixedCols) + 1;
     7113    (Col - FixedCols) + 1;
    70117114end;
    70127115
     
    70227125  Row: integer);
    70237126begin
    7024   Row := (index-1) div (ColCount - FixedCols) + FixedRows;
    7025   Col := (index-1) mod (ColCount - FixedCols) + FixedCols;
     7127  Row := (index - 1) div (ColCount - FixedCols) + FixedRows;
     7128  Col := (index - 1) mod (ColCount - FixedCols) + FixedCols;
    70267129end;
    70277130
     
    70337136    (Key = VK_TAB) and (Shift <= [ssShift]) then
    70347137    GoodNotifyWinEvent(EVENT_OBJECT_FOCUS, Handle, integer(OBJID_CLIENT),
    7035       ColRowToIndex(Col,Row));
     7138      ColRowToIndex(Col, Row));
    70367139end;
    70377140
     
    70437146end;
    70447147
    7045 function IsAMouseButtonDown : boolean;
     7148function IsAMouseButtonDown: boolean;
    70467149begin
    70477150  if Boolean(Hi(GetKeyState(VK_MBUTTON))) or
    7048      Boolean(Hi(GetKeyState(VK_LBUTTON))) or
    7049      Boolean(Hi(GetKeyState(VK_RBUTTON))) then
     7151    Boolean(Hi(GetKeyState(VK_LBUTTON))) or
     7152    Boolean(Hi(GetKeyState(VK_RBUTTON))) then
    70507153    Result := true
    70517154  else
     
    70687171end;
    70697172
    7070 function TORListBox.VerifyUnique(SelectIndex: Integer; iText: String): integer;
    7071 var
    7072   i : integer;
    7073   counter : integer;
     7173function TORListBox.VerifyUnique(SelectIndex: Integer; iText: string): integer;
     7174var
     7175  i: integer;
     7176  counter: integer;
    70747177begin
    70757178  Result := SelectIndex;
    7076     if LongList then
    7077     begin
     7179  if LongList then
     7180  begin
    70787181      //Implemented for CQ: 10092, PSI-04-057
    70797182      //asume long lists are alphabetically ordered...
    7080       if CompareText(iText, Copy(DisplayText[SelectIndex+1], 1, Length(iText))) = 0 then
    7081         Result := -1;
    7082     end
    7083     else //Not a LongList
    7084     begin
    7085       counter := 0;
    7086       for i := 0 to Items.Count-1 do
    7087         if CompareText(iText, Copy(DisplayText[i], 1, Length(iText))) = 0 then
    7088           Inc(counter);
    7089       if counter > 1 then
    7090         Result := -1;
    7091     end;
     7183    if CompareText(iText, Copy(DisplayText[SelectIndex + 1], 1, Length(iText))) = 0 then
     7184      Result := -1;
     7185  end
     7186  else //Not a LongList
     7187  begin
     7188    counter := 0;
     7189    for i := 0 to Items.Count - 1 do
     7190      if CompareText(iText, Copy(DisplayText[i], 1, Length(iText))) = 0 then
     7191        Inc(counter);
     7192    if counter > 1 then
     7193      Result := -1;
     7194  end;
    70927195  FFocusIndex := Result;
    7093   ItemIndex := Result; 
     7196  ItemIndex := Result;
    70947197end;
    70957198
    70967199//This procedure sets the Text property equal to the TextToMatch parameter, then calls
    70977200//FwdChangeDelayed which will perform an auto-completion on the text.
    7098 procedure TORComboBox.SetTextAutoComplete(TextToMatch: String);
     7201
     7202procedure TORComboBox.SetTextAutoComplete(TextToMatch: string);
    70997203begin
    71007204  Text := TextToMatch;
     
    71217225  //uItemTip := TItemTip.Create(Application);  // all listboxes share a single ItemTip window
    71227226  uItemTipCount := 0;
    7123   uNewStyle := Lo(GetVersion) >= 4;          // True = Win95 interface, otherwise old interface
     7227  uNewStyle := Lo(GetVersion) >= 4; // True = Win95 interface, otherwise old interface
    71247228  FillChar(ORCBImages, SizeOf(ORCBImages), 0);
    71257229
     
    71297233
    71307234end.
     7235
  • cprs/branches/HealthSevak-CPRS/CPRS-Lib/ORDateLib2006.dpk

    r829 r1693  
    3434  tee,
    3535  ORCtrlLib2006,
    36   XWB_R10;
     36  XWB_R2007;
    3737
    3838contains
  • cprs/branches/HealthSevak-CPRS/CPRS-Lib/ORDateLib2006.drc

    r829 r1693  
    1 /* VER180
    2   Generated by the Borland Delphi Pascal Compiler
     1/* VER185
     2  Generated by the CodeGear Delphi Pascal Compiler
    33  because -GD or --drc was supplied to the compiler.
    44
     
    1313END
    1414
     15/* OR2006Compatibility.dfm */
     16/* ORDtTm.DFM */
     17/* ORDtTm.RES */
     18/* ORDtTmRng.DFM */
     19/* E:\Vista_30_28\OR_SRC_CREATION\CPRS-Lib\ORDateLib2006.res */
     20/* E:\Vista_30_28\OR_SRC_CREATION\CPRS-Lib\ORDtTm.dcr */
     21/* E:\Vista_30_28\OR_SRC_CREATION\CPRS-Lib\ORDtTmRng.dcr */
     22/* E:\Vista_30_28\OR_SRC_CREATION\CPRS-Lib\ORDateLib2006.drf */
  • cprs/branches/HealthSevak-CPRS/CPRS-Lib/ORDtTm.pas

    r829 r1693  
    9999    FCaption: TStaticText;
    100100    FBlackColorMode: boolean;
     101    FOnDateDialogClosed : TNotifyEvent;
    101102    procedure ButtonClick(Sender: TObject);
    102103    function GetFMDateTime: TFMDateTime;
     
    115116    procedure KeyDown(var Key: Word; Shift: TShiftState); override;
    116117    property DateButton: TORDateButton read FButton;
     118    procedure SetEnabled(Value: Boolean); override; //wat v28  when disabling TORDateBox, button still appears active, this addresses that
    117119  public
    118120    constructor Create(AOwner: TComponent); override;
     
    130132    property RequireTime: Boolean     read FRequireTime write SetRequireTime;
    131133    property Caption: string read GetCaption write SetCaption;
     134    property OnDateDialogClosed: TNotifyEvent read FOnDateDialogClosed write FOnDateDialogClosed;
    132135  end;
    133136
     
    646649  end;
    647650  DateDialog.Free;
     651  if Assigned(OnDateDialogClosed) then OnDateDialogClosed(Self);
    648652  if Visible and Enabled then //Some events may hide the component
    649653    SetFocus;
     
    740744  if Length(Text) > 0 then
    741745  begin
     746   {
     747!!!!!! THIS HAS BEEN REMOVED AS IT CAUSED PROBLEMS WITH REMINDER DIALOGS - VHAISPBELLC !!!!!!
     748    //We need to make sure that there is a date entered before parse
     749    if FRequireTime and ((Pos('@', Text) = 0) or (Length(Piece(Text, '@', 1)) = 0)) then
     750     ErrMsg := 'Date Required';
     751    }
    742752    FFMDateTime := ServerParseFMDate(Text);
    743753    if FFMDateTime <= 0 then Errmsg := 'Invalid Date/Time';
     
    777787    end;
    778788    FCaption.Caption := Value;
     789end;
     790
     791procedure TORDateBox.SetEnabled(Value: Boolean);
     792begin
     793  FButton.Enabled := Value;
     794  inherited;
    779795end;
    780796
  • cprs/branches/HealthSevak-CPRS/CPRS-Lib/ORFn.pas

    r829 r1693  
    3636function LowerOf(i, j: Integer): Integer;
    3737function StrToFloatDef(const S: string; ADefault: Extended): Extended;
     38function RectContains(Rect: TRect; Point: TPoint): boolean;
    3839
    3940{ String functions }
     
    4142function ContainsAlpha(const x: string): Boolean;
    4243function ContainsVisibleChar(const x: string): Boolean;
     44function ContainsUpCarretChar(const x: string): Boolean;
    4345function ConvertSpecialStrings(const x: string): String;
    4446function CRCForFile(AFileName: string): DWORD;
     
    118120
    119121{ Misc functions }
     122function CPRSInstances: integer;
    120123{ You MUST pass an address to an object variable to get KillObj to work }
    121124procedure KillObj(ptr: Pointer; KillObjects: boolean = FALSE);
     
    124127procedure CallWhenIdle(CallProc: TORIdleCallProc; Msg: String);
    125128procedure CallWhenIdleNotifyWhenDone(CallProc, DoneProc: TORIdleCallProc; Msg: String);
     129
    126130procedure menuHideAllBut(aMenuItem: tMenuItem; butItems: array of tMenuItem);
    127131function TabIsPressed : Boolean;
    128132function ShiftTabIsPressed : Boolean;
    129133function EnterIsPressed : Boolean;
     134procedure ScrollControl(Window: TScrollingWinControl; ScrollingUp: boolean; Amount: integer = 40);
    130135
    131136implementation  // ---------------------------------------------------------------------------
     
    387392end;
    388393
     394function RectContains(Rect: TRect; Point: TPoint): boolean;
     395begin
     396  Result := ((Point.X >= Rect.Left) and
     397             (Point.X <= Rect.Right) and
     398             (Point.Y >= Rect.Top) and
     399             (Point.Y <= Rect.Bottom));
     400end;
     401
    389402{ String functions }
    390403
     
    415428  Result := False;
    416429  for i := 1 to Length(x) do if x[i] in ['!'..'~'] then  // ordinal values 33..126
     430  begin
     431    Result := True;
     432    break;
     433  end;
     434end;   
     435
     436function ContainsUpCarretChar(const x: string): Boolean;
     437{ returns true if the string contains the ^ character }
     438var
     439  i: Integer;
     440begin
     441  Result := False;
     442  for i := 1 to Length(x) do if x[i] = '^' then  // ordinal values 33..126
    417443  begin
    418444    Result := True;
     
    20222048*)
    20232049
     2050function CPRSInstances: integer;
     2051// returns the number of CPRS sessions open
     2052var
     2053  AHandle: hWnd;
     2054  LengthText, LengthConst, counter: Integer;
     2055  CharText: array [0..254] of Char;
     2056  TitleText, TitleCompare: string;
     2057const
     2058  TX_IN_USE = 'VistA CPRS in use by: '; // use same as in fFrame
     2059begin
     2060  counter := 0;
     2061  LengthConst := length(TX_IN_USE);
     2062  AHandle := FindWindow(nil, nil);
     2063  while AHandle <> 0 do begin
     2064    LengthText := GetWindowText(AHandle, CharText, 255);
     2065    if LengthText > 0 then
     2066    begin
     2067      TitleText := CharText;
     2068      TitleCompare := copy(TitleText, 1, LengthConst);
     2069      if TitleCompare = TX_IN_USE then
     2070        counter := counter + 1;
     2071    end;
     2072    AHandle := GetWindow(AHandle, GW_HWNDNEXT);
     2073  end;
     2074  Result := counter;
     2075end;
     2076
    20242077{ You MUST pass an address to an object variable to get KillObj to work }
    20252078procedure KillObj(ptr: Pointer; KillObjects: boolean = FALSE);
     
    21972250end;
    21982251
     2252procedure ScrollControl(Window: TScrollingWinControl; ScrollingUp: boolean; Amount: integer = 40);
     2253var
     2254  Delta: integer;
     2255
     2256  // This is needed to tell the child components that they are moving,
     2257  // The TORCombo box, for example, needs to close a dropped down window when it moves.
     2258  // If Delphi had used standard scroll bars, instead of the customized flat ones, this
     2259  // code wouldn't be needed
     2260  procedure SendMoveMessage(Ctrl: TWinControl);
     2261  var
     2262    i: integer;
     2263  begin
     2264    for i := 0 to Ctrl.ControlCount - 1 do
     2265    begin
     2266      if Ctrl.Controls[i] is TWinControl then with TWinControl(Ctrl.Controls[i]) do
     2267      begin
     2268        SendMessage(Handle, WM_MOVE, 0, (Top * 65536) + Left);
     2269        SendMoveMessage(TWinControl(Ctrl.Controls[i]));
     2270      end;
     2271    end;
     2272  end;
     2273 
     2274begin
     2275  Delta := Amount;
     2276  if ScrollingUp then
     2277  begin
     2278    if Window.VertScrollBar.Position < Delta then
     2279      Delta := Window.VertScrollBar.Position;
     2280    Delta := - Delta;
     2281  end
     2282  else
     2283  begin
     2284    if (Window.VertScrollBar.Range - Window.VertScrollBar.Position) < Delta then
     2285      Delta := Window.VertScrollBar.Range - Window.VertScrollBar.Position;
     2286  end;
     2287  if Delta <> 0 then
     2288  begin
     2289    Window.VertScrollBar.Position := Window.VertScrollBar.Position + Delta;
     2290    SendMoveMessage(Window);
     2291  end;
     2292end;
     2293
    21992294initialization
    22002295  FBaseFont := TFont.Create;
  • cprs/branches/HealthSevak-CPRS/CPRS-Lib/ORNet.pas

    r829 r1693  
    11unit ORNet;
    22
    3 {$DEFINE CCOWBROKER}
     3//{$DEFINE CCOWBROKER}
    44
    55interface
    66
    7 uses SysUtils, Windows, Classes, Forms, Controls, ORFn, TRPCB, RPCConf1, Dialogs   
    8 {$IFDEF CCOWBROKER}, CCOWRPCBroker {$ENDIF} ;  //, SharedRPCBroker;
     7uses SysUtils, Windows, Classes, Forms, Controls, ORFn, TRPCB, RPCConf1, Dialogs
     8      ;  //, SharedRPCBroker;
    99
    1010
     
    2626function DottedIPStr: string;
    2727procedure CallRPCWhenIdle(CallProc: TORIdleCallProc; Msg: String);
     28function ShowRPCList: Boolean;
    2829
    2930procedure EnsureBroker;
     
    3637
    3738var
    38 {$IFDEF CCOWBROKER}
    39   RPCBrokerV: TCCOWRPCBroker;
    40 {$ELSE}
    4139  RPCBrokerV: TRPCBroker;
    42   //RPCBrokerV: TSharedRPCBroker;
    43 {$ENDIF}
    4440  RPCLastCall: string;
    4541
     
    6965  if RPCBrokerV = nil then
    7066  begin
    71 {$IFDEF CCOWBROKER}
    72     RPCBrokerV := TCCOWRPCBroker.Create(Application);
    73 {$ELSE}
    7467    RPCBrokerV := TRPCBroker.Create(Application);
    75     //RPCBrokerV := TSharedRPCBroker.Create(Application);
    76 {$ENDIF}
    7768    with RPCBrokerV do
    7869    begin
     
    512503end;
    513504
     505function ShowRPCList: Boolean;
     506begin
     507  if uShowRPCS then Result := True
     508  else Result := False;
     509end;
     510
     511
    514512initialization
    515513  RPCBrokerV := nil;
    516514  RPCLastCall := 'No RPCs called';
    517515  uCallList := TList.Create;
    518   uMaxCalls := 10;
     516  uMaxCalls := 100;
    519517  uShowRPCs := False;
    520518
  • cprs/branches/HealthSevak-CPRS/CPRS-Lib/VA10.drc

    r456 r1693  
    1 /* VER140
    2   Generated by the Borland Delphi Pascal Compiler
     1/* VER185
     2  Generated by the CodeGear Delphi Pascal Compiler
    33  because -GD or --drc was supplied to the compiler.
    44
     
    1313END
    1414
     15/* E:\Vista_30_28\OR_SRC_CREATION\CPRS-Lib\VA10.res */
     16/* E:\Vista_30_28\OR_SRC_CREATION\CPRS-Lib\VA10.drf */
Note: See TracChangeset for help on using the changeset viewer.