Changeset 1693 for cprs/branches/HealthSevak-CPRS/CPRS-Lib/ORCtrls.pas
- Timestamp:
- May 8, 2015, 7:52:55 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cprs/branches/HealthSevak-CPRS/CPRS-Lib/ORCtrls.pas
r829 r1693 1 unit ORCtrls; 1 unit ORCtrls; // Oct 26, 1997 @ 10:00am 2 2 3 3 // To Do: eliminate topindex itemtip on mousedown (seen when choosing clinic pts) 4 4 5 interface 5 interface // -------------------------------------------------------------------------------- 6 6 7 7 uses Windows, Messages, SysUtils, Classes, Graphics, Controls, StdCtrls, Forms, 8 9 Variants, VAClasses;8 ComCtrls, Commctrl, Buttons, ExtCtrls, Grids, ImgList, Menus, CheckLst, 9 Variants, VAClasses, typinfo; 10 10 11 11 const 12 UM_SHOWTIP = (WM_USER + 9436);// message id to display item tip **was 30013 UM_GOTFOCUS = (WM_USER + 9437); 14 MAX_TABS = 40; 15 LL_REVERSE = -1;// long list scrolling in reverse direction16 LL_POSITION = 0;// long list thumb moved17 LL_FORWARD = 1;// long list scrolling in forward direction18 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 = '^----------------------------------------------------------------------------'; 20 20 LLS_SPACE = '^ '; 21 21 22 22 type 23 23 IORBlackColorModeCompatible = interface(IInterface) 24 ['{3554985C-F524-45FA-8C27-4CDD8357DB08}']24 ['{3554985C-F524-45FA-8C27-4CDD8357DB08}'] 25 25 procedure SetBlackColorMode(Value: boolean); 26 26 end; 27 27 28 TORComboBox = class; 29 30 TTranslator = function 28 TORComboBox = class; // forward declaration for FParentCombo 29 30 TTranslator = function(MString: string): string of object; 31 31 32 32 TORStrings = class(TStrings) … … 38 38 procedure Verify; 39 39 protected 40 function Get( index:integer): string; override;40 function Get(index: integer): string; override; 41 41 function GetCount: integer; override; 42 function GetObject(index: integer): TObject; override;42 function GetObject(index: integer): TObject; override; 43 43 procedure Put(Index: Integer; const S: string); override; 44 procedure PutObject(index: integer; Value: TObject); override;45 procedure SetUpdateState( 44 procedure PutObject(index: integer; Value: TObject); override; 45 procedure SetUpdateState(Value: boolean); override; 46 46 public 47 47 function Add(const S: string): integer; override; … … 49 49 destructor Destroy; override; 50 50 procedure Clear; override; 51 procedure Delete( 51 procedure Delete(index: integer); override; 52 52 procedure Insert(Index: Integer; const S: string); override; 53 53 function IndexOf(const S: string): Integer; override; … … 57 57 end; 58 58 59 TORDirection = -1..1; 60 TORNeedDataEvent 61 62 TORBeforeDrawEvent 63 64 TORItemNotifyEvent 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; 65 65 TORCheckComboTextEvent = procedure(Sender: TObject; NumChecked: integer; var Text: string) of object; 66 TORSynonymCheckEvent 67 66 TORSynonymCheckEvent = procedure(Sender: TObject; const Text: string; 67 var IsSynonym: boolean) of object; 68 68 69 69 PItemRec = ^TItemRec; 70 70 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; 74 79 end; 75 80 76 81 TORListBox = class(TListBox, IVADynamicProperty, IORBlackColorModeCompatible) 77 82 private 78 FFocusIndex: Integer; 79 FLargeChange: Integer; 80 FTipItem: Integer; 81 FItemTipActive: Boolean; 82 FItemTipColor: TColor; 83 FItemTipEnable: Boolean; 84 FLastMouseX: Integer; 85 FLastMouseY: Integer; 86 FLastItemIndex: Integer; 87 FFromSelf: Boolean; 88 FDelimiter: Char; 89 FWhiteSpace: Char; 90 FTabPosInPixels: boolean; 91 FTabPos: array[0..MAX_TABS] of Integer; 92 FTabPix: array[0..MAX_TABS] of Integer; 93 FPieces: array[0..MAX_TABS] of Integer; 94 FLongList: Boolean; 95 FScrollBar: TScrollBar; 96 FFirstLoad: Boolean; 97 FFromNeedData: Boolean; 98 FDataAdded: Boolean; 99 FCurrentTop: Integer; 100 FWaterMark: Integer; 101 FDirection: Integer; 102 FInsertAt: Integer; 103 FParentCombo: TORComboBox; 104 FOnChange: TNotifyEvent; 105 FOnNeedData: TORNeedDataEvent; 106 FHideSynonyms: boolean; 107 FSynonymChars: string; 108 FOnSynonymCheck: TORSynonymCheckEvent; 109 FCreatingItem: boolean; 110 FCreatingText: string; 111 FOnBeforeDraw: TORBeforeDrawEvent; 112 FRightClickSelect: boolean; 113 FCheckBoxes: boolean; 114 FFlatCheckBoxes: boolean; 115 FCheckEntireLine: boolean; 116 FOnClickCheck: TORItemNotifyEvent; 117 FDontClose: boolean; 118 FItemsDestroyed: boolean; 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 119 124 FAllowGrayed: boolean; 120 FMItems: TORStrings; 121 FCaption: TStaticText; 122 FCaseChanged: boolean; 123 FLookupPiece: integer; 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 124 129 FIsPartOfComboBox: boolean; 125 130 FBlackColorMode: boolean; … … 156 161 function IsSynonym(const TestStr: string): boolean; 157 162 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; 174 179 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; 181 186 function GetChecked(Index: Integer): Boolean; 182 187 procedure SetChecked(Index: Integer; const Value: Boolean); … … 187 192 procedure SetCheckedState(Index: Integer; const Value: TCheckBoxState); 188 193 function GetMItems: TStrings; 189 procedure SetMItems( 194 procedure SetMItems(Value: TStrings); 190 195 procedure SetCaption(const Value: string); 191 196 function GetCaption: string; … … 207 212 procedure MeasureItem(Index: Integer; var Height: Integer); override; 208 213 procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState); override; 209 function GetIndexFromY(YPos :integer) :integer;214 function GetIndexFromY(YPos: integer): integer; 210 215 property isPartOfComboBox: boolean read FIsPartOfComboBox write FIsPartOfComboBox default False; 211 216 property HideSynonyms: boolean read FHideSynonyms write SetHideSynonyms default FALSE; … … 236 241 property CheckedState[Index: Integer]: TCheckBoxState read GetCheckedState write SetCheckedState; 237 242 property MItems: TStrings read GetMItems write SetMItems; 238 function VerifyUnique(SelectIndex: Integer; iText: String): integer;243 function VerifyUnique(SelectIndex: Integer; iText: string): integer; 239 244 procedure SetBlackColorMode(Value: boolean); 240 245 function SupportsDynamicProperty(PropertyID: integer): boolean; 241 246 function GetDynamicProperty(PropertyID: integer): string; 247 procedure SetHintProperties(Restore: Boolean; MainForm: TComponent); 242 248 property HideSelection: boolean read FHideSelection write FHideSelection; 243 249 published … … 303 309 TORComboBox = class(TWinControl, IVADynamicProperty, IORBlackColorModeCompatible) 304 310 private 305 FItems: TStrings; 306 FMItems: TStrings; 307 FListBox: TORListBox; 308 FEditBox: TORComboEdit; 309 FEditPanel: TORComboPanelEdit; 310 FDropBtn: TBitBtn; 311 FDropPanel: TORDropPanel; 312 FDroppedDown: Boolean; 313 FStyle: TORComboStyle; 314 FDropDownCount: Integer; 315 FFromSelf: Boolean; 316 FFromDropBtn: Boolean; 317 FKeyTimerActive: Boolean; 318 FKeyIsDown: Boolean; 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 319 325 FChangePending: Boolean; 320 326 FListItemsOnly: Boolean; 321 327 FLastFound: string; 322 FLastInput: string; 323 FOnChange: TNotifyEvent; 324 FOnClick: TNotifyEvent; 325 FOnDblClick: TNotifyEvent; 326 FOnDropDown: TNotifyEvent; 327 FOnDropDownClose: TNotifyEvent; 328 FOnKeyDown: TKeyEvent; 329 FOnKeyPress: TKeyPressEvent; 330 FOnKeyUp: TKeyEvent; 331 FOnKeyPause: TNotifyEvent; 332 FOnMouseClick: TNotifyEvent; 333 FOnNeedData: TORNeedDataEvent; 334 FCheckedState: string; 335 FOnCheckedText: TORCheckComboTextEvent; 336 FCheckBoxEditColor: TColor; 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 337 343 FTemplateField: boolean; 338 FCharsNeedMatch: integer; 339 FUniqueAutoComplete: Boolean; 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. 340 346 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; 343 350 procedure DropDownStatusChanged(opened: boolean); 344 351 procedure ClearDropDownStatus; … … 413 420 procedure StartKeyTimer; 414 421 procedure StopKeyTimer; 415 procedure WMDestroy 416 procedure CMFontChanged 417 procedure WMMove (var Message: TWMMove);message WM_MOVE;418 procedure WMSize (var Message: TWMSize);message WM_SIZE;419 procedure WMTimer 420 procedure UMGotFocus 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; 421 428 function GetCheckBoxes: boolean; 422 429 function GetChecked(Index: Integer): Boolean; … … 464 471 procedure InsertSeparator; 465 472 procedure Invalidate; override; 466 procedure SetTextAutoComplete(TextToMatch : String);473 procedure SetTextAutoComplete(TextToMatch: string); 467 474 function GetIEN(AnIndex: Integer): Int64; 468 475 function SelectByIEN(AnIEN: Int64): Integer; … … 490 497 property MItems: TStrings read GetMItems; 491 498 published 499 Property RpcCall :String read fRpcCall write fRpcCall; 492 500 property Anchors; 493 501 property CaseChanged: boolean read GetCaseChanged write SetCaseChanged default TRUE; … … 548 556 property OnResize; 549 557 property OnSynonymCheck: TORSynonymCheckEvent read GetOnSynonymCheck write SetOnSynonymCheck; 550 property CharsNeedMatch: integer read FCharsNeedMatchwrite SetNumForMatch;558 property CharsNeedMatch: integer read FCharsNeedMatch write SetNumForMatch; 551 559 {UniqueAutoComplete Was added as a result of the following defects: 552 560 7293 - PTM 85: Backspace and Dosage: Desired dosage does not populate if dosage is not in local dosage field … … 560 568 private 561 569 FSizes: TList; 562 procedure BuildSizes( 563 procedure DoResize( 570 procedure BuildSizes(Control: TWinControl); 571 procedure DoResize(Control: TWinControl; var CurrentIndex: Integer); 564 572 protected 565 573 procedure Loaded; override; … … 569 577 end; 570 578 571 TOROffsetLabel = class(TGraphicControl) 579 TOROffsetLabel = class(TGraphicControl) // see TCustomLabel in the VCL 572 580 private 573 FHorzOffset: Integer; 574 FVertOffset: Integer; 575 FWordWrap: Boolean; 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 576 584 function GetTransparent: Boolean; 577 585 procedure AdjustSizeOfSelf; … … 648 656 end; 649 657 650 TORAlignEdit = class(TEdit)//Depricated -- Use TCaptionEdit instead658 TORAlignEdit = class(TEdit) //Depricated -- Use TCaptionEdit instead 651 659 published 652 660 property Align; … … 722 730 constructor Create(AOwner: TComponent); override; 723 731 function FindPieceNode(Value: string; 724 732 ParentDelim: Char = #0; StartNode: TTreeNode = nil): TORTreeNode; overload; 725 733 function FindPieceNode(Value: string; APiece: integer; 726 734 ParentDelim: Char = #0; StartNode: TTreeNode = nil): TORTreeNode; overload; 727 735 procedure RenameNodes; 728 736 function GetExpandedIDStr(APiece: integer; ParentDelim: char = #0): string; 729 737 procedure SetExpandedIDStr(APiece: integer; const Value: string); overload; 730 738 procedure SetExpandedIDStr(APiece: integer; ParentDelim: char; 731 739 const Value: string); overload; 732 740 function GetNodeID(Node: TORTreeNode; ParentDelim: Char = #0): string; overload; 733 741 function GetNodeID(Node: TORTreeNode; APiece: integer; ParentDelim: Char = #0): string; overload; … … 770 778 destructor Destroy; override; 771 779 published 772 property CheckedEnabledIndex: integer read FCheckedEnabledIndexwrite SetCheckedEnabledIndex;773 property CheckedDisabledIndex: integer read FCheckedDisabledIndexwrite SetCheckedDisabledIndex;774 property GrayedEnabledIndex: integer read FGrayedEnabledIndexwrite SetGrayedEnabledIndex;775 property GrayedDisabledIndex: integer read FGrayedDisabledIndexwrite SetGrayedDisabledIndex;776 property UncheckedEnabledIndex: integer read FUncheckedEnabledIndexwrite 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; 777 785 property UncheckedDisabledIndex: integer read FUncheckedDisabledIndex write SetUncheckedDisabledIndex; 778 786 end; … … 799 807 FBlackColorMode: boolean; 800 808 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 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; 810 818 function GetImageList: TCustomImageList; 811 819 function GetImageIndexes: string; … … 823 831 procedure SetAutoSize(Value: boolean); override; 824 832 procedure GetDrawData(CanvasHandle: HDC; var Bitmap: TBitmap; 825 826 827 833 var FocRect, Rect: TRect; 834 var DrawOptions: UINT; 835 var TempBitMap: boolean); 828 836 procedure DrawItem(const DrawItemStruct: TDrawItemStruct); dynamic; 829 837 procedure Toggle; override; … … 908 916 private 909 917 FHoverItemPos: integer; 910 FRightClickSelect: boolean; 918 FRightClickSelect: boolean; // When true, a right click selects teh item 911 919 FHintOnItem: boolean; 912 920 procedure SetCaption(const Value: string); … … 941 949 published 942 950 property Caption: string read GetCaption write SetCaption; 951 Property CheckWidth: integer Read GetCheckWidth; 943 952 end; 944 953 … … 1010 1019 procedure KeyUp(var Key: Word; Shift: TShiftState); override; 1011 1020 public 1012 procedure IndexToColRow( 1013 function ColRowToIndex( 1021 procedure IndexToColRow(index: integer; var Col: integer; var Row: integer); 1022 function ColRowToIndex(Col: integer; Row: Integer): integer; 1014 1023 function SupportsDynamicProperty(PropertyID: integer): boolean; 1015 1024 function GetDynamicProperty(PropertyID: integer): string; … … 1026 1035 procedure GoodNotifyWinEvent(event: DWORD; hwnd: HWND; idObject, idChild: Longint); stdcall; 1027 1036 1028 function CalcShortName( 1037 function CalcShortName(LongName: string; PrevLongName: string): string; 1029 1038 1030 1039 {Returns True if any one of 3 mouse buttons are down left, right, or middle} 1031 function IsAMouseButtonDown 1032 1033 implementation 1040 function IsAMouseButtonDown: boolean; 1041 1042 implementation // --------------------------------------------------------------------------- 1034 1043 1035 1044 {$R ORCTRLS} … … 1037 1046 uses 1038 1047 VAUtils; 1039 1048 1040 1049 const 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 combobox1051 CBO_CXBTN = 13;// width of drop down button in combobox1052 CBO_CXFRAME = 5;// offset to account for frame around the edit part of combobox1053 1054 NOREDRAW = 0; 1055 DOREDRAW = 1; 1056 1057 KEY_TIMER_DELAY = 500; 1058 KEY_TIMER_ID = 5800; 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 1059 1068 1060 1069 { use high word to pass positioning flags since listbox is limited to 32767 items } 1061 1070 //SFI_TOP = $80000000; // top of listbox (decimal value: -2147483648) 1062 1071 //SFI_END = $90000000; // end of listbox (decimal value: -1879048192) 1063 SFI_TOP = -2147483646; 1064 SFI_END = -1879048192; 1065 1066 CheckWidth = 15; 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 1067 1076 CheckComboBtnHeight = 21; 1068 1077 MaxNeedDataLen = 64; … … 1071 1080 TItemTip = class(TCustomControl) 1072 1081 private 1073 FShowing: Boolean; 1074 FListBox: TORListBox; 1082 FShowing: Boolean; // true when itemtip is visible 1083 FListBox: TORListBox; // current listbox displaying itemtips 1075 1084 FListItem: integer; 1076 1085 FPoint: TPoint; 1077 1086 FSelected: boolean; 1078 FTabs: array[0..MAX_TABS] of Integer; 1087 FTabs: array[0..MAX_TABS] of Integer; // Holds the pixel offsets for tabs 1079 1088 procedure GetTabSettings; 1080 1089 protected … … 1088 1097 end; 1089 1098 1090 TSizeRatio = class 1099 TSizeRatio = class // relative sizes and positions for resizing 1091 1100 CLeft: Extended; 1092 1101 CTop: Extended; … … 1097 1106 1098 1107 var 1099 uKeyHookHandle: HHOOK; 1100 uItemTip: TItemTip; 1101 uItemTipCount: Integer; 1102 uNewStyle: Boolean; 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; 1104 1113 { General functions and procedures --------------------------------------------------------- } 1105 1114 … … 1130 1139 try 1131 1140 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; 1133 1143 finally 1134 1144 SelectObject(DC, SaveFont); … … 1205 1215 if i < PieceNum 1206 1216 then x := x + StringOfChar(Delim, PieceNum - i) + NewPiece 1207 1217 else x := Copy(x, 1, Strt - PChar(x)) + NewPiece + StrPas(Next); 1208 1218 end; 1209 1219 … … 1236 1246 end; 1237 1247 ANum := StrToIntDef(Trim(APiece), 0); 1238 if (ANum > 0) or (AllowNeg and (ANum < 0)) then1248 if (ANum > 0) or (AllowNeg and (ANum < 0)) then 1239 1249 begin 1240 1250 Inc(IntArray[0]); … … 1262 1272 { TItemTip --------------------------------------------------------------------------------- } 1263 1273 1264 procedure AddItemTipRef; 1265 begin 1266 if uItemTipCount = 0 then uItemTip := TItemTip.Create(Application); 1274 procedure AddItemTipRef; // kcm 1275 begin 1276 if uItemTipCount = 0 then uItemTip := TItemTip.Create(Application); // all listboxes share a single ItemTip window 1267 1277 Inc(uItemTipCount); 1268 1278 end; 1269 1279 1270 procedure RemoveItemTipRef; 1280 procedure RemoveItemTipRef; // kcm 1271 1281 begin 1272 1282 Dec(uItemTipCount); … … 1295 1305 Params.Style := WS_POPUP or WS_DISABLED or WS_BORDER; 1296 1306 if uNewStyle then Params.ExStyle := WS_EX_TOOLWINDOW; 1297 Params.ExStyle := Params.ExStyle or WS_EX_TOPMOST; 1307 Params.ExStyle := Params.ExStyle or WS_EX_TOPMOST; // - test this!! 1298 1308 end; 1299 1309 … … 1314 1324 // WARNING - Do NOT change the X pos or the tab starting pos - this will cause a missmatch 1315 1325 // 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); 1317 1327 end; 1318 1328 end; … … 1335 1345 var 1336 1346 DX, X, i, count: integer; 1337 1347 1338 1348 begin 1339 1349 Count := FListBox.FTabPix[0]; 1340 FTabs[0] := 1; 1341 if (Count = 1) then1350 FTabs[0] := 1; // Set first tab stop to location 1 for display purposes 1351 if (Count = 1) then 1342 1352 begin 1343 1353 DX := FListBox.FTabPix[1]; … … 1353 1363 for i := 1 to MAX_TABS do 1354 1364 begin 1355 if (i <= Count) then1365 if (i <= Count) then 1356 1366 FTabs[i] := FListBox.FTabPix[i] - 1 1357 1367 else … … 1375 1385 Canvas.Brush.Color := clHighlight; 1376 1386 Canvas.Font.Color := clHighlightText; 1377 end else 1387 end else // the item is not selected 1378 1388 begin 1379 1389 Canvas.Brush.Color := FListBox.ItemTipColor; … … 1381 1391 end; 1382 1392 Caption := #9 + FListBox.DisplayText[FListItem]; 1383 if Copy(Caption, 1, 2) = '__' then Caption := ' '; 1393 if Copy(Caption, 1, 2) = '__' then Caption := ' '; // so separators don't extend past window 1384 1394 1385 1395 GetTabSettings; 1386 1396 1387 1397 AWidth := LOWORD(GetTabbedTextExtent(Canvas.Handle, PChar(Caption), Length(Caption), 1388 MAX_TABS +1, FTabs[0]));1398 MAX_TABS + 1, FTabs[0])); 1389 1399 // inherent scrollbar may not always be visible in a long list 1390 1400 if FListBox.LongList 1391 1401 then ListClientWidth := ClientWidthOfList(FListBox) 1392 1402 else ListClientWidth := FListBox.ClientWidth; 1393 1403 X := FPoint.X; 1394 if (FListBox.FCheckBoxes) then1404 if (FListBox.FCheckBoxes) then 1395 1405 begin 1396 1406 dec(ListClientWidth, CheckWidth); … … 1414 1424 if (GetCaptureControl = nil) and CatchMouse then FListBox.MouseCapture := True; 1415 1425 SetWindowPos(Handle, HWND_TOP, X, FPoint.Y, AWidth, FListBox.ItemHeight, 1416 1426 SWP_SHOWWINDOW or SWP_NOACTIVATE); 1417 1427 Invalidate; 1418 1428 end; … … 1422 1432 { sets the canvas properties and window size and text depending on the item in the listbox } 1423 1433 begin 1424 if not AListBox.Visible then Exit; 1434 if not AListBox.Visible then Exit; // added to support DropDown lists 1425 1435 FListBox := AListBox; 1426 1436 FListItem := AnItem; … … 1432 1442 type 1433 1443 TORCBImgIdx = (iiUnchecked, iiChecked, iiGrayed, iiQMark, iiBlueQMark, 1434 1435 1436 1444 iiDisUnchecked, iiDisChecked, iiDisGrayed, iiDisQMark, 1445 iiFlatUnChecked, iiFlatChecked, iiFlatGrayed, 1446 iiRadioUnchecked, iiRadioChecked, iiRadioDisUnchecked, iiRadioDisChecked); 1437 1447 1438 1448 const … … 1445 1455 'ORCB_RADIO_DISABLED_UNCHECKED', 'ORCB_RADIO_DISABLED_CHECKED'); 1446 1456 1447 1457 BlackCheckBoxImageResNames: array[TORCBImgIdx] of PChar = ( 1448 1458 'BLACK_ORLB_FLAT_UNCHECKED', 'BLACK_ORLB_FLAT_CHECKED', 'BLACK_ORLB_FLAT_GRAYED', 1449 1459 'BLACK_ORCB_QUESTIONMARK', 'BLACK_ORCB_BLUEQUESTIONMARK', … … 1453 1463 'BLACK_ORCB_RADIO_UNCHECKED', 'BLACK_ORCB_RADIO_CHECKED', 1454 1464 'BLACK_ORCB_RADIO_DISABLED_UNCHECKED', 'BLACK_ORCB_RADIO_DISABLED_CHECKED'); 1455 1465 1456 1466 var 1457 1467 ORCBImages: array[TORCBImgIdx, Boolean] of TBitMap; … … 1461 1471 ResName: string; 1462 1472 begin 1463 if (not assigned(ORCBImages[Idx, BlackMode])) then1473 if (not assigned(ORCBImages[Idx, BlackMode])) then 1464 1474 begin 1465 1475 ORCBImages[Idx, BlackMode] := TBitMap.Create; … … 1483 1493 for Mode := false to true do 1484 1494 begin 1485 if (assigned(ORCBImages[i, Mode])) then1495 if (assigned(ORCBImages[i, Mode])) then 1486 1496 ORCBImages[i, Mode].Free; 1487 1497 end; … … 1491 1501 { TORStrings } 1492 1502 1493 function TORStrings.Add(const S: string): integer; 1503 function TORStrings.Add(const S: string): integer; 1494 1504 var 1495 1505 RealVerification: Boolean; … … 1580 1590 var 1581 1591 RealVerification: Boolean; 1582 begin 1592 begin //If this method weren't overridden, the listbox would forget which item was selected. 1583 1593 MList[Index] := S; 1584 1594 RealVerification := Verification; … … 1611 1621 if Verification then begin 1612 1622 if not Assigned(FPlainText) then 1613 raise Exception.Create( 1623 raise Exception.Create('ORStrings is missing PlainText property.'); 1614 1624 if not Assigned(FTranslator) then 1615 raise Exception.Create( 1625 raise Exception.Create('ORStrings is missing Translator property.'); 1616 1626 Errors := TStringList.Create; 1617 1627 try 1618 1628 TotalCount := MList.Count; 1619 1629 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)); 1622 1632 if PlainText.Count > TotalCount then 1623 1633 TotalCount := PlainText.Count; … … 1625 1635 for i := 0 to TotalCount - 1 do begin 1626 1636 if i >= MList.Count then 1627 Errors.Add('PlainText[' +IntToStr(i)+']: '+PlainText[i])1637 Errors.Add('PlainText[' + IntToStr(i) + ']: ' + PlainText[i]) 1628 1638 else if i >= PlainText.Count then 1629 Errors.Add('ORStrings[' +IntToStr(i)+']: '+Translator(MList[i]))1639 Errors.Add('ORStrings[' + IntToStr(i) + ']: ' + Translator(MList[i])) 1630 1640 else begin 1631 1641 M := Translator(MList[i]); 1632 1642 Plain := PlainText[i]; 1633 1643 if M <> Plain then begin 1634 if UpperCase(M) = UpperCase(Plain) then 1644 if UpperCase(M) = UpperCase(Plain) then //Listboxes don't always sort cases right, so we give them a little help here. 1635 1645 begin 1636 1646 PlainText[i] := M; … … 1638 1648 else 1639 1649 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); 1642 1652 end; 1643 1653 end; … … 1645 1655 end; 1646 1656 if Errors.Count > 0 then begin 1647 Errors.Insert( 1648 raise Exception.Create( 1657 Errors.Insert(0, 'OR strings are out of sync with plain text strings :'); 1658 raise Exception.Create(Errors.Text); 1649 1659 end; 1650 1660 finally … … 1691 1701 if uItemTip <> nil then uItemTip.Hide; 1692 1702 DestroyItems; 1693 RemoveItemTipRef; 1703 RemoveItemTipRef; //kcm 1694 1704 inherited Destroy; 1695 1705 end; … … 1711 1721 FFromSelf := True; 1712 1722 RealVerification := True; 1713 if Assigned( FMItems) then1723 if Assigned(FMItems) then 1714 1724 begin 1715 1725 RealVerification := FMItems.Verification; … … 1717 1727 end; 1718 1728 inherited CreateWnd; 1719 if Assigned( FMItems) then1729 if Assigned(FMItems) then 1720 1730 begin 1721 1731 FMItems.Verification := RealVerification; … … 1763 1773 function TORListBox.IsSynonym(const TestStr: string): boolean; 1764 1774 var 1765 i, cnt,len :integer;1775 i, cnt, len: integer; 1766 1776 1767 1777 begin 1768 1778 Result := FALSE; 1769 if ((FHideSynonyms) and (FSynonymChars <> '')) then1779 if ((FHideSynonyms) and (FSynonymChars <> '')) then 1770 1780 begin 1771 1781 len := length(FSynonymChars); 1772 1782 cnt := 0; 1773 1783 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; 1776 1786 if assigned(FOnSynonymCheck) then 1777 1787 FOnSynonymCheck(Self, TestStr, Result); … … 1787 1797 Result := ''; 1788 1798 FFromSelf := True; 1789 Len := SendMessage(Handle, LB_GETTEXT, Index, Integer(@Buf));1799 Len := SendMessage(Handle, LB_GETTEXT, Index, Integer(@Buf)); 1790 1800 FFromSelf := False; 1791 1801 if Len > 0 then … … 1818 1828 inherited; 1819 1829 if not FFromSelf then with Message do 1820 begin1821 ItemRec := PItemRec(Result);1822 if(assigned(ItemRec)) then1823 Result := Integer(ItemRec^.UserObject)1824 else1825 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; 1827 1837 end; 1828 1838 … … 1833 1843 begin 1834 1844 if not FFromSelf then with Message do 1835 begin1836 FFromSelf := True;1837 ItemRec := PItemRec(SendMessage(Handle,LB_GETITEMDATA, WParam, 0));// WParam: list index1838 FFromSelf := False;1839 if(assigned(ItemRec)) then1840 ItemRec^.UserObject := TObject(LParam);1841 LParam := Integer(ItemRec);1842 if uItemTip.FShowing and (uItemTip.FListBox = Self) and (uItemTip.FListItem = WParam) then1843 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; 1845 1855 inherited; 1846 1856 end; … … 1854 1864 inherited; 1855 1865 if (not FFromSelf) and (Message.Result <> LB_ERR) then with Message do 1856 begin1857 FFromSelf := True;1858 ItemRec := PItemRec(SendMessage(Handle,LB_GETITEMDATA, WParam, 0)); // WParam: list index1859 FFromSelf := False;1860 if(assigned(ItemRec)) then1861 1866 begin 1862 1867 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 1866 1869 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; 1884 end; 1885 1875 1886 procedure TORListBox.LBGetTextLen(var Message: TMessage); 1876 1887 { intercept LB_GETTEXTLEN and return true length of ItemRec^.FullText } … … 1881 1892 inherited; 1882 1893 if (not FFromSelf) and (Message.Result <> LB_ERR) then with Message do 1883 begin1884 FFromSelf := True;1885 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, WParam, 0));1886 if(assigned(ItemRec)) then1887 Result := Length(TListBox(self).Items[WParam])// Result:length of string1888 else1889 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; 1892 1903 end; 1893 1904 … … 1900 1911 if not FFromSelf then 1901 1912 begin 1902 if FLongList then 1913 if FLongList then // -- special long list processing - begin 1903 1914 begin 1904 1915 if FFromNeedData then FDataAdded := True else with Message do 1905 begin1906 WParam := FWaterMark;1907 Result := Perform(LB_INSERTSTRING, WParam, LParam);// always insert into short list1908 Exit;1909 end;1910 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 1911 1922 New(ItemRec); 1912 1923 with ItemRec^, Message do … … 1922 1933 DoChange; 1923 1934 with Message do if Result <> LB_ERR then 1924 begin1925 FFromSelf := True;1926 SendMessage(Handle,LB_SETITEMDATA, Result, Integer(ItemRec));// Result: new item index1927 FFromSelf := False;1928 end1929 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); 1930 1941 end 1931 1942 else inherited; … … 1939 1950 if not FFromSelf then 1940 1951 begin 1941 if FLongList then 1952 if FLongList then // -- special long list processing - begin 1942 1953 begin 1943 1954 if FFromNeedData then … … 1947 1958 end 1948 1959 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); 1954 1967 end; 1955 Inc(FWaterMark); 1956 end; 1957 end; // -- special long list processing - end 1968 end; // -- special long list processing - end 1958 1969 New(ItemRec); 1959 1970 with ItemRec^, Message do … … 1968 1979 DoChange; 1969 1980 with Message do if Result <> LB_ERR then 1970 begin1971 FFromSelf := True;1972 SendMessage(Handle,LB_SETITEMDATA, Result, Integer(ItemRec)); // Result: new item index1973 FFromSelf := False;1974 end1975 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); 1976 1987 end 1977 1988 else inherited; … … 1986 1997 begin 1987 1998 FFromSelf := True; 1988 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, WParam, 0));// WParam: list index1999 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, WParam, 0)); // WParam: list index 1989 2000 FFromSelf := False; 1990 if (assigned(ItemRec)) then2001 if (assigned(ItemRec)) then 1991 2002 begin 1992 2003 if FLongList and not FFromNeedData then … … 1995 2006 end; 1996 2007 end; 1997 FFromSelf := True; 1998 inherited; 1999 FFromSelf := False; 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. 2000 2011 DoChange; 2001 2012 end; … … 2013 2024 begin 2014 2025 FFromSelf := True; 2015 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, i, 0));2026 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, i, 0)); 2016 2027 FFromSelf := False; 2017 2028 Dispose(ItemRec); … … 2049 2060 case Message.CharCode of 2050 2061 VK_LBUTTON, VK_RETURN, VK_SPACE: 2051 begin2052 if (FocusIndex < 0) and (CheckBoxes or MultiSelect) and (Count > 0) then // JNM - 508 compliance2053 SetFocusIndex(0);2054 if FocusIndex > -1 then2055 2062 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 2057 2066 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); 2062 2073 // Send WM_COMMAND here because LBN_SELCHANGE not triggered by LB_SETSEL 2063 2074 // and LBN_SELCHANGE is what eventually triggers the Click event. … … 2067 2078 //PostMessage() not SendMessage() is Required here for checkboxes, SendMessage() doesn't 2068 2079 //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; 2073 2085 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); 2080 2091 VK_RIGHT, VK_DOWN: SetFocusIndex(FocusIndex + 1); 2081 2092 else inherited; 2082 2093 end; 2083 2094 Message.Result := 0; … … 2094 2105 begin 2095 2106 if FParentCombo <> nil then with Message do 2096 begin2097 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); //+ 2100 2111 // if the mouse was clicked in the client area set ItemIndex ourselves 2101 if PtInRect(ListRect, Point(XPos, YPos)) then//~2102 begin2103 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; 2108 2119 // if the mouse was clicked on the scrollbar, send a message to make the scrolling happen 2109 2120 // this is done with WM_NCLBUTTONDOWN, which is ignored if mousecapture is on, so we have 2110 2121 // 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 //~ 2115 2124 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; 2145 2156 inherited; 2146 2157 end; … … 2162 2173 2163 2174 begin 2164 if (FRightClickSelect and (FParentCombo = nil)) then with Message do // List Boxes only, not Combo Boxes2165 begin2166 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); //+ 2168 2179 // if the mouse was clicked in the client area set ItemIndex ourselves 2169 if PtInRect(ListRect, Point(XPos, YPos)) then//~2170 begin2171 AnItem := GetIndexFromY(YPos);2172 if AnItem >= Items.Count then AnItem := -1;2173 end2174 else2175 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; 2178 2189 inherited; 2179 2190 end; … … 2186 2197 begin 2187 2198 if FParentCombo <> nil then with Message do 2188 begin2189 if(FCheckBoxes) then FDontClose := TRUE;2199 begin 2200 if (FCheckBoxes) then FDontClose := TRUE; 2190 2201 // if the mouse was clicked on the scrollbar, send a message to make the scrolling happen 2191 2202 // this is done with WM_NCLBUTTONDOWN, which is ignored if mousecapture is on, so we have 2192 2203 // 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 2197 2206 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} 2214 2225 inherited; 2215 2226 end; … … 2258 2269 GetCursorPos(APoint); 2259 2270 APoint := ScreenToClient(APoint); 2260 MouseMove([], APoint.X, APoint.Y); 2271 MouseMove([], APoint.X, APoint.Y); // assume nothing in ShiftState for now 2261 2272 end; 2262 2273 … … 2311 2322 procedure TORListBox.DestroyItems; 2312 2323 var 2313 ItemCount, i: Integer;2324 ItemCount, i: Integer; 2314 2325 ItemRec: PItemRec; 2315 2326 2316 2327 begin 2317 if (not FItemsDestroyed) then2328 if (not FItemsDestroyed) then 2318 2329 begin 2319 2330 ItemCount := Perform(LB_GETCOUNT, 0, 0); … … 2321 2332 begin 2322 2333 FFromSelf := True; 2323 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, i, 0));2334 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, i, 0)); 2324 2335 FFromSelf := False; 2325 2336 if Assigned(ItemRec) then … … 2338 2349 2339 2350 begin 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; 2341 2352 OldFromSelf := FFromSelf; 2342 2353 FFromSelf := True; 2343 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, idx, 0));2354 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, idx, 0)); 2344 2355 FFromSelf := OldFromSelf; 2345 if (assigned(ItemRec)) then2346 begin 2347 if (FAllowGrayed) then2356 if (assigned(ItemRec)) then 2357 begin 2358 if (FAllowGrayed) then 2348 2359 begin 2349 2360 case ItemRec^.CheckedState of 2350 2361 cbUnchecked: ItemRec^.CheckedState := cbGrayed; 2351 cbGrayed: 2352 cbChecked: 2362 cbGrayed: ItemRec^.CheckedState := cbChecked; 2363 cbChecked: ItemRec^.CheckedState := cbUnchecked; 2353 2364 end; 2354 2365 end 2355 2366 else 2356 2367 begin 2357 if (ItemRec^.CheckedState = cbUnchecked) then2368 if (ItemRec^.CheckedState = cbUnchecked) then 2358 2369 ItemRec^.CheckedState := cbChecked 2359 2370 else … … 2363 2374 Rect := ItemRect(Idx); 2364 2375 InvalidateRect(Handle, @Rect, FALSE); 2365 if (assigned(FOnClickCheck)) then2376 if (assigned(FOnClickCheck)) then 2366 2377 FOnClickCheck(Self, idx); 2367 if (assigned(FParentCombo)) then2378 if (assigned(FParentCombo)) then 2368 2379 FParentCombo.UpdateCheckEditBoxText; 2369 2380 end; … … 2389 2400 uItemTip.Hide; 2390 2401 inherited MouseDown(Button, Shift, X, Y); 2391 if (FCheckBoxes) and (X >= 0) and (X <= Width) and (Y >= 0) and (Y <= Height) then2402 if (FCheckBoxes) and (X >= 0) and (X <= Width) and (Y >= 0) and (Y <= Height) then 2392 2403 begin 2393 2404 idx := GetIndexFromY(Y); 2394 if (idx >= 0) then2395 begin 2396 if (FCheckEntireLine) then2405 if (idx >= 0) then 2406 begin 2407 if (FCheckEntireLine) then 2397 2408 ToggleCheckBox(idx) 2398 2409 else 2399 if(X < CheckWidth) then ToggleCheckBox(idx); 2400 end; 2410 if (X < CheckWidth) then ToggleCheckBox(idx); 2411 end; 2412 end; 2413 end; 2414 2415 procedure TORListBox.SetHintProperties(Restore: Boolean; MainForm: TComponent); 2416 var 2417 i, x: integer; 2418 Component: TComponent; 2419 begin 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); 2401 2466 end; 2402 2467 end; … … 2408 2473 var 2409 2474 AnItem: Integer; 2410 TrueOffset :integer;2475 TrueOffset: integer; 2411 2476 TipPos: TPoint; 2412 2477 begin 2413 2478 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 2414 2490 if (not FItemTipEnable) or (not Application.Active) then Exit; 2415 2491 { Make sure mouse really moved before continuing. For some reason, MouseMove gets called … … 2422 2498 if not PtInRect(ClientRect, Point(X, Y)) then 2423 2499 begin 2500 If FParentCombo = nil then MouseCapture := False; 2424 2501 uItemTip.Hide; 2425 2502 FItemTipActive := False; … … 2449 2526 procedure TORListBox.MeasureItem(Index: Integer; var Height: Integer); 2450 2527 var 2451 Txt: string;2452 2453 begin 2454 if (FHideSynonyms) and (fSynonymChars <> '') then2455 begin 2456 if (FCreatingItem) then2528 Txt: string; 2529 2530 begin 2531 if (FHideSynonyms) and (fSynonymChars <> '') then 2532 begin 2533 if (FCreatingItem) then 2457 2534 Txt := FCreatingText 2458 2535 else 2459 Txt := 2460 if (IsSynonym(Txt)) then Height := 0;2536 Txt := Items[Index]; 2537 if (IsSynonym(Txt)) then Height := 0; 2461 2538 end; 2462 2539 inherited MeasureItem(Index, Height); … … 2465 2542 procedure TORListBox.WMDestroy(var Message: TWMDestroy); 2466 2543 begin 2467 if (assigned(Owner)) and (csDestroying in Owner.ComponentState) then2544 if (assigned(Owner)) and (csDestroying in Owner.ComponentState) then 2468 2545 DestroyItems; 2469 2546 inherited; … … 2472 2549 procedure TORListBox.CNDrawItem(var Message: TWMDrawItem); 2473 2550 begin 2474 if (FCheckBoxes) then2551 if (FCheckBoxes) then 2475 2552 with Message.DrawItemStruct^ do 2476 2553 inc(rcItem.Left, CheckWidth); … … 2482 2559 Flags: Longint; 2483 2560 ItemRec: PItemRec; 2484 OldFromSelf :boolean;2561 OldFromSelf: boolean; 2485 2562 BMap: TBitMap; 2486 2563 i, DY: integer; … … 2489 2566 ShowText: string; 2490 2567 begin 2491 if (assigned(FOnBeforeDraw)) then2568 if (assigned(FOnBeforeDraw)) then 2492 2569 FOnBeforeDraw(Self, Index, Rect, State); 2493 2570 if Assigned(OnDrawItem) then OnDrawItem(Self, Index, Rect, State) … … 2504 2581 OldFromSelf := FFromSelf; 2505 2582 FFromSelf := True; 2506 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Index, 0));// WParam: list index2583 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Index, 0)); // WParam: list index 2507 2584 FFromSelf := OldFromSelf; 2508 2585 2509 if (FCheckBoxes) then2586 if (FCheckBoxes) then 2510 2587 begin 2511 if (assigned(ItemRec)) then2588 if (assigned(ItemRec)) then 2512 2589 begin 2513 2590 case ItemRec^.CheckedState of 2514 2591 cbUnchecked: 2515 2592 begin 2516 if (FFlatCheckBoxes) then2593 if (FFlatCheckBoxes) then 2517 2594 BMap := GetORCBBitmap(iiFlatUnChecked, FBlackColorMode) 2518 2595 else … … 2521 2598 cbChecked: 2522 2599 begin 2523 if (FFlatCheckBoxes) then2600 if (FFlatCheckBoxes) then 2524 2601 BMap := GetORCBBitmap(iiFlatChecked, FBlackColorMode) 2525 2602 else 2526 2603 BMap := GetORCBBitmap(iiChecked, FBlackColorMode); 2527 2604 end; 2528 2529 2530 if(FFlatCheckBoxes) then2531 2532 2533 2534 2605 else // cbGrayed: 2606 begin 2607 if (FFlatCheckBoxes) then 2608 BMap := GetORCBBitmap(iiFlatGrayed, FBlackColorMode) 2609 else 2610 BMap := GetORCBBitmap(iiGrayed, FBlackColorMode); 2611 end; 2535 2612 end; 2536 2613 end 2537 2614 else 2538 2615 begin 2539 if (FFlatCheckBoxes) then2616 if (FFlatCheckBoxes) then 2540 2617 BMap := GetORCBBitmap(iiFlatGrayed, FBlackColorMode) 2541 2618 else … … 2544 2621 TmpR := Rect; 2545 2622 TmpR.Right := TmpR.Left; 2546 dec(TmpR.Left, CheckWidth +1);2623 dec(TmpR.Left, CheckWidth + 1); 2547 2624 DY := ((TmpR.Bottom - TmpR.Top) - BMap.Height) div 2; 2548 2625 Canvas.Draw(TmpR.Left, TmpR.Top + DY, BMap); 2549 2626 end; 2550 2627 2551 if (FTabPos[0] > 0) then2628 if (FTabPos[0] > 0) then 2552 2629 Flags := (FTabPos[1] * 256) or Flags or DT_TABSTOP or DT_EXPANDTABS; 2553 2630 2554 2631 ShowText := GetDisplayText(Index); 2555 if (Style <> lbStandard) and (FTabPos[0] > 0) then2632 if (Style <> lbStandard) and (FTabPos[0] > 0) then 2556 2633 begin 2557 2634 for i := 1 to FTabPix[0] do … … 2559 2636 Neg := (FTabPix[i] < 0); 2560 2637 if Neg then FTabPix[i] := -FTabPix[i]; 2561 inc(FTabPix[i], Rect.Left-1);2638 inc(FTabPix[i], Rect.Left - 1); 2562 2639 if Neg then FTabPix[i] := -FTabPix[i]; 2563 2640 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), 2565 2642 FTabPix[0], FTabPix[1], -1); 2566 2643 for i := 1 to FTabPix[0] do … … 2568 2645 Neg := (FTabPix[i] < 0); 2569 2646 if Neg then FTabPix[i] := -FTabPix[i]; 2570 dec(FTabPix[i], Rect.Left-1);2647 dec(FTabPix[i], Rect.Left - 1); 2571 2648 if Neg then FTabPix[i] := -FTabPix[i]; 2572 2649 end; … … 2578 2655 end; 2579 2656 2580 function TORListBox.GetIndexFromY(YPos :integer) :integer;2581 begin 2582 if (FHideSynonyms) then2583 begin 2584 Result := TopIndex -1;2657 function TORListBox.GetIndexFromY(YPos: integer): integer; 2658 begin 2659 if (FHideSynonyms) then 2660 begin 2661 Result := TopIndex - 1; 2585 2662 repeat 2586 2663 inc(Result); 2587 if (Perform(LB_GETITEMHEIGHT, Result, 0) > 0) then2588 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)); 2590 2667 end 2591 2668 else … … 2602 2679 ScrollCount, ScrollPos, InitialTop, i: Integer; 2603 2680 begin 2604 if FLongList then 2605 begin 2606 if (Value = SFI_TOP) or (Value = SFI_END) then 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 2607 2684 begin 2608 2685 if Value = SFI_TOP then ScrollPos := 0 else ScrollPos := 100; 2609 ScrollTo(Self, scPosition, ScrollPos); 2686 ScrollTo(Self, scPosition, ScrollPos); // ScrollTo is scrollbar event 2610 2687 FScrollBar.Position := ScrollPos; 2611 2688 if ScrollPos = 0 then Value := FFocusIndex else Value := FFocusIndex + FLargeChange; … … 2614 2691 InitialTop := TopIndex; 2615 2692 ScrollCount := Value - InitialTop; 2616 ScrollPos := 50; 2617 if ScrollCount < 0 then 2693 ScrollPos := 50; // arbitrary, can be anything from 1-99 2694 if ScrollCount < 0 then // scroll backwards 2618 2695 begin 2619 2696 if ScrollCount = -FLargeChange then ScrollTo(Self, scPageUp, ScrollPos) else … … 2622 2699 Value := Value + (FCurrentTop - InitialTop); 2623 2700 end; 2624 if ScrollCount > FLargeChange then 2701 if ScrollCount > FLargeChange then // scroll forwards 2625 2702 begin 2626 2703 if ScrollCount = (FLargeChange * 2) then ScrollTo(Self, scPageDown, ScrollPos) else … … 2628 2705 FScrollBar.Position := ScrollPos; 2629 2706 end; 2630 if (FHideSynonyms) then2707 if (FHideSynonyms) then 2631 2708 begin 2632 while ((Perform(LB_GETITEMHEIGHT, Value, 0) = 0) and (Value >= 0) and (value < Items.Count)) do2709 while ((Perform(LB_GETITEMHEIGHT, Value, 0) = 0) and (Value >= 0) and (value < Items.Count)) do 2633 2710 begin 2634 if (Value < FFocusIndex) then2711 if (Value < FFocusIndex) then 2635 2712 dec(Value) 2636 2713 else … … 2639 2716 end; 2640 2717 end; 2641 end; 2718 end; // -- special long list processing - end 2642 2719 if (Value = SFI_END) or (not (Value < Items.Count)) then Value := Items.Count - 1; 2643 2720 if (Value = SFI_TOP) or (Value < 0) then Value := 0; … … 2670 2747 var 2671 2748 TipPos: TPoint; 2672 TrueOffset :integer;2673 TmpIdx :integer;2749 TrueOffset: integer; 2750 TmpIdx: integer; 2674 2751 begin 2675 2752 // if listbox is dropdown combo but control is not focused - … … 2680 2757 // if control is not focused - 2681 2758 if (Screen.ActiveControl <> Self) and (Screen.ActiveControl <> Parent) then Exit; 2682 if (FHideSynonyms) then2759 if (FHideSynonyms) then 2683 2760 begin 2684 2761 TrueOffset := TopIndex; 2685 2762 TmpIdx := TopIndex; 2686 while ((TmpIdx < Message.wParam) and (TmpIdx < Items.Count)) do2687 begin 2688 if (Perform(LB_GETITEMHEIGHT, TmpIdx, 0) > 0) then2763 while ((TmpIdx < Message.wParam) and (TmpIdx < Items.Count)) do 2764 begin 2765 if (Perform(LB_GETITEMHEIGHT, TmpIdx, 0) > 0) then 2689 2766 inc(TrueOffset); 2690 2767 inc(TmpIdx); … … 2695 2772 TipPos := ClientToScreen(Point(0, (TrueOffset - TopIndex) * ItemHeight)); 2696 2773 //uItemTip.Show(Self, FFocusIndex, TipPos, NO_CATCH_MOUSE); 2697 uItemTip.Show(Self, FFocusIndex, TipPos, FParentCombo = nil); 2774 uItemTip.Show(Self, FFocusIndex, TipPos, FParentCombo = nil); // if DropDown, no mousecapture 2698 2775 end; 2699 2776 … … 2703 2780 if (AnIndex < Items.Count) and (AnIndex > -1) 2704 2781 then Result := StrToInt64Def(Piece(Items[AnIndex], FDelimiter, 1), 0) 2705 2782 else Result := 0; 2706 2783 end; 2707 2784 … … 2711 2788 if ItemIndex > -1 2712 2789 then Result := StrToInt64Def(Piece(Items[ItemIndex], FDelimiter, 1), 0) 2713 2790 else Result := 0; 2714 2791 end; 2715 2792 … … 2739 2816 if FLongList then ListEnd := FWaterMark - 1 else ListEnd := Items.Count - 1; 2740 2817 for i := 0 to ListEnd do if (GetIEN(i) = AnIEN) and (GetDisplayText(i) = AnItem) then 2741 begin2742 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; 2747 2824 if FLongList and not ItemFound then 2748 2825 begin … … 2781 2858 raise Exception.Create('List Index Out of Bounds'); 2782 2859 FFromSelf := True; 2783 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Index, 0));2860 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Index, 0)); 2784 2861 FFromSelf := False; 2785 if (assigned(ItemRec)) then2862 if (assigned(ItemRec)) then 2786 2863 Result := ItemRec^.Reference 2787 2864 else … … 2797 2874 raise Exception.Create('List Index Out of Bounds'); 2798 2875 FFromSelf := True; 2799 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Index, 0));2876 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Index, 0)); 2800 2877 FFromSelf := False; 2801 if (assigned(ItemRec)) then2878 if (assigned(ItemRec)) then 2802 2879 ItemRec^.Reference := AReference; 2803 2880 end; … … 2834 2911 { returns the character based tab stops that are currently set, if any } 2835 2912 begin 2836 if (FTabPosInPixels) then2913 if (FTabPosInPixels) then 2837 2914 Result := IntArrayToString(FTabPix) 2838 2915 else … … 2849 2926 for i := 2 to TabTmp[0] do 2850 2927 if (abs(TabTmp[i]) < abs(TabTmp[i - 1])) or 2851 2928 (TabTmp[i] = TabTmp[i - 1]) then 2852 2929 raise Exception.Create('Tab positions must be in ascending order'); 2853 if (FTabPosInPixels) then2930 if (FTabPosInPixels) then 2854 2931 begin 2855 2932 for i := 0 to TabTmp[0] do FTabPix[i] := TabTmp[i]; … … 2866 2943 procedure TORListBox.SetTabPosInPixels(const Value: boolean); 2867 2944 begin 2868 if (FTabPosInPixels <> Value) then2945 if (FTabPosInPixels <> Value) then 2869 2946 begin 2870 2947 FTabPosInPixels := Value; … … 2879 2956 i, AveWidth: Integer; 2880 2957 begin 2881 FillChar(TabDlg, SizeOf(TabDlg),0);2958 FillChar(TabDlg, SizeOf(TabDlg), 0); 2882 2959 AveWidth := FontWidthPixel(Self.Font.Handle); 2883 if (FTabPosInPixels) then2960 if (FTabPosInPixels) then 2884 2961 begin 2885 2962 FillChar(FTabPos, SizeOf(FTabPos), 0); … … 2888 2965 begin 2889 2966 FTabPos[i] := FTabPix[i] div AveWidth; 2890 TabDlg[i] 2967 TabDlg[i] := (FTabPix[i] * 4) div AveWidth; 2891 2968 end; 2892 2969 end … … 2898 2975 begin 2899 2976 // do dialog units first so that pixels gets the same rounding error 2900 TabDlg[i] := FTabPos[i] * 4;// 4 dialog units per character2977 TabDlg[i] := FTabPos[i] * 4; // 4 dialog units per character 2901 2978 FTabPix[i] := (TabDlg[i] * AveWidth) div 4; 2902 2979 end; 2903 2980 end; 2904 TabDlg[0] 2981 TabDlg[0] := FTabPos[0]; 2905 2982 Perform(LB_SETTABSTOPS, TabDlg[0], Integer(@TabDlg[1])); 2906 2983 Refresh; … … 2912 2989 end; 2913 2990 2914 procedure TORListBox.SetHideSynonyms(Value :boolean);2915 var 2916 TmpIH :integer;2917 2918 begin 2919 if (FHideSynonyms <> Value) then2920 begin 2921 if ((Value) and (not FLongList)) then2991 procedure TORListBox.SetHideSynonyms(Value: boolean); 2992 var 2993 TmpIH: integer; 2994 2995 begin 2996 if (FHideSynonyms <> Value) then 2997 begin 2998 if ((Value) and (not FLongList)) then 2922 2999 raise Exception.Create('Hide Synonyms only allowed on Long Lists'); 2923 3000 FHideSynonyms := Value; 2924 if (not FHideSynonyms) then3001 if (not FHideSynonyms) then 2925 3002 begin 2926 3003 Style := lbStandard; … … 2928 3005 else 2929 3006 begin 2930 if (FSynonymChars = '') then3007 if (FSynonymChars = '') then 2931 3008 FSynonymChars := '<>'; 2932 3009 TmpIH := ItemHeight; … … 2937 3014 end; 2938 3015 2939 procedure TORListBox.SetSynonymChars(Value :string);2940 begin 2941 if (FSynonymChars <> Value) then3016 procedure TORListBox.SetSynonymChars(Value: string); 3017 begin 3018 if (FSynonymChars <> Value) then 2942 3019 begin 2943 3020 FSynonymChars := Value; 2944 if ((Value = '') and (FHideSynonyms)) then3021 if ((Value = '') and (FHideSynonyms)) then 2945 3022 SetHideSynonyms(FALSE); 2946 if (FHideSynonyms) then3023 if (FHideSynonyms) then 2947 3024 begin 2948 3025 SetHideSynonyms(FALSE); … … 2959 3036 procedure TORListBox.SetStyle(Value: TListBoxStyle); 2960 3037 begin 2961 if (Value <> lbOwnerDrawVariable) and (FHideSynonyms) then3038 if (Value <> lbOwnerDrawVariable) and (FHideSynonyms) then 2962 3039 FHideSynonyms := FALSE; 2963 if (FCheckBoxes) and (Value = lbStandard) then3040 if (FCheckBoxes) and (Value = lbStandard) then 2964 3041 FCheckBoxes := FALSE; 2965 3042 inherited Style := Value; … … 3002 3079 try 3003 3080 TORStrings(Items).Verification := False; 3004 HandleNeeded; 3081 HandleNeeded; // ensures that Items is valid if in the middle of RecreateWnd 3005 3082 SaveListMode := FLongList; 3006 3083 Strings := TStringList.Create; 3007 3084 SaveItems := TList.Create; 3008 FLongList := False; 3085 FLongList := False; // so don't have to track WaterMark 3009 3086 FFromSelf := True; 3010 for i := 0 to Items.Count - 1 do 3087 for i := 0 to Items.Count - 1 do // put pointers to TItemRec in SaveItems 3011 3088 begin 3012 3089 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, i, 0)); … … 3014 3091 end; 3015 3092 Strings.Assign(Items); 3016 Items.Clear; 3093 Items.Clear; // still FromSelf so don't dispose recs 3017 3094 FFromSelf := False; 3018 for i := 0 to SaveItems.Count - 1 do 3095 for i := 0 to SaveItems.Count - 1 do // use saved ItemRecs to rebuild listbox 3019 3096 begin 3020 3097 ItemRec := SaveItems[i]; 3021 if (assigned(ItemRec)) then3098 if (assigned(ItemRec)) then 3022 3099 begin 3023 3100 Pos := Items.AddObject(Strings[i], ItemRec^.UserObject); 3024 3101 // CQ 11491 - Changing TabPositions, etc. was wiping out check box status. 3025 3102 FFromSelf := True; 3026 ItemRec2 := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Pos, 0));3103 ItemRec2 := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Pos, 0)); 3027 3104 FFromSelf := False; 3028 if (assigned(ItemRec2)) then3105 if (assigned(ItemRec2)) then 3029 3106 begin 3030 3107 ItemRec2^.Reference := ItemRec^.Reference; … … 3051 3128 begin 3052 3129 FreeScrollBar; 3053 if (FHideSynonyms) then3130 if (FHideSynonyms) then 3054 3131 SetHideSynonyms(FALSE); 3055 3132 end; … … 3062 3139 L, T, W, H, OffsetLT, OffsetWH: Integer; 3063 3140 begin 3064 if uNewStyle then begin OffsetLT := 2; OffsetWH := 4; end 3065 else begin OffsetLT := 0; OffsetWH := 0; end;// Win3.13141 if uNewStyle then begin OffsetLT := 2; OffsetWH := 4; end // Win95 3142 else begin OffsetLT := 0; OffsetWH := 0; end; // Win3.1 3066 3143 W := GetSystemMetrics(SM_CXVSCROLL); 3067 3144 L := Left + Width - W - OffsetLT; … … 3076 3153 begin 3077 3154 FLongList := True; 3078 if MultiSelect then MultiSelect := False; 3155 if MultiSelect then MultiSelect := False; // LongLists do not support multiple selections 3079 3156 FScrollBar := TScrollBar.Create(Self); 3080 3157 FScrollBar.Kind := sbVertical; … … 3085 3162 if FParentCombo = nil 3086 3163 then FScrollBar.Parent := Parent 3087 3164 else FScrollBar.Parent := FParentCombo.FDropPanel; 3088 3165 end; 3089 3166 … … 3092 3169 begin 3093 3170 FLongList := False; 3094 FScrollBar.Free; 3171 FScrollBar.Free; // don't call from destroy because scrollbar may already be free 3095 3172 FScrollBar := nil; 3096 3173 end; … … 3112 3189 3113 3190 FirstItem := TextToShow(Strings[0]); 3114 LastItem := TextToShow(Strings[Strings.Count-1]);3191 LastItem := TextToShow(Strings[Strings.Count - 1]); 3115 3192 Ascend := True; 3116 3193 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 3121 False: case FDirection of3122 3123 3124 3125 True:case FDirection of3126 3127 3128 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; 3129 3206 end; 3130 3207 end; … … 3141 3218 index := GetStringIndex(S); 3142 3219 if index > -1 then 3143 S := Piece(Items[index], Delimiter,LookUpPiece);3220 S := Piece(Items[index], Delimiter, LookUpPiece); 3144 3221 end; 3145 3222 if CaseChanged then … … 3157 3234 if FWaterMark > 0 then 3158 3235 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); 3161 3238 end; 3162 3239 end; … … 3184 3261 begin 3185 3262 case FDirection of 3186 LL_REVERSE:for i := Items.Count - 1 downto3187 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); 3190 3267 end; 3191 3268 end; … … 3199 3276 if Items.Count > 1000 then ClearLong; 3200 3277 case FDirection of 3201 LL_REVERSE:if FWaterMark < Items.Count then StartFrom := DisplayText[FWaterMark];3202 LL_POSITION: begin3203 3204 3205 3206 3207 3208 3209 3210 3211 LL_FORWARD:if (FWaterMark < Items.Count) and (Items.Count > 0)3212 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]; 3213 3290 end; 3214 3291 if LookupPiece <> 0 then … … 3216 3293 index := GetStringIndex(StartFrom); 3217 3294 if index > -1 then 3218 StartFrom := Piece(Items[index], Delimiter,LookUpPiece);3295 StartFrom := Piece(Items[index], Delimiter, LookUpPiece); 3219 3296 end; 3220 3297 if CaseChanged then 3221 3298 StartFrom := Uppercase(StartFrom); 3222 StartFrom := Copy(StartFrom, 1, 128); 3223 CtrlPos := 0; 3299 StartFrom := Copy(StartFrom, 1, 128); // limit length to 128 characters 3300 CtrlPos := 0; // make sure no ctrl characters 3224 3301 for CharPos := 1 to Length(StartFrom) do if StartFrom[CharPos] in [#0..#31] then 3225 begin3226 CtrlPos := CharPos;3227 break;3228 end;3302 begin 3303 CtrlPos := CharPos; 3304 break; 3305 end; 3229 3306 if CtrlPos > 0 then StartFrom := Copy(StartFrom, 1, CtrlPos - 1); 3230 3307 if FDirection = LL_FORWARD then FInsertAt := Items.Count else FInsertAt := FWaterMark; … … 3243 3320 x := DisplayText[TopIndex]; 3244 3321 if (FWaterMark > 0) and (TopIndex < FWaterMark) 3245 then Result := 0 3246 3247 Inc(Result); 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 3248 3325 end; 3249 3326 … … 3251 3328 { event code for the longlist scrollbar, adjusts TopIndex & calls OnNeedData as necessary } 3252 3329 var 3253 Count, Goal, Dir :integer; 3254 Done :boolean; 3255 3256 begin 3330 Count, Goal, Dir: integer; 3331 Done: boolean; 3332 DropDownPanel: TORListBox; 3333 begin 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; 3257 3342 uItemTip.Hide; 3258 3343 FCurrentTop := TopIndex; 3259 if (ScrollCode = scPosition) then3344 if (ScrollCode = scPosition) then 3260 3345 begin 3261 3346 NeedData(LL_POSITION, ALPHA_DISTRIBUTION[ScrollPos]); 3262 3347 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); 3266 3351 end; 3267 3352 FFocusIndex := TopIndex; 3268 3353 end 3269 3354 else 3270 if(HideSynonyms) then3271 begin3272 Count := 0;3273 case ScrollCode of3274 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; 3278 3363 else 3279 3364 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 3288 3369 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; 3291 3386 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 3297 3388 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; 3300 3395 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; 3301 3420 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; 3337 3422 if (ScrollPos > 0) and (ScrollPos < 100) then ScrollPos := PositionThumb; 3338 3423 end; … … 3344 3429 begin 3345 3430 Result := -1; 3346 if Length(AString) > 0 then 3347 begin 3348 if not FLongList then 3431 if Length(AString) > 0 then {*KCM*} 3432 begin 3433 if not FLongList then // Normal List 3349 3434 begin 3350 3435 Result := SendMessage(Handle, LB_FINDSTRING, -1, Longint(PChar(AString))); 3351 3436 if Result = LB_ERR then Result := -1; 3352 end else 3437 end else // Long List 3353 3438 begin 3354 3439 if FScrollBar.Position = 0 then for i := 0 to FWatermark - 1 do 3355 begin3356 if CompareText(AString, Copy(DisplayText[i], 1, Length(AString))) = 0 then3357 3440 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; 3360 3446 end; 3361 end;3362 3447 if Result < 0 then 3363 3448 begin … … 3377 3462 begin 3378 3463 Result := -1; 3379 if Length(AString) > 0 then 3380 begin 3381 if not FLongList then 3464 if Length(AString) > 0 then {*KCM*} 3465 begin 3466 if not FLongList then // Normal List 3382 3467 begin 3383 3468 Result := SendMessage(Handle, LB_FINDSTRING, -1, Longint(PChar(AString))); … … 3385 3470 // use FFocusIndex instead of FocusIndex to reduce flashing 3386 3471 FFocusIndex := Result; 3387 end else 3472 end else // Long List 3388 3473 begin 3389 3474 if FScrollBar.Position = 0 then for i := 0 to FWatermark - 1 do 3390 begin3391 if CompareText(AString, Copy(DisplayText[i], 1, Length(AString))) = 0 then3392 3475 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; 3395 3481 end; 3396 end;3397 3482 if not StringBetween(AString, DisplayText[FWaterMark], DisplayText[Items.Count - 1]) then 3398 3483 begin … … 3402 3487 index := GetStringIndex(x); 3403 3488 if index > -1 then 3404 x := Piece(Items[index], Delimiter,LookUpPiece);3489 x := Piece(Items[index], Delimiter, LookUpPiece); 3405 3490 end; 3406 3491 if CaseChanged then … … 3421 3506 ItemIndex := Result; 3422 3507 FFocusIndex := Result; 3423 if Result > -1 then TopIndex := Result; 3424 if FLongList then FScrollBar.Position := PositionThumb; 3508 if Result > -1 then TopIndex := Result; // will scroll item into view 3509 if FLongList then FScrollBar.Position := PositionThumb; // done after topindex set 3425 3510 end; 3426 3511 3427 3512 procedure TORListBox.SetCheckBoxes(const Value: boolean); 3428 3513 begin 3429 if (FCheckBoxes <> Value) then3514 if (FCheckBoxes <> Value) then 3430 3515 begin 3431 3516 FCheckBoxes := Value; 3432 if (Value) then3433 begin 3434 if (GetStyle = lbStandard) then3517 if (Value) then 3518 begin 3519 if (GetStyle = lbStandard) then 3435 3520 SetStyle(lbOwnerDrawFixed); 3436 if (inherited MultiSelect) then3521 if (inherited MultiSelect) then 3437 3522 SetMultiSelect(FALSE); 3438 3523 end; … … 3443 3528 procedure TORListBox.SetFlatCheckBoxes(const Value: boolean); 3444 3529 begin 3445 if (FFlatCheckBoxes <> Value) then3530 if (FFlatCheckBoxes <> Value) then 3446 3531 begin 3447 3532 FFlatCheckBoxes := Value; … … 3458 3543 if Index < 0 then exit; 3459 3544 FFromSelf := True; 3460 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Index, 0));3545 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Index, 0)); 3461 3546 FFromSelf := FALSE; 3462 if (assigned(ItemRec)) then3547 if (assigned(ItemRec)) then 3463 3548 Result := (ItemRec^.CheckedState = cbChecked) 3464 3549 else … … 3473 3558 begin 3474 3559 FFromSelf := True; 3475 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Index, 0));3560 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Index, 0)); 3476 3561 FFromSelf := False; 3477 3562 if (assigned(ItemRec)) and (Value <> (ItemRec^.CheckedState = cbChecked)) then 3478 3563 begin 3479 if (Value) then3564 if (Value) then 3480 3565 ItemRec^.CheckedState := cbChecked 3481 3566 else … … 3483 3568 Rect := ItemRect(Index); 3484 3569 InvalidateRect(Handle, @Rect, FALSE); 3485 if (assigned(FOnClickCheck)) then3570 if (assigned(FOnClickCheck)) then 3486 3571 FOnClickCheck(Self, Index); 3487 3572 end; … … 3494 3579 begin 3495 3580 FFromSelf := True; 3496 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Index, 0));3581 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Index, 0)); 3497 3582 FFromSelf := FALSE; 3498 if (assigned(ItemRec)) then3583 if (assigned(ItemRec)) then 3499 3584 Result := ItemRec^.CheckedState 3500 3585 else … … 3510 3595 begin 3511 3596 FFromSelf := True; 3512 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Index, 0));3597 ItemRec := PItemRec(SendMessage(Handle, LB_GETITEMDATA, Index, 0)); 3513 3598 FFromSelf := False; 3514 3599 if (assigned(ItemRec)) and (Value <> ItemRec^.CheckedState) then … … 3517 3602 Rect := ItemRect(Index); 3518 3603 InvalidateRect(Handle, @Rect, FALSE); 3519 if (assigned(FOnClickCheck)) then3604 if (assigned(FOnClickCheck)) then 3520 3605 FOnClickCheck(Self, Index); 3521 3606 end; … … 3530 3615 begin 3531 3616 inherited SetMultiSelect(Value); 3532 if (Value) then SetCheckBoxes(FALSE);3617 if (Value) then SetCheckBoxes(FALSE); 3533 3618 end; 3534 3619 … … 3539 3624 begin 3540 3625 Result := ''; 3541 if (FCheckBoxes) then3542 begin 3543 for i := 0 to Items.Count -1 do3626 if (FCheckBoxes) then 3627 begin 3628 for i := 0 to Items.Count - 1 do 3544 3629 Result := Result + Char(ord('0') + Ord(GetCheckedState(i))); 3545 3630 end; … … 3551 3636 3552 3637 begin 3553 for i := 0 to Items.Count -1 do3554 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))); 3555 3640 end; 3556 3641 … … 3558 3643 begin 3559 3644 if not Assigned(FMItems) then 3560 FMItems := TORStrings.Create(Tlistbox(Self).Items, TextToShow);3645 FMItems := TORStrings.Create(Tlistbox(Self).Items, TextToShow); 3561 3646 result := FMItems; 3562 3647 end; 3563 3648 3564 procedure TORListBox.SetMItems( 3649 procedure TORListBox.SetMItems(Value: TStrings); 3565 3650 begin 3566 3651 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); 3569 3654 end; 3570 3655 … … 3588 3673 FCaption.Width := 0; 3589 3674 FCaption.Visible := True; 3590 if Assigned 3675 if Assigned(FParentCombo) then 3591 3676 FCaption.Parent := FParentCombo 3592 3677 else … … 3612 3697 procedure DropDownPanelOpened; 3613 3698 begin 3614 if uDropPanelOpenCount =0 then3699 if uDropPanelOpenCount = 0 then 3615 3700 uOldShowHintsSetting := Application.ShowHint; 3616 Application.ShowHint := FALSE;3701 // Application.ShowHint := FALSE; 3617 3702 inc(uDropPanelOpenCount); 3618 3703 end; … … 3621 3706 begin 3622 3707 dec(uDropPanelOpenCount); 3623 if uDropPanelOpenCount <=0 then3708 if uDropPanelOpenCount <= 0 then 3624 3709 begin 3625 3710 uDropPanelOpenCount := 0; 3626 3711 if not Application.ShowHint then 3627 Application.ShowHint := uOldShowHintsSetting3712 // Application.ShowHint := uOldShowHintsSetting 3628 3713 end; 3629 3714 end; … … 3649 3734 BevelOuter := bvNone; 3650 3735 BorderStyle := bsNone; 3651 Caption := '';3736 Caption := ''; 3652 3737 Ctl3D := False; 3653 3738 Visible := False; … … 3660 3745 inherited CreateParams(Params); 3661 3746 if not (csDesigning in ComponentState) then with Params do 3662 begin3663 if uNewStyle then Params.ExStyle := Params.ExStyle or WS_EX_TOOLWINDOW;3664 Params.ExStyle := Params.ExStyle or WS_EX_TOPMOST;// - incompatible with ItemTip3665 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; 3668 3753 end; 3669 3754 … … 3674 3759 begin 3675 3760 Result := nil; 3676 if (FButtons) then3677 begin 3678 for i := 0 to ControlCount -1 do3679 if (Controls[i] is TSpeedButton) then3761 if (FButtons) then 3762 begin 3763 for i := 0 to ControlCount - 1 do 3764 if (Controls[i] is TSpeedButton) then 3680 3765 begin 3681 if ((OKBtn and ((Controls[i] as TSpeedButton).Tag = OKBtnTag)) or3682 3766 if ((OKBtn and ((Controls[i] as TSpeedButton).Tag = OKBtnTag)) or 3767 ((not OKBtn) and ((Controls[i] as TSpeedButton).Tag = CancelBtnTag))) then 3683 3768 begin 3684 3769 Result := TSpeedButton(Controls[i]); … … 3695 3780 begin 3696 3781 sb := GetButton(TRUE); 3697 if (assigned(sb)) then sb.Down := FALSE;3782 if (assigned(sb)) then sb.Down := FALSE; 3698 3783 sb := GetButton(FALSE); 3699 if (assigned(sb)) then sb.Down := FALSE;3784 if (assigned(sb)) then sb.Down := FALSE; 3700 3785 end; 3701 3786 … … 3707 3792 begin 3708 3793 inherited; 3709 if (FButtons) then3794 if (FButtons) then 3710 3795 begin 3711 3796 btn := GetButton(TRUE); 3712 if (assigned(btn)) then3797 if (assigned(btn)) then 3713 3798 begin 3714 3799 half := width div 2; 3715 3800 btn.Left := 0; 3716 3801 btn.Width := Half; 3717 btn.Top := Height -btn.Height;3802 btn.Top := Height - btn.Height; 3718 3803 btn := GetButton(FALSE); 3719 3804 btn.Left := Half; 3720 3805 btn.Width := Width - Half; 3721 btn.Top := Height -btn.Height;3806 btn.Top := Height - btn.Height; 3722 3807 end; 3723 3808 end; … … 3728 3813 btn: TSpeedButton; 3729 3814 cbo: TORComboBox; 3730 i: integer;3815 i: integer; 3731 3816 3732 3817 begin 3733 3818 cbo := (Owner as TORComboBox); 3734 if (cbo.FListBox.FCheckBoxes) then3735 begin 3736 if (not FButtons) then3819 if (cbo.FListBox.FCheckBoxes) then 3820 begin 3821 if (not FButtons) then 3737 3822 begin 3738 3823 btn := TSpeedButton.Create(Self); … … 3757 3842 end 3758 3843 else 3759 if(FButtons) then3760 begin3761 for i := ControlCount-1 downto 0 do3762 if(Controls[i] is TButton) then3763 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; 3767 3852 end; 3768 3853 … … 3782 3867 begin 3783 3868 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 3785 3876 end; 3786 3877 … … 3791 3882 begin 3792 3883 if (FListBox.FCheckBoxes) and assigned(FEditPanel) and 3793 3794 3884 (Message.FocusedWnd <> FListBox.Handle) and 3885 ((not assigned(FDropBtn)) or (Message.FocusedWnd <> FDropBtn.Handle)) then 3795 3886 begin 3796 3887 FEditPanel.FFocused := FALSE; … … 3845 3936 FEditBox.OnKeyUp := FwdKeyUp; 3846 3937 FEditBox.Visible := True; 3847 fCharsNeedMatch := 1; 3938 fCharsNeedMatch := 1; 3848 3939 end; 3849 3940 3850 3941 procedure TORComboBox.WMDestroy(var Message: TWMDestroy); 3851 3942 begin 3852 if (assigned(Owner)) and (csDestroying in Owner.ComponentState) then3943 if (assigned(Owner)) and (csDestroying in Owner.ComponentState) then 3853 3944 FListBox.DestroyItems; 3854 3945 inherited; … … 3889 3980 function TORComboBox.EditControl: TWinControl; 3890 3981 begin 3891 if (assigned(FEditPanel)) then3982 if (assigned(FEditPanel)) then 3892 3983 Result := FEditPanel 3893 3984 else … … 3899 3990 var 3900 3991 FontHeight: Integer; 3901 cboBtnX, cboBtnY: integer;3992 cboBtnX, cboBtnY: integer; 3902 3993 cboYMargin: integer; 3903 3994 … … 3917 4008 cboBtnY := CBO_CXFRAME; 3918 4009 end; 3919 Height := HigherOf(FontHeight + cboYMargin, Height); 4010 Height := HigherOf(FontHeight + cboYMargin, Height); // must be at least as high as text 3920 4011 EditControl.SetBounds(0, 0, Width, FontHeight + cboYMargin); 3921 if (assigned(FEditPanel)) then4012 if (assigned(FEditPanel)) then 3922 4013 FEditBox.SetBounds(2, 3, FEditPanel.Width - 4, FEditPanel.Height - 5); 3923 4014 if FStyle = orcsDropDown then 3924 4015 begin 3925 Height := FontHeight + cboYMargin; 4016 Height := FontHeight + cboYMargin; // DropDown can only be text height 3926 4017 FDropBtn.SetBounds(EditControl.Width - CBO_CXBTN - cboBtnX, 0, 3927 4018 CBO_CXBTN, EditControl.Height - cboBtnY); 3928 4019 end else 3929 4020 begin 3930 4021 FListBox.SetBounds(0, FontHeight + CBO_CYMARGIN, 3931 4022 Width, Height - FontHeight - CBO_CYMARGIN); 3932 4023 end; 3933 4024 SetEditRect; … … 3950 4041 { shift the focus back to the editbox so the focus rectangle doesn't clutter the button } 3951 4042 begin 3952 if FDroppedDown then FListBox.MouseCapture := True; 4043 if FDroppedDown then FListBox.MouseCapture := True; // do here so 1st buttonup not captured 3953 4044 FEditBox.SetFocus; 3954 4045 end; 3955 4046 3956 4047 procedure 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 4048 var 4049 DropDownPanel: TORListBox; 4050 begin 4051 DropDownPanel := TORListBox.Create(nil); 4052 try 4053 if opened then 4054 begin 4055 if not FDropPanel.Visible then 3963 4056 begin 3964 FDisableHints := TRUE; 3965 DropDownPanelOpened; 4057 if FDropDownStatusChangedCount = 0 then 4058 begin 4059 FDisableHints := TRUE; 4060 DropDownPanelOpened; 4061 end; 4062 inc(FDropDownStatusChangedCount); 3966 4063 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 3976 4069 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; 3979 4080 end; 3980 FDropDownStatusChangedCount := 0; 3981 end; 4081 end; 4082 finally 4083 DropDownPanel.Free; 3982 4084 end; 3983 4085 end; … … 4070 4172 begin 4071 4173 FChangePending := False; 4072 if (not FListItemsOnly) and (Length(FEditBox.Text) > 0) and (FEditBox.SelStart = 0) then Exit; 4174 if (not FListItemsOnly) and (Length(FEditBox.Text) > 0) and (FEditBox.SelStart = 0) then Exit; // **KCM** test this! 4073 4175 with FEditBox do x := Copy(Text, 1, SelStart); 4074 4176 FLastInput := x; … … 4079 4181 SelectIndex := FListBox.SelectString(x); 4080 4182 if UniqueAutoComplete then 4081 SelectIndex := FListBox.VerifyUnique(SelectIndex, x);4183 SelectIndex := FListBox.VerifyUnique(SelectIndex, x); 4082 4184 if FListItemsOnly and (SelectIndex < 0) and (x <> '') then 4083 4185 begin … … 4086 4188 SelectIndex := FListBox.SelectString(x); 4087 4189 FEditBox.Text := GetEditBoxText(SelectIndex); 4088 if (not FListBox.FCheckBoxes) then4190 if (not FListBox.FCheckBoxes) then 4089 4191 SendMessage(FEditBox.Handle, EM_SETSEL, Length(FEditBox.Text), Length(x)); 4090 4192 FFromSelf := False; 4091 Exit; 4193 Exit; // OnChange not called in this case 4092 4194 end; 4093 4195 FFromSelf := True; … … 4096 4198 FEditBox.Text := GetEditBoxText(SelectIndex); 4097 4199 FLastFound := x; 4098 if (not FListBox.FCheckBoxes) then4200 if (not FListBox.FCheckBoxes) then 4099 4201 SendMessage(FEditBox.Handle, EM_SETSEL, Length(FEditBox.Text), Length(x)); 4100 4202 end else 4101 4203 begin 4102 if (FListBox.CheckBoxes) then4204 if (FListBox.CheckBoxes) then 4103 4205 FEditBox.Text := GetEditBoxText(SelectIndex) 4104 4206 else 4105 FEditBox.Text := x; 4207 FEditBox.Text := x; // no match, so don't set FLastFound 4106 4208 FEditBox.SelStart := Length(x); 4107 4209 end; 4108 4210 FFromSelf := False; 4109 if (not FListBox.FCheckBoxes) then4211 if (not FListBox.FCheckBoxes) then 4110 4212 if Assigned(FOnChange) then FOnChange(Self); 4111 4213 end; … … 4146 4248 begin 4147 4249 FFromSelf := True; 4148 FListBox.FFocusIndex := FListBox.ItemIndex; 4250 FListBox.FFocusIndex := FListBox.ItemIndex; // FFocusIndex used so ItemTip doesn't flash 4149 4251 FEditBox.Text := GetEditBoxText(FListBox.ItemIndex); 4150 4252 FLastFound := FEditBox.Text; … … 4152 4254 // not sure why this must be posted (put at the back of the message queue), but for some 4153 4255 // reason FEditBox.SelectAll selects successfully then deselects on exiting this procedure 4154 if (not FListBox.FCheckBoxes) then4256 if (not FListBox.FCheckBoxes) then 4155 4257 PostMessage(FEditBox.Handle, EM_SETSEL, 0, Length(FEditBox.Text)); 4156 4258 FEditBox.SetFocus; 4157 4259 end; 4158 4260 if Assigned(FOnClick) then FOnClick(Self); 4159 if (not FListBox.FCheckBoxes) then4160 if Assigned(FOnChange) then FOnChange(Self); 4261 if (not FListBox.FCheckBoxes) then 4262 if Assigned(FOnChange) then FOnChange(Self); // click causes both click & change events 4161 4263 end; 4162 4264 … … 4170 4272 { passed selected navigation keys to listbox, applies special handling to backspace and F4 } 4171 4273 var 4172 i, iPos: Integer;4173 x, AString: string;4274 i, iPos: Integer; 4275 x, AString: string; 4174 4276 begin 4175 4277 // special case: when default action taken (RETURN) make sure FwdChangeDelayed is called first 4176 4278 if (Key = VK_RETURN) and FListBox.LongList and FChangePending then FwdChangeDelayed; 4177 StopKeyTimer; 4279 StopKeyTimer; // stop timer after control keys so in case an exit event is triggered 4178 4280 if Assigned(FOnKeyDown) then FOnKeyDown(Self, Key, Shift); 4179 if Key in [VK_PRIOR, VK_NEXT, VK_UP, VK_DOWN] then 4281 if Key in [VK_PRIOR, VK_NEXT, VK_UP, VK_DOWN] then // navigation 4180 4282 begin 4181 4283 if (FStyle = orcsDropDown) and not DroppedDown then DroppedDown := True; … … 4192 4294 if iPos > -1 then 4193 4295 begin 4194 FListBox.FFocusIndex := iPos -1;4296 FListBox.FFocusIndex := iPos - 1; 4195 4297 FListBox.ItemIndex := FListBox.FFocusIndex; 4196 4298 end; … … 4199 4301 FListBox.Perform(WM_KEYDOWN, Key, 1); 4200 4302 end; 4201 if Key in [VK_LBUTTON, VK_RETURN, VK_PRIOR, VK_NEXT, VK_UP, VK_DOWN] then 4303 if Key in [VK_LBUTTON, VK_RETURN, VK_PRIOR, VK_NEXT, VK_UP, VK_DOWN] then // select item 4202 4304 begin 4203 4305 FListBox.Perform(WM_KEYDOWN, VK_LBUTTON, 1); … … 4206 4308 begin 4207 4309 FEditBox.Text := GetEditBoxText(FListBox.ItemIndex); 4208 FLastFound := FEditBox.Text; 4310 FLastFound := FEditBox.Text; //kcm 4209 4311 end; 4210 4312 FFromSelf := False; … … 4212 4314 // tell parent about RETURN, ESCAPE so that the default action is taken 4213 4315 if Key in [VK_RETURN, VK_ESCAPE, VK_TAB] then SendMessage(Parent.Handle, CN_KEYDOWN, Key, 0); 4214 if Key = VK_BACK then 4316 if Key = VK_BACK then // backspace 4215 4317 begin 4216 4318 FFromSelf := True; … … 4218 4320 i := FEditBox.SelStart; 4219 4321 Delete(x, i + 1, Length(x)); 4220 if (FListBox.FCheckBoxes) then4322 if (FListBox.FCheckBoxes) then 4221 4323 FEditBox.Text := GetEditBoxText(ItemIndex) 4222 4324 else … … 4295 4397 { for DropDown combo, display the listbox at the appropriate full screen coordinates } 4296 4398 const 4297 MIN_ITEMS = 3; 4399 MIN_ITEMS = 3; // minimum visible items for long list 4298 4400 var 4299 4401 ScreenPoint: TPoint; … … 4308 4410 if FListBox.LongList 4309 4411 then DropDownCnt := HigherOf(FDropDownCount, MIN_ITEMS) 4310 4412 else DropDownCnt := LowerOf(FDropDownCount, FListBox.Items.Count); 4311 4413 FListBox.SetBounds(0, 0, Width, (FListBox.ItemHeight * DropDownCnt) + CBO_CXFRAME); 4312 4414 // need to make this smart enough to drop the list UP when necessary *** … … 4314 4416 4315 4417 PnlHeight := FListBox.Height; 4316 if (FListBox.FCheckBoxes) then4418 if (FListBox.FCheckBoxes) then 4317 4419 inc(PnlHeight, CheckComboBtnHeight); 4318 4420 FDropPanel.SetBounds(ScreenPoint.X, ScreenPoint.Y, FListBox.Width, PnlHeight); 4319 if (FListBox.FCheckBoxes) then4421 if (FListBox.FCheckBoxes) then 4320 4422 begin 4321 4423 FDropPanel.ResetButtons; … … 4326 4428 FDropPanel.BringToFront; 4327 4429 if FListBox.FScrollBar <> nil then FListBox.FScrollBar.BringToFront; 4328 if not FFromDropBtn then FListBox.MouseCapture := True; 4430 if not FFromDropBtn then FListBox.MouseCapture := True; // otherwise ButtonUp captures 4329 4431 end else 4330 4432 begin … … 4334 4436 FDropPanel.Hide; 4335 4437 DropDownStatusChanged(FALSE); 4336 if (FListBox.FCheckBoxes) and (assigned(FOnChange)) and4438 if (FListBox.FCheckBoxes) and (assigned(FOnChange)) and 4337 4439 (FCheckedState <> FListBox.GetCheckedString) then 4338 4440 FOnChange(Self); … … 4346 4448 begin 4347 4449 SendMessage(FEditBox.Handle, EM_GETRECT, 0, LongInt(@Loc)); 4348 Loc.Bottom := ClientHeight + 1; 4450 Loc.Bottom := ClientHeight + 1; // +1 is workaround for windows paint bug 4349 4451 if FStyle = orcsDropDown then 4350 4452 begin 4351 Loc.Right := ClientWidth - FDropBtn.Width - CBO_CXFRAME; 4352 if (FTemplateField) then4353 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); 4354 4456 end 4355 4457 else 4356 Loc.Right := ClientWidth - CBO_CXFRAME; 4458 Loc.Right := ClientWidth - CBO_CXFRAME; // edit in full edit box 4357 4459 Loc.Top := 0; 4358 if (FTemplateField) then4460 if (FTemplateField) then 4359 4461 Loc.Left := 2 4360 4462 else … … 4383 4485 if Value = -1 then FFocusIndex := -1 else FocusIndex := Value; 4384 4486 uItemTip.Hide; 4385 if (FListBox.CheckBoxes) then4487 if (FListBox.CheckBoxes) then 4386 4488 SetEditText(GetEditBoxText(ItemIndex)) 4387 4489 else … … 4430 4532 FListBox.FParentCombo := nil; 4431 4533 FListBox.Parent := Self; 4432 if FListBox.FScrollBar <> nil then FListBox.FScrollBar.Parent := Self; 4534 if FListBox.FScrollBar <> nil then FListBox.FScrollBar.Parent := Self; // if long 4433 4535 FListBox.Visible := True; 4434 4536 end else 4435 4537 begin 4436 4538 FDropBtn := TBitBtn.Create(Self); 4437 if (assigned(FEditPanel) and (csDesigning in ComponentState)) then4539 if (assigned(FEditPanel) and (csDesigning in ComponentState)) then 4438 4540 FEditPanel.ControlStyle := FEditPanel.ControlStyle + [csAcceptsControls]; 4439 4541 FDropBtn.Parent := FEditBox; 4440 if (assigned(FEditPanel) and (csDesigning in ComponentState)) then4542 if (assigned(FEditPanel) and (csDesigning in ComponentState)) then 4441 4543 FEditPanel.ControlStyle := FEditPanel.ControlStyle - [csAcceptsControls]; 4442 4544 LoadComboBoxImage; … … 4454 4556 FListBox.Parent := FDropPanel; 4455 4557 ClearDropDownStatus; 4456 if FListBox.FScrollBar <> nil then FListBox.FScrollBar.Parent := FDropPanel; 4558 if FListBox.FScrollBar <> nil then FListBox.FScrollBar.Parent := FDropPanel; // if long 4457 4559 end else 4458 4560 begin … … 4718 4820 procedure TORComboBox.SetColor(Value: TColor); 4719 4821 begin 4720 if (not FListBox.CheckBoxes) then4822 if (not FListBox.CheckBoxes) then 4721 4823 FEditBox.Color := Value; 4722 4824 FListBox.Color := Value; … … 4795 4897 procedure TORComboBox.SetText(const Value: string); 4796 4898 begin 4797 FEditBox.Text := Value; 4899 FEditBox.Text := Value; // kcm ??? 4798 4900 end; 4799 4901 … … 4825 4927 procedure TORComboBox.SetCheckBoxes(const Value: boolean); 4826 4928 begin 4827 if (FListBox.FCheckBoxes <> Value) then4929 if (FListBox.FCheckBoxes <> Value) then 4828 4930 begin 4829 4931 FListBox.SetCheckBoxes(Value); 4830 if (assigned(FDropPanel)) then4932 if (assigned(FDropPanel)) then 4831 4933 FDropPanel.UpdateButtons; 4832 4934 FEditBox.Visible := FALSE; 4833 4935 try 4834 if (Value) then4936 if (Value) then 4835 4937 begin 4836 4938 SetListItemsOnly(TRUE); … … 4844 4946 FEditPanel.BorderWidth := 1; 4845 4947 FEditBox.Parent := FEditPanel; 4846 if (csDesigning in ComponentState) then4948 if (csDesigning in ComponentState) then 4847 4949 FEditPanel.ControlStyle := FEditPanel.ControlStyle - [csAcceptsControls]; 4848 4950 end … … 4865 4967 begin 4866 4968 FListBox.SetChecked(Index, Value); 4867 if (assigned(FDropPanel)) then4969 if (assigned(FDropPanel)) then 4868 4970 FDropPanel.UpdateButtons; 4869 if (Value) then4971 if (Value) then 4870 4972 SetListItemsOnly(TRUE); 4871 4973 end; … … 4886 4988 4887 4989 begin 4888 if (assigned(FDropPanel)) then4990 if (assigned(FDropPanel)) then 4889 4991 begin 4890 4992 btn := FDropPanel.GetButton(OKBtn); 4891 if (assigned(Btn)) then4993 if (assigned(Btn)) then 4892 4994 Btn.Down := TRUE; 4893 4995 end; 4894 if (not OKBtn) then FListBox.SetCheckedString(FCheckedState);4895 if (AutoClose) then4996 if (not OKBtn) then FListBox.SetCheckedString(FCheckedState); 4997 if (AutoClose) then 4896 4998 begin 4897 4999 FListBox.FDontClose := FALSE; … … 4913 5015 procedure TORComboBox.SetCheckBoxEditColor(const Value: TColor); 4914 5016 begin 4915 if (FCheckBoxEditColor <> Value) then5017 if (FCheckBoxEditColor <> Value) then 4916 5018 begin 4917 5019 FCheckBoxEditColor := Value; 4918 if (FListBox.FCheckBoxes) then5020 if (FListBox.FCheckBoxes) then 4919 5021 FEditBox.Color := FCheckBoxEditColor; 4920 5022 end; … … 4923 5025 procedure TORComboBox.SetListItemsOnly(const Value: Boolean); 4924 5026 begin 4925 if (FListItemsOnly <> Value) then5027 if (FListItemsOnly <> Value) then 4926 5028 begin 4927 5029 FListItemsOnly := Value; 4928 if (not Value) then5030 if (not Value) then 4929 5031 SetCheckBoxes(FALSE); 4930 5032 end; … … 4939 5041 procedure TORComboBox.SetTemplateField(const Value: boolean); 4940 5042 begin 4941 if (FTemplateField <> Value) then5043 if (FTemplateField <> Value) then 4942 5044 begin 4943 5045 FTemplateField := Value; 4944 if (Value) then5046 if (Value) then 4945 5047 begin 4946 5048 SetStyle(orcsDropDown); … … 4985 5087 4986 5088 begin 4987 if (FListBox.FCheckBoxes) then5089 if (FListBox.FCheckBoxes) then 4988 5090 begin 4989 5091 Result := ''; 4990 5092 cnt := 0; 4991 for i := 0 to FListBox.Items.Count -1 do4992 begin 4993 if (FListBox.Checked[i]) then5093 for i := 0 to FListBox.Items.Count - 1 do 5094 begin 5095 if (FListBox.Checked[i]) then 4994 5096 begin 4995 5097 inc(cnt); 4996 if (Result <> '') then5098 if (Result <> '') then 4997 5099 Result := Result + ', '; 4998 5100 Result := Result + FListBox.GetDisplayText(i); 4999 5101 end; 5000 5102 end; 5001 if (assigned(FOnCheckedText)) then5103 if (assigned(FOnCheckedText)) then 5002 5104 FOnCheckedText(FListBox, cnt, Result); 5003 5105 end … … 5008 5110 procedure TORComboBox.UpdateCheckEditBoxText; 5009 5111 begin 5010 if (FListBox.FCheckBoxes) then5112 if (FListBox.FCheckBoxes) then 5011 5113 begin 5012 5114 FFromSelf := TRUE; … … 5020 5122 begin 5021 5123 UpdateCheckEditBoxText; 5022 if (FStyle <> orcsDropDown) and (assigned(FOnChange)) then5124 if (FStyle <> orcsDropDown) and (assigned(FOnChange)) then 5023 5125 FOnChange(Self); 5024 5126 end; … … 5076 5178 begin 5077 5179 if FSizes <> nil then with FSizes do for i := 0 to Count - 1 do 5078 begin5079 SizeRatio := Items[i];5080 SizeRatio.Free;5081 end;5180 begin 5181 SizeRatio := Items[i]; 5182 SizeRatio.Free; 5183 end; 5082 5184 FSizes.Free; 5083 5185 inherited Destroy; 5084 5186 end; 5085 5187 5086 procedure TORAutoPanel.BuildSizes( 5087 var 5088 i, H,W: Integer;5188 procedure TORAutoPanel.BuildSizes(Control: TWinControl); 5189 var 5190 i, H, W: Integer; 5089 5191 SizeRatio: TSizeRatio; 5090 5192 Child: TControl; … … 5097 5199 Child := Control.Controls[i]; 5098 5200 with Child do 5099 SizeRatio := TSizeRatio.Create(Left /W, Top/H, Width/W, Height/H);5100 FSizes.Add(SizeRatio); 5201 SizeRatio := TSizeRatio.Create(Left / W, Top / H, Width / W, Height / H); 5202 FSizes.Add(SizeRatio); //FSizes is in tree traversal order. 5101 5203 //TGroupBox is currently the only type of container that is having these 5102 5204 //resize problems … … 5110 5212 begin 5111 5213 inherited Loaded; 5112 if csDesigning in ComponentState then Exit; 5214 if csDesigning in ComponentState then Exit; // only want auto-resizing at run time 5113 5215 FSizes := TList.Create; 5114 5216 BuildSizes(Self); 5115 5217 end; 5116 5218 5117 procedure TORAutoPanel.DoResize( 5118 var 5119 i, H,W: Integer;5219 procedure TORAutoPanel.DoResize(Control: TWinControl; var CurrentIndex: Integer); 5220 var 5221 i, H, W: Integer; 5120 5222 SizeRatio: TSizeRatio; 5121 5223 Child: TControl; … … 5132 5234 with SizeRatio do begin 5133 5235 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) 5135 5237 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)); 5137 5239 end; 5138 5240 if Child is TGroupBox then … … 5147 5249 begin 5148 5250 inherited Resize; 5149 if csDesigning in ComponentState then Exit; 5251 if csDesigning in ComponentState then Exit; // only want auto-resizing at run time 5150 5252 i := 0; 5151 DoResize( 5253 DoResize(Self, i); 5152 5254 end; 5153 5255 … … 5191 5293 Flags := DT_EXPANDTABS or DT_CALCRECT; 5192 5294 if FWordWrap then Flags := Flags or DT_WORDBREAK; 5193 DoDrawText(ARect, Flags); 5295 DoDrawText(ARect, Flags); // returns size of text rect 5194 5296 Canvas.Handle := 0; 5195 5297 ReleaseDC(0, DC); … … 5227 5329 ARect := ClientRect; 5228 5330 Inc(ARect.Left, FHorzOffset); 5229 Inc(ARect.Top, 5331 Inc(ARect.Top, FVertOffset); 5230 5332 Flags := DT_EXPANDTABS or DT_NOPREFIX or DT_LEFT; 5231 5333 if FWordWrap then Flags := Flags or DT_WORDBREAK; … … 5246 5348 begin 5247 5349 if Value 5248 then ControlStyle := ControlStyle - [csOpaque] 5249 else ControlStyle := ControlStyle + [csOpaque];// transparent = false5350 then ControlStyle := ControlStyle - [csOpaque] // transparent = true 5351 else ControlStyle := ControlStyle + [csOpaque]; // transparent = false 5250 5352 Invalidate; 5251 5353 end; … … 5318 5420 inherited CreateParams(Params); 5319 5421 Params.Style := Params.Style or ButtonAlignment[FAlignment] or 5320 5321 5422 ButtonLayout[FLayout] or 5423 ButtonWordWrap[FWordWrap]; 5322 5424 end; 5323 5425 5324 5426 procedure TORAlignButton.SetAlignment(const Value: TAlignment); 5325 5427 begin 5326 if (FAlignment <> Value) then5428 if (FAlignment <> Value) then 5327 5429 begin 5328 5430 FAlignment := Value; … … 5333 5435 procedure TORAlignButton.SetLayout(const Value: TTextLayout); 5334 5436 begin 5335 if (FLayout <> Value) then5437 if (FLayout <> Value) then 5336 5438 begin 5337 5439 FLayout := Value; … … 5342 5444 procedure TORAlignButton.SetWordWrap(const Value: boolean); 5343 5445 begin 5344 if (FWordWrap <> Value) then5446 if (FWordWrap <> Value) then 5345 5447 begin 5346 5448 FWordWrap := Value; … … 5359 5461 MakeVisible; 5360 5462 R := DisplayRect(FALSE); 5361 if (R.Top < 0) then5463 if (R.Top < 0) then 5362 5464 TreeView.TopItem := Self 5363 5465 else 5364 if(R.Bottom > TreeView.ClientHeight) then5365 begin5366 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; 5371 5473 end; 5372 5474 … … 5397 5499 function TORTreeNode.GetText: string; 5398 5500 begin 5399 Result := Inherited Text;5501 Result := inherited Text; 5400 5502 end; 5401 5503 … … 5423 5525 begin 5424 5526 ORCtrls.SetPiece(FStringData, FDelim, PieceNum, NewPiece); 5425 if (PieceNum = FPiece) then5527 if (PieceNum = FPiece) then 5426 5528 Text := NewPiece; 5427 5529 end; … … 5430 5532 procedure TORTreeNode.SetStringData(const Value: string); 5431 5533 begin 5432 if (FStringData <> Value) then5534 if (FStringData <> Value) then 5433 5535 begin 5434 5536 FStringData := Value; … … 5447 5549 procedure TORTreeNode.UpdateText(const Value: string; UpdateData: boolean); 5448 5550 begin 5449 Inherited Text := Value;5551 inherited Text := Value; 5450 5552 Caption := Text; 5451 if (UpdateData) then5553 if (UpdateData) then 5452 5554 with GetORTreeView do 5453 5555 begin … … 5457 5559 end; 5458 5560 5459 function CalcShortName( 5561 function CalcShortName(LongName: string; PrevLongName: string): string; 5460 5562 var 5461 5563 WordBorder: integer; … … 5465 5567 for j := 1 to Length(LongName) do 5466 5568 begin 5467 if (LongName[j] = ' ') or ((j > 1) and (LongName[j -1] = ' ')) or5569 if (LongName[j] = ' ') or ((j > 1) and (LongName[j - 1] = ' ')) or 5468 5570 ((j = Length(LongName)) and (j = Length(PrevLongName)) and (LongName[j] = PrevLongName[j])) then 5469 5571 WordBorder := j; … … 5474 5576 result := LongName 5475 5577 else if WordBorder = Length(LongName) then 5476 result := 'Same as above (' +LongName+')'5578 result := 'Same as above (' + LongName + ')' 5477 5579 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)) + ')'; 5479 5581 end; 5480 5582 … … 5489 5591 OnNodeCaptioning(self, TheCaption); 5490 5592 if ShortNodeCaptions and (Self.GetPrevSibling <> nil) then 5491 TheCaption := CalcShortName( 5593 TheCaption := CalcShortName(TheCaption, Self.GetPrevSibling.Text); 5492 5594 end; 5493 5595 FCaption := TheCaption; … … 5503 5605 begin 5504 5606 DoInh := TRUE; 5505 if (assigned(FOnDragging)) then5607 if (assigned(FOnDragging)) then 5506 5608 begin 5507 5609 with Message do … … 5516 5618 end; 5517 5619 FOnDragging(Self, DNode, DoInh); 5518 if (not DoInh) then5620 if (not DoInh) then 5519 5621 begin 5520 5622 Message.Result := 1; … … 5525 5627 end; 5526 5628 end; 5527 if (DoInh) then inherited;5629 if (DoInh) then inherited; 5528 5630 end; 5529 5631 … … 5537 5639 begin 5538 5640 Result := TORTreeNode.Create(Items); 5539 if Assigned( OnAddition) then5641 if Assigned(OnAddition) then 5540 5642 OnAddition(self, Result); 5541 5643 end; 5542 5644 5543 5645 function TORTreeView.FindPieceNode(Value: string; 5544 5646 ParentDelim: Char = #0; StartNode: TTreeNode = nil): TORTreeNode; 5545 5647 begin 5546 5648 Result := FindPieceNode(Value, FPiece, ParentDelim, StartNode); … … 5548 5650 5549 5651 function TORTreeView.FindPieceNode(Value: string; APiece: integer; 5550 5652 ParentDelim: Char = #0; StartNode: TTreeNode = nil): TORTreeNode; 5551 5653 var 5552 5654 StartIdx, i: integer; … … 5555 5657 begin 5556 5658 if assigned(StartNode) then 5557 StartIdx := StartNode.AbsoluteIndex +15659 StartIdx := StartNode.AbsoluteIndex + 1 5558 5660 else 5559 5661 StartIdx := 0; 5560 5662 Result := nil; 5561 for i := StartIdx to Items.Count -1 do5663 for i := StartIdx to Items.Count - 1 do 5562 5664 begin 5563 5665 Node := (Items[i] as TORTreeNode); 5564 if (GetNodeID(Node, APiece, ParentDelim) = Value) then5666 if (GetNodeID(Node, APiece, ParentDelim) = Value) then 5565 5667 begin 5566 5668 Result := Node; … … 5576 5678 begin 5577 5679 Result := ''; 5578 for i := 0 to Items.Count -1 do5680 for i := 0 to Items.Count - 1 do 5579 5681 begin 5580 5682 with (Items[i] as TORTreeNode) do 5581 5683 begin 5582 if (Expanded) then5684 if (Expanded) then 5583 5685 begin 5584 if (Result <> '') then5686 if (Result <> '') then 5585 5687 Result := Result + FDelim; 5586 5688 Result := Result + GetNodeID(TORTreeNode(Items[i]), APiece, ParentDelim); … … 5596 5698 5597 5699 procedure TORTreeView.SetExpandedIDStr(APiece: integer; ParentDelim: char; 5598 5700 const Value: string); 5599 5701 var 5600 5702 i: integer; … … 5614 5716 repeat 5615 5717 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); 5618 5720 Node := FindPieceNode(Srch, APiece, ParentDelim); 5619 if (assigned(Node)) then5721 if (assigned(Node)) then 5620 5722 Node.Expand(FALSE); 5621 Nlist := copy(NList, i+1,MaxInt);5622 until (NList = '');5723 Nlist := copy(NList, i + 1, MaxInt); 5724 until (NList = ''); 5623 5725 TopItem := Top; 5624 5726 Selected := Sel; … … 5640 5742 procedure TORTreeView.RenameNodes; 5641 5743 var 5642 i: integer;5643 5644 begin 5645 if (FDelim <> #0) and (FPiece > 0) then5646 begin 5647 for i := 0 to Items.Count -1 do5744 i: integer; 5745 5746 begin 5747 if (FDelim <> #0) and (FPiece > 0) then 5748 begin 5749 for i := 0 to Items.Count - 1 do 5648 5750 with (Items[i] as TORTreeNode) do 5649 5751 UpdateText(Piece(FStringData, FDelim, FPiece), FALSE); … … 5653 5755 procedure TORTreeView.SetNodeDelim(const Value: Char); 5654 5756 begin 5655 if (FDelim <> Value) then5757 if (FDelim <> Value) then 5656 5758 begin 5657 5759 FDelim := Value; … … 5662 5764 procedure TORTreeView.SetHorzScrollPos(Value: integer); 5663 5765 begin 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); 5666 5768 end; 5667 5769 5668 5770 procedure TORTreeView.SetNodePiece(const Value: integer); 5669 5771 begin 5670 if (FPiece <> Value) then5772 if (FPiece <> Value) then 5671 5773 begin 5672 5774 FPiece := Value; … … 5677 5779 procedure TORTreeView.SetVertScrollPos(Value: integer); 5678 5780 begin 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); 5681 5783 end; 5682 5784 … … 5690 5792 ParentDelim: Char): string; 5691 5793 begin 5692 if (assigned(Node)) then5794 if (assigned(Node)) then 5693 5795 begin 5694 5796 Result := Piece(Node.FStringData, FDelim, APiece); 5695 if ((ParentDelim <> #0) and (ParentDelim <> FDelim) and (assigned(Node.Parent))) then5797 if ((ParentDelim <> #0) and (ParentDelim <> FDelim) and (assigned(Node.Parent))) then 5696 5798 Result := Result + ParentDelim + GetNodeID(Node.Parent, APiece, ParentDelim); 5697 5799 end … … 5742 5844 function RStr(Value: integer): string; 5743 5845 begin 5744 if (Value <> -1) then5846 if (Value <> -1) then 5745 5847 Result := IntToStr(Value) 5746 5848 else … … 5751 5853 begin 5752 5854 Result := RStr(FCheckedEnabledIndex) + 5753 5754 5755 5756 5757 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 := ''; 5760 5862 end; 5761 5863 5762 5864 procedure TORCBImageIndexes.SetIdxString(Value: string); 5763 5865 var 5764 i, j,v: integer;5765 Sub: String;5766 5767 begin 5768 if (Value = '') then5769 begin 5770 FCheckedEnabledIndex 5771 FGrayedEnabledIndex 5772 FUncheckedEnabledIndex 5773 FCheckedDisabledIndex 5774 FGrayedDisabledIndex 5866 i, j, v: integer; 5867 Sub: string; 5868 5869 begin 5870 if (Value = '') then 5871 begin 5872 FCheckedEnabledIndex := -1; 5873 FGrayedEnabledIndex := -1; 5874 FUncheckedEnabledIndex := -1; 5875 FCheckedDisabledIndex := -1; 5876 FGrayedDisabledIndex := -1; 5775 5877 FUncheckedDisabledIndex := -1; 5776 5878 end … … 5780 5882 Sub := Value; 5781 5883 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); 5785 5887 case i of 5786 0: FCheckedEnabledIndex 5787 1: FGrayedEnabledIndex 5788 2: FUncheckedEnabledIndex 5789 3: FCheckedDisabledIndex 5790 4: FGrayedDisabledIndex 5888 0: FCheckedEnabledIndex := v; 5889 1: FGrayedEnabledIndex := v; 5890 2: FUncheckedEnabledIndex := v; 5891 3: FCheckedDisabledIndex := v; 5892 4: FGrayedDisabledIndex := v; 5791 5893 5: FUncheckedDisabledIndex := v; 5792 5894 end; 5793 5895 inc(i); 5794 Sub := copy(Sub, j+1,MaxInt);5795 until (Sub = '');5896 Sub := copy(Sub, j + 1, MaxInt); 5897 until (Sub = ''); 5796 5898 end; 5797 5899 end; … … 5799 5901 procedure TORCBImageIndexes.ImageListChanged(Sender: TObject); 5800 5902 begin 5801 if (Owner is TWinControl) then5903 if (Owner is TWinControl) then 5802 5904 (Owner as TWinControl).Invalidate; 5803 5905 end; … … 5811 5913 procedure TORCBImageIndexes.SetCheckedDisabledIndex(const Value: integer); 5812 5914 begin 5813 if (FCheckedDisabledIndex <> Value) then5915 if (FCheckedDisabledIndex <> Value) then 5814 5916 begin 5815 5917 FCheckedDisabledIndex := Value; … … 5820 5922 procedure TORCBImageIndexes.SetCheckedEnabledIndex(const Value: integer); 5821 5923 begin 5822 if (FCheckedEnabledIndex <> Value) then5924 if (FCheckedEnabledIndex <> Value) then 5823 5925 begin 5824 5926 FCheckedEnabledIndex := Value; … … 5829 5931 procedure TORCBImageIndexes.SetGrayedDisabledIndex(const Value: integer); 5830 5932 begin 5831 if (FGrayedDisabledIndex <> Value) then5933 if (FGrayedDisabledIndex <> Value) then 5832 5934 begin 5833 5935 FGrayedDisabledIndex := Value; … … 5838 5940 procedure TORCBImageIndexes.SetGrayedEnabledIndex(const Value: integer); 5839 5941 begin 5840 if (FGrayedEnabledIndex <> Value) then5942 if (FGrayedEnabledIndex <> Value) then 5841 5943 begin 5842 5944 FGrayedEnabledIndex := Value; … … 5847 5949 procedure TORCBImageIndexes.SetUncheckedDisabledIndex(const Value: integer); 5848 5950 begin 5849 if (FUncheckedDisabledIndex <> Value) then5951 if (FUncheckedDisabledIndex <> Value) then 5850 5952 begin 5851 5953 FUncheckedDisabledIndex := Value; … … 5856 5958 procedure TORCBImageIndexes.SetUncheckedEnabledIndex(const Value: integer); 5857 5959 begin 5858 if (FUncheckedEnabledIndex <> Value) then5960 if (FUncheckedEnabledIndex <> Value) then 5859 5961 begin 5860 5962 FUncheckedEnabledIndex := Value; … … 5889 5991 destructor TORCheckBox.Destroy; 5890 5992 begin 5891 if (FCustomImagesOwned) then FCustomImages.Free;5993 if (FCustomImagesOwned) then FCustomImages.Free; 5892 5994 FCanvas.Free; 5893 5995 inherited; … … 5917 6019 procedure TORCheckBox.Toggle; 5918 6020 begin 5919 if (FGrayedToChecked) then6021 if (FGrayedToChecked) then 5920 6022 begin 5921 6023 case State of … … 5969 6071 5970 6072 procedure TORCheckBox.GetDrawData(CanvasHandle: HDC; var Bitmap: TBitmap; 5971 5972 5973 6073 var FocRect, Rect: TRect; 6074 var DrawOptions: UINT; 6075 var TempBitMap: boolean); 5974 6076 var 5975 6077 i, l, TxtHeight, TxtWidth, AWidth: Integer; … … 5983 6085 FSingleLine := TRUE; 5984 6086 5985 if (not (csDestroying in ComponentState)) then6087 if (not (csDestroying in ComponentState)) then 5986 6088 begin 5987 6089 with FCustomImages do … … 5993 6095 begin 5994 6096 CustomImgIdx := -1; 5995 if (assigned(FImages)) then6097 if (assigned(FImages)) then 5996 6098 begin 5997 if (Enabled or (csDesigning in ComponentState)) then6099 if (Enabled or (csDesigning in ComponentState)) then 5998 6100 begin 5999 6101 case State of 6000 cbChecked: 6102 cbChecked: CustomImgIdx := FCheckedEnabledIndex; 6001 6103 cbUnChecked: CustomImgIdx := FUncheckedEnabledIndex; 6002 cbGrayed: 6104 cbGrayed: CustomImgIdx := FGrayedEnabledIndex; 6003 6105 end; 6004 6106 end … … 6006 6108 begin 6007 6109 case State of 6008 cbChecked: 6110 cbChecked: CustomImgIdx := FCheckedDisabledIndex; 6009 6111 cbUnChecked: CustomImgIdx := FUncheckedDisabledIndex; 6010 cbGrayed: 6112 cbGrayed: CustomImgIdx := FGrayedDisabledIndex; 6011 6113 end; 6012 6114 end; 6013 if ((CustomImgIdx < 0) or (CustomImgIdx >= FImages.Count)) then6115 if ((CustomImgIdx < 0) or (CustomImgIdx >= FImages.Count)) then 6014 6116 CustomImgIdx := -1; 6015 6117 end; 6016 if (CustomImgIdx < 0) then6118 if (CustomImgIdx < 0) then 6017 6119 begin 6018 6120 ImgIdx := iiChecked; 6019 if (Enabled or (csDesigning in ComponentState)) then6121 if (Enabled or (csDesigning in ComponentState)) then 6020 6122 begin 6021 if (FRadioStyle) then6123 if (FRadioStyle) then 6022 6124 begin 6023 6125 if State = cbChecked then … … 6029 6131 begin 6030 6132 case State of 6031 cbChecked: 6133 cbChecked: ImgIdx := iiChecked; 6032 6134 cbUnChecked: ImgIdx := iiUnchecked; 6033 6135 cbGrayed: 6034 6136 begin 6035 6137 case FGrayedStyle of 6036 gsNormal: 6037 gsQuestionMark: 6138 gsNormal: ImgIdx := iiGrayed; 6139 gsQuestionMark: ImgIdx := iiQMark; 6038 6140 gsBlueQuestionMark: ImgIdx := iiBlueQMark; 6039 6141 end; … … 6044 6146 else 6045 6147 begin 6046 if (FRadioStyle) then6148 if (FRadioStyle) then 6047 6149 begin 6048 6150 if State = cbChecked then … … 6054 6156 begin 6055 6157 case State of 6056 cbChecked: 6158 cbChecked: ImgIdx := iiDisChecked; 6057 6159 cbUnChecked: ImgIdx := iiDisUnchecked; 6058 6160 cbGrayed: 6059 6161 begin 6060 if (FGrayedStyle = gsNormal) then6162 if (FGrayedStyle = gsNormal) then 6061 6163 ImgIdx := iiDisGrayed 6062 6164 else … … 6082 6184 Rect.Left := Bitmap.Width + 5; 6083 6185 6084 if (FWordWrap) then6186 if (FWordWrap) then 6085 6187 DrawOptions := DrawOptions or DT_WORDBREAK 6086 6188 else 6087 6189 DrawOptions := DrawOptions or DT_VCENTER or DT_SINGLELINE; 6088 6190 6089 if (FWordWrap) then6191 if (FWordWrap) then 6090 6192 begin 6091 6193 if Alignment = taLeftJustify then … … 6094 6196 Rect.Right := Width; 6095 6197 Rect.Top := 1; 6096 Rect.Bottom := Height +1;6198 Rect.Bottom := Height + 1; 6097 6199 dec(Rect.Right); 6098 6200 FocRect := Rect; 6099 6201 TxtHeight := DrawText(Handle, PChar(Caption), Length(Caption), FocRect, 6100 6202 DrawOptions or DT_CALCRECT); 6101 6203 FSingleLine := (TxtHeight = TextHeight(Caption)); 6102 6204 Rect.Bottom := Rect.Top + TxtHeight + 1; … … 6110 6212 l := length(Caption); 6111 6213 AWidth := TextWidth('&'); 6112 while (i < l) do6214 while (i < l) do 6113 6215 begin 6114 6216 inc(i); 6115 6217 // '&&' is an escape char that should display one '&' wide. 6116 6218 // This next part preserves the first '&' but drops all the others 6117 if (Copy(Caption, i,2)<>'&&') and (Copy(Caption,i,1)='&') then6118 dec(TxtWidth, AWidth);6219 if (Copy(Caption, i, 2) <> '&&') and (Copy(Caption, i, 1) = '&') then 6220 dec(TxtWidth, AWidth); 6119 6221 end; 6120 6222 Rect.Right := Rect.Left + TxtWidth; 6121 6223 TxtHeight := TextHeight(Caption); 6122 if (TxtHeight < Bitmap.Height) then6224 if (TxtHeight < Bitmap.Height) then 6123 6225 TxtHeight := Bitmap.Height; 6124 6226 Rect.Top := ((((ClientHeight - TxtHeight) * 5) - 5) div 10); … … 6143 6245 6144 6246 begin 6145 if (not (csDestroying in ComponentState)) then6247 if (not (csDestroying in ComponentState)) then 6146 6248 begin 6147 6249 GetDrawData(DrawItemStruct.hDC, Bitmap, FocusRect, R, DrawOptions, TempBitMap); … … 6160 6262 Font := Self.Font; 6161 6263 6162 if (Enabled or (csDesigning in ComponentState)) then6264 if (Enabled or (csDesigning in ComponentState)) then 6163 6265 begin 6164 6266 DrawText(Handle, PChar(Caption), Length(Caption), FocusRect, DrawOptions); … … 6166 6268 else 6167 6269 begin 6168 OldColor :=Font.Color;6270 OldColor := Font.Color; 6169 6271 try 6170 6272 if Ctl3D then … … 6175 6277 OffsetRect(FocusRect, -1, -1); 6176 6278 end; 6177 Font.Color :=clGrayText;6279 Font.Color := clGrayText; 6178 6280 DrawText(Handle, PChar(Caption), Length(Caption), FocusRect, DrawOptions); 6179 6281 finally 6180 Font.Color :=OldColor;6282 Font.Color := OldColor; 6181 6283 end; 6182 6284 … … 6185 6287 end; 6186 6288 6187 if ((DrawItemStruct.itemState and ODS_FOCUS) <> 0) then6289 if ((DrawItemStruct.itemState and ODS_FOCUS) <> 0) then 6188 6290 begin 6189 6291 InflateRect(FocusRect, 1, 1); 6190 if (FFocusOnBox) then6292 if (FFocusOnBox) then 6191 6293 //TempRect := Rect(0, 0, CheckWidth - 1, CheckWidth - 1) 6192 6294 TempRect := Rect(0, 0, CheckWidth + 2, CheckWidth + 5) … … 6205 6307 else 6206 6308 R.Left := 0; 6207 if (FWordWrap) then6208 R.Top := FocusRect.Top6309 if (FWordWrap) then 6310 R.Top := FocusRect.Top 6209 6311 else 6210 6312 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 6213 6315 end; 6214 6316 Draw(R.Left, R.Top, Bitmap); … … 6218 6320 end; 6219 6321 finally 6220 if (TempBitMap) then6322 if (TempBitMap) then 6221 6323 Bitmap.Free; 6222 6324 end; … … 6226 6328 procedure TORCheckBox.SetGrayedStyle(Value: TGrayedStyle); 6227 6329 begin 6228 if (FGrayedStyle <> Value) then6330 if (FGrayedStyle <> Value) then 6229 6331 begin 6230 6332 FGrayedStyle := Value; 6231 if (State = cbGrayed) then Invalidate;6333 if (State = cbGrayed) then Invalidate; 6232 6334 end; 6233 6335 end; … … 6241 6343 begin 6242 6344 inherited; 6243 if (FSizable) and (csDesigning in ComponentState) then6345 if (FSizable) and (csDesigning in ComponentState) then 6244 6346 AutoAdjustSize; 6245 6347 end; … … 6254 6356 Message.Result := 0; 6255 6357 6256 if (assigned(Parent) and (FGroupIndex <> 0)) then6358 if (assigned(Parent) and (FGroupIndex <> 0)) then 6257 6359 begin 6258 6360 Chk := Checked; 6259 if (Chk or (not FAllowAllUnchecked)) then6361 if (Chk or (not FAllowAllUnchecked)) then 6260 6362 begin 6261 6363 cnt := 0; 6262 for i := 0 to Parent.ControlCount -1 do6364 for i := 0 to Parent.ControlCount - 1 do 6263 6365 begin 6264 if (Parent.Controls[i] is TORCheckBox) then6366 if (Parent.Controls[i] is TORCheckBox) then 6265 6367 begin 6266 6368 cb := TORCheckBox(Parent.Controls[i]); 6267 if (cb <> Self) then6369 if (cb <> Self) then 6268 6370 begin 6269 if (cb.Checked and (cb.FGroupIndex = FGroupIndex)) then6371 if (cb.Checked and (cb.FGroupIndex = FGroupIndex)) then 6270 6372 begin 6271 6373 if Chk then … … 6277 6379 end; 6278 6380 end; 6279 if (not Chk) and (Cnt = 0) then6381 if (not Chk) and (Cnt = 0) then 6280 6382 Checked := TRUE; 6281 6383 end; … … 6287 6389 procedure TORCheckBox.SetWordWrap(const Value: boolean); 6288 6390 begin 6289 if (FWordWrap <> Value) then6391 if (FWordWrap <> Value) then 6290 6392 begin 6291 6393 FWordWrap := Value; … … 6297 6399 procedure TORCheckBox.SetAutoSize(Value: boolean); 6298 6400 begin 6299 if (FAutoSize <> Value) then6401 if (FAutoSize <> Value) then 6300 6402 begin 6301 6403 FAutoSize := Value; … … 6324 6426 6325 6427 begin 6326 if (FAutoSize and (([csDestroying, csLoading] * ComponentState) = [])) then6428 if (FAutoSize and (([csDestroying, csLoading] * ComponentState) = [])) then 6327 6429 begin 6328 6430 FSizable := TRUE; … … 6338 6440 ReleaseDC(0, DC); 6339 6441 end; 6340 if (FocusRect.Left <> R.Left) or6341 (FocusRect.Right <> R.Right) or6342 (FocusRect.Top <> R.Top) or6442 if (FocusRect.Left <> R.Left) or 6443 (FocusRect.Right <> R.Right) or 6444 (FocusRect.Top <> R.Top) or 6343 6445 (FocusRect.Bottom <> R.Bottom) or 6344 6446 (R.Right <> ClientRect.Right) or … … 6348 6450 if Alignment = taLeftJustify then 6349 6451 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); 6352 6454 end 6353 6455 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; 6357 6459 end; 6358 6460 end; … … 6366 6468 procedure TORCheckBox.SetCaption(const Value: TCaption); 6367 6469 begin 6368 if (inherited Caption <> Value) then6470 if (inherited Caption <> Value) then 6369 6471 begin 6370 6472 inherited Caption := Value; … … 6383 6485 begin 6384 6486 FGroupIndex := Value; 6385 if (Value <> 0) and (csDesigning in ComponentState) and (not (csLoading in ComponentState)) then6487 if (Value <> 0) and (csDesigning in ComponentState) and (not (csLoading in ComponentState)) then 6386 6488 SetRadioStyle(TRUE); 6387 6489 SyncAllowAllUnchecked; … … 6394 6496 6395 6497 begin 6396 if (assigned(Parent) and (FGroupIndex <> 0)) then6397 begin 6398 for i := 0 to Parent.ControlCount -1 do6399 begin 6400 if (Parent.Controls[i] is TORCheckBox) then6498 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 6401 6503 begin 6402 6504 cb := TORCheckBox(Parent.Controls[i]); 6403 if ((cb <> Self) and (cb.FGroupIndex = FGroupIndex)) then6505 if ((cb <> Self) and (cb.FGroupIndex = FGroupIndex)) then 6404 6506 cb.FAllowAllUnchecked := FAllowAllUnchecked; 6405 6507 end; … … 6422 6524 procedure TORCheckBox.SetAssociate(const Value: TControl); 6423 6525 begin 6424 if (FAssociate <> Value) then6425 begin 6426 if (assigned(FAssociate)) then6526 if (FAssociate <> Value) then 6527 begin 6528 if (assigned(FAssociate)) then 6427 6529 FAssociate.RemoveFreeNotification(Self); 6428 6530 FAssociate := Value; 6429 if (assigned(FAssociate)) then6531 if (assigned(FAssociate)) then 6430 6532 begin 6431 6533 FAssociate.FreeNotification(Self); … … 6451 6553 // lose the disabled glyph that is stored on that button for the combo box. 6452 6554 6453 if (Ctrl is TWinControl) and (csAcceptsControls in Ctrl.ControlStyle) then6454 begin 6455 for i := 0 to TWinControl(Ctrl).ControlCount -1 do6555 if (Ctrl is TWinControl) and (csAcceptsControls in Ctrl.ControlStyle) then 6556 begin 6557 for i := 0 to TWinControl(Ctrl).ControlCount - 1 do 6456 6558 begin 6457 6559 if DoCtrl then … … 6466 6568 6467 6569 begin 6468 if (assigned(FAssociate)) then6570 if (assigned(FAssociate)) then 6469 6571 EnableCtrl(FAssociate, FALSE); 6470 6572 end; … … 6474 6576 begin 6475 6577 inherited; 6476 if (AComponent = FAssociate) and (Operation = opRemove) then6578 if (AComponent = FAssociate) and (Operation = opRemove) then 6477 6579 FAssociate := nil; 6478 6580 end; … … 6518 6620 if (Mask and HDI_WIDTH) <> 0 then 6519 6621 begin 6520 if (Column[Item].MinWidth > 0) and (cxy < Column[Item].MinWidth) then6622 if (Column[Item].MinWidth > 0) and (cxy < Column[Item].MinWidth) then 6521 6623 cxy := Column[Item].MinWidth; 6522 if (Column[Item].MaxWidth > 0) and (cxy > Column[Item].MaxWidth) then6624 if (Column[Item].MaxWidth > 0) and (cxy > Column[Item].MaxWidth) then 6523 6625 cxy := Column[Item].MaxWidth; 6524 6626 Column[Item].Width := cxy; … … 6538 6640 with Message, TLVColumn(pointer(LParam)^) do 6539 6641 begin 6540 if (cx < Column[WParam].MinWidth) then6642 if (cx < Column[WParam].MinWidth) then 6541 6643 begin 6542 6644 NewW := Column[WParam].MinWidth; … … 6544 6646 idx := WParam; 6545 6647 end; 6546 if (cx > Column[WParam].MaxWidth) then6648 if (cx > Column[WParam].MaxWidth) then 6547 6649 begin 6548 6650 NewW := Column[WParam].MaxWidth; … … 6552 6654 end; 6553 6655 inherited; 6554 if (Changed) then6656 if (Changed) then 6555 6657 Column[idx].Width := NewW; 6556 6658 end; … … 6567 6669 with Message do 6568 6670 begin 6569 if (LParam < Column[WParam].MinWidth) then6671 if (LParam < Column[WParam].MinWidth) then 6570 6672 begin 6571 6673 LParam := Column[WParam].MinWidth; … … 6574 6676 idx := WParam; 6575 6677 end; 6576 if (LParam > Column[WParam].MaxWidth) then6678 if (LParam > Column[WParam].MaxWidth) then 6577 6679 begin 6578 6680 LParam := Column[WParam].MaxWidth; … … 6583 6685 end; 6584 6686 inherited; 6585 if (Changed) then6687 if (Changed) then 6586 6688 Column[idx].Width := NewW; 6587 6689 end; … … 6591 6693 destructor TORComboPanelEdit.Destroy; 6592 6694 begin 6593 if (assigned(FCanvas)) then6695 if (assigned(FCanvas)) then 6594 6696 FCanvas.Free; 6595 6697 inherited; … … 6603 6705 begin 6604 6706 inherited; 6605 if (FFocused) then6606 begin 6607 if (not assigned(FCanvas)) then6707 if (FFocused) then 6708 begin 6709 if (not assigned(FCanvas)) then 6608 6710 FCanvas := TControlCanvas.Create; 6609 6711 DC := GetWindowDC(Handle); … … 6620 6722 6621 6723 { TKeyClickPanel ----------------------------------------------------------------------------- } 6724 6622 6725 procedure TKeyClickPanel.KeyDown(var Key: Word; Shift: TShiftState); 6623 6726 begin … … 6692 6795 procedure TCaptionListBox.MoveFocusDown; 6693 6796 begin 6694 if ItemIndex < (Items.Count -1) then6797 if ItemIndex < (Items.Count - 1) then 6695 6798 Perform(LB_SETCARETINDEX, ItemIndex + 1, 0); 6696 6799 end; … … 6728 6831 VK_LEFT, VK_UP: MoveFocusUp; 6729 6832 VK_RIGHT, VK_DOWN: MoveFocusDown; 6730 6833 else inherited; 6731 6834 end 6732 6835 else inherited; … … 6735 6838 procedure TCaptionListBox.WMMouseMove(var Message: TWMMouseMove); 6736 6839 var 6737 i 6840 i: integer; 6738 6841 begin 6739 6842 inherited; … … 6760 6863 begin 6761 6864 if FRightClickSelect then with Message do 6762 begin6763 APoint := Point(XPos, YPos);6865 begin 6866 APoint := Point(XPos, YPos); 6764 6867 // if the mouse was clicked in the client area set ItemIndex... 6765 if PtInRect(ClientRect, APoint) then6766 begin6767 ItemIndex := ItemAtPos(APoint,True);6868 if PtInRect(ClientRect, APoint) then 6869 begin 6870 ItemIndex := ItemAtPos(APoint, True); 6768 6871 // ...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; 6779 6883 end; 6780 6884 end; 6781 6885 end; 6782 end;6783 6886 inherited; 6784 6887 end; … … 6916 7019 function TCaptionTreeView.GetCaption: string; 6917 7020 begin 6918 7021 result := inherited Caption; 6919 7022 end; 6920 7023 … … 7008 7111 begin 7009 7112 result := (ColCount - FixedCols) * (Row - FixedRows) + 7010 7113 (Col - FixedCols) + 1; 7011 7114 end; 7012 7115 … … 7022 7125 Row: integer); 7023 7126 begin 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; 7026 7129 end; 7027 7130 … … 7033 7136 (Key = VK_TAB) and (Shift <= [ssShift]) then 7034 7137 GoodNotifyWinEvent(EVENT_OBJECT_FOCUS, Handle, integer(OBJID_CLIENT), 7035 ColRowToIndex(Col, Row));7138 ColRowToIndex(Col, Row)); 7036 7139 end; 7037 7140 … … 7043 7146 end; 7044 7147 7045 function IsAMouseButtonDown 7148 function IsAMouseButtonDown: boolean; 7046 7149 begin 7047 7150 if Boolean(Hi(GetKeyState(VK_MBUTTON))) or 7048 7049 7151 Boolean(Hi(GetKeyState(VK_LBUTTON))) or 7152 Boolean(Hi(GetKeyState(VK_RBUTTON))) then 7050 7153 Result := true 7051 7154 else … … 7068 7171 end; 7069 7172 7070 function TORListBox.VerifyUnique(SelectIndex: Integer; iText: String): integer;7071 var 7072 i 7073 counter 7173 function TORListBox.VerifyUnique(SelectIndex: Integer; iText: string): integer; 7174 var 7175 i: integer; 7176 counter: integer; 7074 7177 begin 7075 7178 Result := SelectIndex; 7076 7077 7179 if LongList then 7180 begin 7078 7181 //Implemented for CQ: 10092, PSI-04-057 7079 7182 //asume long lists are alphabetically ordered... 7080 if CompareText(iText, Copy(DisplayText[SelectIndex+1], 1, Length(iText))) = 0 then7081 7082 7083 7084 7085 7086 for i := 0 to Items.Count-1 do7087 7088 7089 7090 Result := -1;7091 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; 7092 7195 FFocusIndex := Result; 7093 ItemIndex := Result; 7196 ItemIndex := Result; 7094 7197 end; 7095 7198 7096 7199 //This procedure sets the Text property equal to the TextToMatch parameter, then calls 7097 7200 //FwdChangeDelayed which will perform an auto-completion on the text. 7098 procedure TORComboBox.SetTextAutoComplete(TextToMatch: String); 7201 7202 procedure TORComboBox.SetTextAutoComplete(TextToMatch: string); 7099 7203 begin 7100 7204 Text := TextToMatch; … … 7121 7225 //uItemTip := TItemTip.Create(Application); // all listboxes share a single ItemTip window 7122 7226 uItemTipCount := 0; 7123 uNewStyle := Lo(GetVersion) >= 4; 7227 uNewStyle := Lo(GetVersion) >= 4; // True = Win95 interface, otherwise old interface 7124 7228 FillChar(ORCBImages, SizeOf(ORCBImages), 0); 7125 7229 … … 7129 7233 7130 7234 end. 7235
Note:
See TracChangeset
for help on using the changeset viewer.