home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1997 August / VPR9708A.ISO / D3TRIAL / INSTALL / DATA.Z / CONTROLS.INT < prev    next >
Text File  |  1997-03-21  |  27KB  |  745 lines

  1.  
  2. {*******************************************************}
  3. {                                                       }
  4. {       Delphi Visual Component Library                 }
  5. {                                                       }
  6. {       Copyright (c) 1995,97 Borland International     }
  7. {                                                       }
  8. {*******************************************************}
  9.  
  10. unit Controls;
  11.  
  12. {$P+,S-,W-,R-}
  13. {$C PRELOAD}
  14.  
  15. interface
  16.  
  17. {$R CONTROLS}
  18.  
  19. uses Messages, Windows, Classes, Sysutils, Graphics, Menus, CommCtrl, Imm;
  20.  
  21. { VCL control message IDs }
  22.  
  23. const
  24.   CM_BASE                   = $B000;
  25.   CM_ACTIVATE               = CM_BASE + 0;
  26.   CM_DEACTIVATE             = CM_BASE + 1;
  27.   CM_GOTFOCUS               = CM_BASE + 2;
  28.   CM_LOSTFOCUS              = CM_BASE + 3;
  29.   CM_CANCELMODE             = CM_BASE + 4;
  30.   CM_DIALOGKEY              = CM_BASE + 5;
  31.   CM_DIALOGCHAR             = CM_BASE + 6;
  32.   CM_FOCUSCHANGED           = CM_BASE + 7;
  33.   CM_PARENTFONTCHANGED      = CM_BASE + 8;
  34.   CM_PARENTCOLORCHANGED     = CM_BASE + 9;
  35.   CM_HITTEST                = CM_BASE + 10;
  36.   CM_VISIBLECHANGED         = CM_BASE + 11;
  37.   CM_ENABLEDCHANGED         = CM_BASE + 12;
  38.   CM_COLORCHANGED           = CM_BASE + 13;
  39.   CM_FONTCHANGED            = CM_BASE + 14;
  40.   CM_CURSORCHANGED          = CM_BASE + 15;
  41.   CM_CTL3DCHANGED           = CM_BASE + 16;
  42.   CM_PARENTCTL3DCHANGED     = CM_BASE + 17;
  43.   CM_TEXTCHANGED            = CM_BASE + 18;
  44.   CM_MOUSEENTER             = CM_BASE + 19;
  45.   CM_MOUSELEAVE             = CM_BASE + 20;
  46.   CM_MENUCHANGED            = CM_BASE + 21;
  47.   CM_APPKEYDOWN             = CM_BASE + 22;
  48.   CM_APPSYSCOMMAND          = CM_BASE + 23;
  49.   CM_BUTTONPRESSED          = CM_BASE + 24;
  50.   CM_SHOWINGCHANGED         = CM_BASE + 25;
  51.   CM_ENTER                  = CM_BASE + 26;
  52.   CM_EXIT                   = CM_BASE + 27;
  53.   CM_DESIGNHITTEST          = CM_BASE + 28;
  54.   CM_ICONCHANGED            = CM_BASE + 29;
  55.   CM_WANTSPECIALKEY         = CM_BASE + 30;
  56.   CM_INVOKEHELP             = CM_BASE + 31;
  57.   CM_WINDOWHOOK             = CM_BASE + 32;
  58.   CM_RELEASE                = CM_BASE + 33;
  59.   CM_SHOWHINTCHANGED        = CM_BASE + 34;
  60.   CM_PARENTSHOWHINTCHANGED  = CM_BASE + 35;
  61.   CM_SYSCOLORCHANGE         = CM_BASE + 36;
  62.   CM_WININICHANGE           = CM_BASE + 37;
  63.   CM_FONTCHANGE             = CM_BASE + 38;
  64.   CM_TIMECHANGE             = CM_BASE + 39;
  65.   CM_TABSTOPCHANGED         = CM_BASE + 40;
  66.   CM_UIACTIVATE             = CM_BASE + 41;
  67.   CM_UIDEACTIVATE           = CM_BASE + 42;
  68.   CM_DOCWINDOWACTIVATE      = CM_BASE + 43;
  69.   CM_CONTROLLISTCHANGE      = CM_BASE + 44;
  70.   CM_GETDATALINK            = CM_BASE + 45;
  71.   CM_CHILDKEY               = CM_BASE + 46;
  72.   CM_DRAG                   = CM_BASE + 47;
  73.   CM_HINTSHOW               = CM_BASE + 48;
  74.   CM_DIALOGHANDLE           = CM_BASE + 49;
  75.   CM_ISTOOLCONTROL          = CM_BASE + 50;
  76.   CM_RECREATEWND            = CM_BASE + 51;
  77.   CM_INVALIDATE             = CM_BASE + 52;
  78.   CM_SYSFONTCHANGED         = CM_BASE + 53;
  79.   CM_CONTROLCHANGE          = CM_BASE + 54;
  80.   CM_CHANGED                = CM_BASE + 55;
  81.  
  82. { VCL control notification IDs }
  83.  
  84. const
  85.   CN_BASE              = $BC00;
  86.   CN_CHARTOITEM        = CN_BASE + WM_CHARTOITEM;
  87.   CN_COMMAND           = CN_BASE + WM_COMMAND;
  88.   CN_COMPAREITEM       = CN_BASE + WM_COMPAREITEM;
  89.   CN_CTLCOLORBTN       = CN_BASE + WM_CTLCOLORBTN;
  90.   CN_CTLCOLORDLG       = CN_BASE + WM_CTLCOLORDLG;
  91.   CN_CTLCOLOREDIT      = CN_BASE + WM_CTLCOLOREDIT;
  92.   CN_CTLCOLORLISTBOX   = CN_BASE + WM_CTLCOLORLISTBOX;
  93.   CN_CTLCOLORMSGBOX    = CN_BASE + WM_CTLCOLORMSGBOX;
  94.   CN_CTLCOLORSCROLLBAR = CN_BASE + WM_CTLCOLORSCROLLBAR;
  95.   CN_CTLCOLORSTATIC    = CN_BASE + WM_CTLCOLORSTATIC;
  96.   CN_DELETEITEM        = CN_BASE + WM_DELETEITEM;
  97.   CN_DRAWITEM          = CN_BASE + WM_DRAWITEM;
  98.   CN_HSCROLL           = CN_BASE + WM_HSCROLL;
  99.   CN_MEASUREITEM       = CN_BASE + WM_MEASUREITEM;
  100.   CN_PARENTNOTIFY      = CN_BASE + WM_PARENTNOTIFY;
  101.   CN_VKEYTOITEM        = CN_BASE + WM_VKEYTOITEM;
  102.   CN_VSCROLL           = CN_BASE + WM_VSCROLL;
  103.   CN_KEYDOWN           = CN_BASE + WM_KEYDOWN;
  104.   CN_KEYUP             = CN_BASE + WM_KEYUP;
  105.   CN_CHAR              = CN_BASE + WM_CHAR;
  106.   CN_SYSKEYDOWN        = CN_BASE + WM_SYSKEYDOWN;
  107.   CN_SYSCHAR           = CN_BASE + WM_SYSCHAR;
  108.   CN_NOTIFY            = CN_BASE + WM_NOTIFY;
  109.  
  110. { TModalResult values }
  111.  
  112. const
  113.   mrNone     = 0;
  114.   mrOk       = idOk;
  115.   mrCancel   = idCancel;
  116.   mrAbort    = idAbort;
  117.   mrRetry    = idRetry;
  118.   mrIgnore   = idIgnore;
  119.   mrYes      = idYes;
  120.   mrNo       = idNo;
  121.   mrAll      = mrNo + 1;
  122.   mrNoToAll  = mrAll + 1;
  123.   mrYesToAll = mrNoToAll + 1;
  124.  
  125. { Cursor identifiers }
  126.  
  127. const
  128.   crDefault     = 0;
  129.   crNone        = -1;
  130.   crArrow       = -2;
  131.   crCross       = -3;
  132.   crIBeam       = -4;
  133.   crSize        = -5;
  134.   crSizeNESW    = -6;
  135.   crSizeNS      = -7;
  136.   crSizeNWSE    = -8;
  137.   crSizeWE      = -9;
  138.   crUpArrow     = -10;
  139.   crHourGlass   = -11;
  140.   crDrag        = -12;
  141.   crNoDrop      = -13;
  142.   crHSplit      = -14;
  143.   crVSplit      = -15;
  144.   crMultiDrag   = -16;
  145.   crSQLWait     = -17;
  146.   crNo          = -18;
  147.   crAppStart    = -19;
  148.   crHelp        = -20;
  149.   crHandPoint   = -21;
  150.  
  151. type
  152.  
  153. { Forward declarations }
  154.  
  155.   TDragObject = class;
  156.   TControl = class;
  157.   TWinControl = class;
  158.   TCustomImageList = class;
  159.  
  160. { VCL control message records }
  161.  
  162.   TCMActivate = TWMNoParams;
  163.   TCMDeactivate = TWMNoParams;
  164.   TCMGotFocus = TWMNoParams;
  165.   TCMLostFocus = TWMNoParams;
  166.   TCMDialogKey = TWMKey;
  167.   TCMDialogChar = TWMKey;
  168.   TCMHitTest = TWMNCHitTest;
  169.   TCMEnter = TWMNoParams;
  170.   TCMExit = TWMNoParams;
  171.   TCMDesignHitTest = TWMMouse;
  172.   TCMWantSpecialKey = TWMKey;
  173.  
  174.   TCMCancelMode = record
  175.     Msg: Cardinal;
  176.     Unused: Integer;
  177.     Sender: TControl;
  178.     Result: Longint;
  179.   end;
  180.  
  181.   TCMFocusChanged = record
  182.     Msg: Cardinal;
  183.     Unused: Integer;
  184.     Sender: TWinControl;
  185.     Result: Longint;
  186.   end;
  187.  
  188.   TCMControlListChange = record
  189.     Msg: Cardinal;
  190.     Control: TControl;
  191.     Inserting: LongBool;
  192.     Result: Longint;
  193.   end;
  194.  
  195.   TCMChildKey = record
  196.     Msg: Cardinal;
  197.     CharCode: Word;
  198.     Unused: Word;
  199.     Sender: TWinControl;
  200.     Result: Longint;
  201.   end;
  202.  
  203.   TCMControlChange = record
  204.     Msg: Cardinal;
  205.     Control: TControl;
  206.     Inserting: LongBool;
  207.     Result: Longint;
  208.   end;
  209.  
  210.   TCMChanged = record
  211.     Msg: Cardinal;
  212.     Unused: Longint;
  213.     Child: TControl;
  214.     Result: Longint;
  215.   end;
  216.  
  217.   TDragMessage = (dmDragEnter, dmDragLeave, dmDragMove, dmDragDrop, dmDragCancel,
  218.     dmFindTarget);
  219.  
  220.   PDragRec = ^TDragRec;
  221.   TDragRec = record
  222.     Pos: TPoint;
  223.     Source: TDragObject;
  224.     Target: Pointer;
  225.   end;
  226.  
  227.   TCMDrag = packed record
  228.     Msg: Cardinal;
  229.     DragMessage: TDragMessage;
  230.     Reserved1: Byte;
  231.     Reserved2: Word;
  232.     DragRec: PDragRec;
  233.     Result: Longint;
  234.   end;
  235.  
  236. { Cursor type }
  237.  
  238.   TCursor = -32768..32767;
  239.  
  240. { Dragging objects }
  241.  
  242.   TDragObject = class(TObject)
  243.   protected
  244.     function GetDragImages: TCustomImageList; virtual;
  245.     function GetDragCursor(Accepted: Boolean; X, Y: Integer): TCursor; virtual;
  246.     procedure Finished(Target: TObject; X, Y: Integer; Accepted: Boolean); virtual;
  247.   public
  248.     function Instance: THandle; virtual;
  249.     function GetName: string; virtual;
  250.     procedure HideDragImage; virtual;
  251.     procedure ShowDragImage; virtual;
  252.   end;
  253.  
  254.   TDragControlObject = class(TDragObject)
  255.   protected
  256.     function GetDragImages: TCustomImageList; override;
  257.     function GetDragCursor(Accepted: Boolean; X, Y: Integer): TCursor; override;
  258.     procedure Finished(Target: TObject; X, Y: Integer; Accepted: Boolean); override;
  259.   public
  260.     constructor Create(AControl: TControl);
  261.     property Control: TControl;
  262.     procedure HideDragImage; override;
  263.     procedure ShowDragImage; override;
  264.   end;
  265.  
  266. { Controls }
  267.  
  268.   TControlCanvas = class(TCanvas)
  269.   protected
  270.     procedure CreateHandle; override;
  271.   public
  272.     destructor Destroy; override;
  273.     procedure FreeHandle;
  274.     property Control: TControl;
  275.   end;
  276.  
  277.   TAlign = (alNone, alTop, alBottom, alLeft, alRight, alClient);
  278.  
  279.   TControlState = set of (csLButtonDown, csClicked, csPalette,
  280.     csReadingState, csAlignmentNeeded, csFocusing, csCreating,
  281.     csPaintCopy);
  282.  
  283.   TControlStyle = set of (csAcceptsControls, csCaptureMouse,
  284.     csDesignInteractive, csClickEvents, csFramed, csSetCaption, csOpaque,
  285.     csDoubleClicks, csFixedWidth, csFixedHeight, csNoDesignVisible,
  286.     csReplicatable, csNoStdEvents, csDisplayDragImage, csReflector);
  287.  
  288.   TMouseButton = (mbLeft, mbRight, mbMiddle);
  289.  
  290.   TDragMode = (dmManual, dmAutomatic);
  291.  
  292.   TDragState = (dsDragEnter, dsDragLeave, dsDragMove);
  293.  
  294.   TTabOrder = -1..32767;
  295.  
  296.   TCaption = type string;
  297.  
  298.   TDate = type TDateTime;
  299.  
  300.   TTime = type TDateTime;
  301.  
  302.   TScalingFlags = set of (sfLeft, sfTop, sfWidth, sfHeight, sfFont);
  303.  
  304.   TMouseEvent = procedure(Sender: TObject; Button: TMouseButton;
  305.     Shift: TShiftState; X, Y: Integer) of object;
  306.   TMouseMoveEvent = procedure(Sender: TObject; Shift: TShiftState;
  307.     X, Y: Integer) of object;
  308.   TKeyEvent = procedure(Sender: TObject; var Key: Word;
  309.     Shift: TShiftState) of object;
  310.   TKeyPressEvent = procedure(Sender: TObject; var Key: Char) of object;
  311.   TDragOverEvent = procedure(Sender, Source: TObject; X, Y: Integer;
  312.     State: TDragState; var Accept: Boolean) of object;
  313.   TDragDropEvent = procedure(Sender, Source: TObject;
  314.     X, Y: Integer) of object;
  315.   TStartDragEvent = procedure(Sender: TObject;
  316.     var DragObject: TDragObject) of object;
  317.   TEndDragEvent = procedure(Sender, Target: TObject;
  318.     X, Y: Integer) of object;
  319.  
  320.   TWndMethod = procedure(var Message: TMessage) of object;
  321.  
  322.   TControl = class(TComponent)
  323.   protected
  324.     procedure Changed;
  325.     procedure ChangeScale(M, D: Integer); dynamic;
  326.     procedure Click; dynamic;
  327.     procedure DblClick; dynamic;
  328.     procedure DefaultHandler(var Message); override;
  329.     procedure DefineProperties(Filer: TFiler); override;
  330.     procedure DragCanceled; dynamic;
  331.     procedure DragOver(Source: TObject; X, Y: Integer; State: TDragState;
  332.       var Accept: Boolean); dynamic;
  333.     procedure DoEndDrag(Target: TObject; X, Y: Integer); dynamic;
  334.     procedure DoStartDrag(var DragObject: TDragObject); dynamic;
  335.     function GetClientOrigin: TPoint; virtual;
  336.     function GetClientRect: TRect; virtual;
  337.     function GetDeviceContext(var WindowHandle: HWnd): HDC; virtual;
  338.     function GetDragImages: TCustomImageList; virtual;
  339.     function GetPalette: HPALETTE; dynamic;
  340.     function GetParentComponent: TComponent; override;
  341.     function GetPopupMenu: TPopupMenu; dynamic;
  342.     function HasParent: Boolean; override;
  343.     procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
  344.       X, Y: Integer); dynamic;
  345.     procedure MouseMove(Shift: TShiftState; X, Y: Integer); dynamic;
  346.     procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
  347.       X, Y: Integer); dynamic;
  348.     procedure Notification(AComponent: TComponent;
  349.       Operation: TOperation); override;
  350.     function PaletteChanged(Foreground: Boolean): Boolean; dynamic;
  351.     procedure ReadState(Reader: TReader); override;
  352.     procedure RequestAlign;
  353.     procedure SendCancelMode(Sender: TControl);
  354.     procedure SetDragMode(Value: TDragMode); virtual;
  355.     procedure SetParent(AParent: TWinControl); virtual;
  356.     procedure SetParentComponent(Value: TComponent); override;
  357.     procedure SetName(const Value: TComponentName); override;
  358.     procedure SetZOrder(TopMost: Boolean); dynamic;
  359.     procedure UpdateBoundsRect(const R: TRect);
  360.     procedure VisibleChanging; dynamic;
  361.     procedure WndProc(var Message: TMessage); virtual;
  362.     property Caption: TCaption;
  363.     property Color: TColor default clWindow;
  364.     property DesktopFont: Boolean default False;
  365.     property DragCursor: TCursor default crDrag;
  366.     property DragMode: TDragMode default dmManual;
  367.     property Font: TFont;
  368.     property IsControl: Boolean;
  369.     property MouseCapture: Boolean;
  370.     property ParentColor: Boolean default True;
  371.     property ParentFont: Boolean default True;
  372.     property ParentShowHint: Boolean default True;
  373.     property PopupMenu: TPopupMenu;
  374.     property ScalingFlags: TScalingFlags;
  375.     property Text: TCaption;
  376.     property WindowText: PChar;
  377.     property OnClick: TNotifyEvent;
  378.     property OnDblClick: TNotifyEvent;
  379.     property OnDragDrop: TDragDropEvent;
  380.     property OnDragOver: TDragOverEvent;
  381.     property OnEndDrag: TEndDragEvent;
  382.     property OnMouseDown: TMouseEvent;
  383.     property OnMouseMove: TMouseMoveEvent;
  384.     property OnMouseUp: TMouseEvent;
  385.     property OnStartDrag: TStartDragEvent;
  386.   public
  387.     constructor Create(AOwner: TComponent); override;
  388.     destructor Destroy; override;
  389.     procedure BeginDrag(Immediate: Boolean);
  390.     procedure BringToFront;
  391.     function ClientToScreen(const Point: TPoint): TPoint;
  392.     function Dragging: Boolean;
  393.     procedure DragDrop(Source: TObject; X, Y: Integer); dynamic;
  394.     procedure EndDrag(Drop: Boolean);
  395.     function GetTextBuf(Buffer: PChar; BufSize: Integer): Integer;
  396.     function GetTextLen: Integer;
  397.     procedure Hide;
  398.     procedure Invalidate; virtual;
  399.     function Perform(Msg: Cardinal; WParam, LParam: Longint): Longint;
  400.     procedure Refresh;
  401.     procedure Repaint; virtual;
  402.     function ScreenToClient(const Point: TPoint): TPoint;
  403.     procedure SendToBack;
  404.     procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); virtual;
  405.     procedure SetTextBuf(Buffer: PChar);
  406.     procedure Show;
  407.     procedure Update; virtual;
  408.     property Align: TAlign default alNone;
  409.     property BoundsRect: TRect;
  410.     property ClientHeight: Integer;
  411.     property ClientOrigin: TPoint;
  412.     property ClientRect: TRect;
  413.     property ClientWidth: Integer;
  414.     property ControlState: TControlState;
  415.     property ControlStyle: TControlStyle;
  416.     property Parent: TWinControl;
  417.     property ShowHint: Boolean;
  418.     property Visible: Boolean default True;
  419.     property Enabled: Boolean default True;
  420.     property WindowProc: TWndMethod;
  421.   published
  422.     property Left: Integer;
  423.     property Top: Integer;
  424.     property Width: Integer;
  425.     property Height: Integer;
  426.     property Cursor: TCursor default crDefault;
  427.     property Hint: string;
  428.   end;
  429.  
  430.   TControlClass = class of TControl;
  431.  
  432.   TCreateParams = record
  433.     Caption: PChar;
  434.     Style: Longint;
  435.     ExStyle: Longint;
  436.     X, Y: Integer;
  437.     Width, Height: Integer;
  438.     WndParent: HWnd;
  439.     Param: Pointer;
  440.     WindowClass: TWndClass;
  441.     WinClassName: array[0..63] of Char;
  442.   end;
  443.  
  444.   TImeMode = (imDisable, imClose, imOpen, imDontCare,
  445.               imSAlpha, imAlpha, imHira, imSKata, imKata,
  446.               imChinese, imSHanguel, imHanguel);
  447.   TImeName = type string;
  448.  
  449.   TWinControl = class(TControl)
  450.   protected
  451.     FDoubleBuffered: Boolean;
  452.     FInImeComposition: Boolean;
  453.     procedure AlignControls(AControl: TControl; var Rect: TRect); virtual;
  454.     procedure ChangeScale(M, D: Integer); override;
  455.     procedure CreateHandle; virtual;
  456.     procedure CreateParams(var Params: TCreateParams); virtual;
  457.     procedure CreateSubClass(var Params: TCreateParams;
  458.       ControlClassName: PChar);
  459.     procedure CreateWindowHandle(const Params: TCreateParams); virtual;
  460.     procedure CreateWnd; virtual;
  461.     procedure DefaultHandler(var Message); override;
  462.     procedure DestroyHandle;
  463.     procedure DestroyWindowHandle; virtual;
  464.     procedure DestroyWnd; virtual;
  465.     procedure DoEnter; dynamic;
  466.     procedure DoExit; dynamic;
  467.     function DoKeyDown(var Message: TWMKey): Boolean;
  468.     function DoKeyPress(var Message: TWMKey): Boolean;
  469.     function DoKeyUp(var Message: TWMKey): Boolean;
  470.     function FindNextControl(CurControl: TWinControl;
  471.       GoForward, CheckTabStop, CheckParent: Boolean): TWinControl;
  472.     procedure FixupTabList;
  473.     procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
  474.     function GetClientOrigin: TPoint; override;
  475.     function GetClientRect: TRect; override;
  476.     function GetDeviceContext(var WindowHandle: HWnd): HDC; override;
  477.     function GetParentHandle: HWnd;
  478.     function GetTopParentHandle: HWnd;
  479.     function IsControlMouseMsg(var Message: TWMMouse): Boolean;
  480.     procedure KeyDown(var Key: Word; Shift: TShiftState); dynamic;
  481.     procedure KeyUp(var Key: Word; Shift: TShiftState); dynamic;
  482.     procedure KeyPress(var Key: Char); dynamic;
  483.     procedure MainWndProc(var Message: TMessage);
  484.     procedure NotifyControls(Msg: Word);
  485.     procedure PaintControls(DC: HDC; First: TControl);
  486.     procedure PaintHandler(var Message: TWMPaint);
  487.     procedure PaintWindow(DC: HDC); virtual;
  488.     function PaletteChanged(Foreground: Boolean): Boolean; override;
  489.     procedure ReadState(Reader: TReader); override;
  490.     procedure RecreateWnd;
  491.     procedure ResetIme;
  492.     function ResetImeComposition(Action: DWORD): Boolean;
  493.     procedure ScaleControls(M, D: Integer);
  494.     procedure SelectFirst;
  495.     procedure SelectNext(CurControl: TWinControl;
  496.       GoForward, CheckTabStop: Boolean);
  497.     procedure SetChildOrder(Child: TComponent; Order: Integer); override;
  498.     procedure SetIme;
  499.     function SetImeCompositionWindow(Font: TFont; XPos, YPos: Integer): Boolean;
  500.     procedure SetZOrder(TopMost: Boolean); override;
  501.     procedure ShowControl(AControl: TControl); virtual;
  502.     procedure WndProc(var Message: TMessage); override;
  503.     property Ctl3D: Boolean;
  504.     property DefWndProc: Pointer;
  505.     property ImeMode: TImeMode default imDontCare;
  506.     property ImeName: TImeName;
  507.     property ParentCtl3D: Boolean default True;
  508.     property WindowHandle: HWnd;
  509.     property OnEnter: TNotifyEvent;
  510.     property OnExit: TNotifyEvent;
  511.     property OnKeyDown: TKeyEvent;
  512.     property OnKeyPress: TKeyPressEvent;
  513.     property OnKeyUp: TKeyEvent;
  514.   public
  515.     constructor Create(AOwner: TComponent); override;
  516.     constructor CreateParented(ParentWindow: HWnd);
  517.     destructor Destroy; override;
  518.     procedure Broadcast(var Message);
  519.     function CanFocus: Boolean;
  520.     function ContainsControl(Control: TControl): Boolean;
  521.     function ControlAtPos(const Pos: TPoint; AllowDisabled: Boolean): TControl;
  522.     procedure DisableAlign;
  523.     procedure EnableAlign;
  524.     function Focused: Boolean;
  525.     procedure GetTabOrderList(List: TList); dynamic;
  526.     function HandleAllocated: Boolean;
  527.     procedure HandleNeeded;
  528.     procedure InsertControl(AControl: TControl);
  529.     procedure Invalidate; override;
  530.     procedure PaintTo(DC: HDC; X, Y: Integer);
  531.     procedure RemoveControl(AControl: TControl);
  532.     procedure Realign;
  533.     procedure Repaint; override;
  534.     procedure ScaleBy(M, D: Integer);
  535.     procedure ScrollBy(DeltaX, DeltaY: Integer);
  536.     procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
  537.     procedure SetFocus; virtual;
  538.     procedure Update; override;
  539.     procedure UpdateControlState;
  540.     property Brush: TBrush;
  541.     property Controls[Index: Integer]: TControl;
  542.     property ControlCount: Integer;
  543.     property Handle: HWnd;
  544.     property ParentWindow: HWnd;
  545.     property Showing: Boolean;
  546.     property TabOrder: TTabOrder default -1;
  547.     property TabStop: Boolean default False;
  548.   published
  549.     property HelpContext: THelpContext default 0;
  550.   end;
  551.  
  552.   TWinControlClass = class of TWinControl;
  553.  
  554.   TGraphicControl = class(TControl)
  555.   protected
  556.     procedure Paint; virtual;
  557.     property Canvas: TCanvas;
  558.   public
  559.     constructor Create(AOwner: TComponent); override;
  560.     destructor Destroy; override;
  561.   end;
  562.  
  563.   TCustomControl = class(TWinControl)
  564.   protected
  565.     procedure Paint; virtual;
  566.     procedure PaintWindow(DC: HDC); override;
  567.     property Canvas: TCanvas;
  568.   public
  569.     constructor Create(AOwner: TComponent); override;
  570.     destructor Destroy; override;
  571.   end;
  572.  
  573.   THintWindow = class(TCustomControl)
  574.   protected
  575.     procedure CreateParams(var Params: TCreateParams); override;
  576.     procedure Paint; override;
  577.   public
  578.     constructor Create(AOwner: TComponent); override;
  579.     procedure ActivateHint(Rect: TRect; const AHint: string); virtual;
  580.     procedure ActivateHintData(Rect: TRect; const AHint: string; AData: Pointer); virtual;
  581.     function CalcHintRect(MaxWidth: Integer; const AHint: string;
  582.       AData: Pointer): TRect; virtual;
  583.     function IsHintMsg(var Msg: TMsg): Boolean; virtual;
  584.     procedure ReleaseHandle;
  585.     property Caption;
  586.     property Color;
  587.     property Canvas;
  588.   end;
  589.  
  590.   THintWindowClass = class of THintWindow;
  591.  
  592. { TChangeLink }
  593.  
  594.   TChangeLink = class(TObject)
  595.   public
  596.     destructor Destroy; override;
  597.     procedure Change; dynamic;
  598.     property OnChange: TNotifyEvent;
  599.     property Sender: TCustomImageList;
  600.   end;
  601.  
  602.   { TCustomImageList }
  603.  
  604.   TDrawingStyle = (dsFocus, dsSelected, dsNormal, dsTransparent);
  605.   TImageType = (itImage, itMask);
  606.   TResType = (rtBitmap, rtCursor, rtIcon);
  607.   TOverlay = 0..3;
  608.   TLoadResource = (lrDefaultColor, lrDefaultSize, lrFromFile,
  609.     lrMap3DColors, lrTransparent, lrMonoChrome);
  610.   TLoadResources = set of TLoadResource;
  611.  
  612.   TCustomImageList = class(TComponent)
  613.   protected
  614.     procedure Change; dynamic;
  615.     procedure DefineProperties(Filer: TFiler); override;
  616.     procedure GetImages(Index: Integer; Image, Mask: TBitmap);
  617.     procedure HandleNeeded;
  618.     procedure Initialize;
  619.     property BlendColor: TColor default clNone;
  620.     property BkColor: TColor default clNone;
  621.     property AllocBy: Integer default 4;
  622.     property DrawingStyle: TDrawingStyle default dsNormal;
  623.     property Height: Integer default 16;
  624.     property ImageType: TImageType default itImage;
  625.     property Masked: Boolean default True;
  626.     property OnChange: TNotifyEvent;
  627.     property ShareImages: Boolean default False;
  628.     property Width: Integer default 16;
  629.   public
  630.     constructor Create(AOwner: TComponent); override;
  631.     constructor CreateSize(AWidth, AHeight: Integer);
  632.     destructor Destroy; override;
  633.     procedure Assign(Source: TPersistent); override;
  634.     function Add(Image, Mask: TBitmap): Integer;
  635.     function AddIcon(Image: TIcon): Integer;
  636.     procedure AddImages(Value: TCustomImageList);
  637.     function AddMasked(Image: TBitmap; MaskColor: TColor): Integer;
  638.     function BeginDrag(Window: HWND; X, Y: Integer): Boolean;
  639.     procedure Clear;
  640.     procedure Delete(Index: Integer);
  641.     function DragLock(Window: HWND; XPos, YPos: Integer): Boolean;
  642.     function DragMove(X, Y: Integer): Boolean;
  643.     procedure DragUnlock;
  644.     procedure Draw(Canvas: TCanvas; X, Y, Index: Integer);
  645.     procedure DrawOverlay(Canvas: TCanvas; X, Y: Integer;
  646.       ImageIndex: Integer; Overlay: TOverlay);
  647.     function EndDrag: Boolean;
  648.     function FileLoad(ResType: TResType; Name: string;
  649.       MaskColor: TColor): Boolean;
  650.     procedure GetBitmap(Index: Integer; Image: TBitmap);
  651.     function GetHotSpot: TPoint;
  652.     procedure GetIcon(Index: Integer; Image: TIcon);
  653.     function GetImageBitmap: HBITMAP;
  654.     function GetMaskBitmap: HBITMAP;
  655.     function GetResource(ResType: TResType; Name: string;
  656.       Width: Integer; LoadFlags: TLoadResources; MaskColor: TColor): Boolean;
  657.     function GetInstRes(Instance: THandle; ResType: TResType; Name: string;
  658.       Width: Integer; LoadFlags: TLoadResources; MaskColor: TColor): Boolean;
  659.     function HandleAllocated: Boolean;
  660.     procedure HideDragImage;
  661.     procedure Insert(Index: Integer; Image, Mask: TBitmap);
  662.     procedure InsertIcon(Index: Integer; Image: TIcon);
  663.     procedure InsertMasked(Index: Integer; Image: TBitmap; MaskColor: TColor);
  664.     procedure Move(CurIndex, NewIndex: Integer);
  665.     function Overlay(ImageIndex: Integer; Overlay: TOverlay): Boolean;
  666.     procedure RegisterChanges(Value: TChangeLink);
  667.     function ResourceLoad(ResType: TResType; Name: string;
  668.       MaskColor: TColor): Boolean;
  669.     function ResInstLoad(Instance: THandle; ResType: TResType; Name: string;
  670.       MaskColor: TColor): Boolean;
  671.     procedure Replace(Index: Integer; Image, Mask: TBitmap);
  672.     procedure ReplaceIcon(Index: Integer; Image: TIcon);
  673.     procedure ReplaceMasked(Index: Integer; NewImage: TBitmap; MaskColor: TColor);
  674.     function SetDragImage(Index, HotSpotX, HotSpotY: Integer): Boolean;
  675.     procedure ShowDragImage;
  676.     procedure UnRegisterChanges(Value: TChangeLink);
  677.     property Count: Integer;
  678.     property DragCursor: TCursor;
  679.     property Dragging: Boolean;
  680.     property Handle: HImageList;
  681.   end;
  682.  
  683. { TImageList }
  684.   TImageList = class(TCustomImageList)
  685.   published
  686.     property BlendColor;
  687.     property BkColor;
  688.     property AllocBy;
  689.     property DrawingStyle;
  690.     property Height;
  691.     property ImageType;
  692.     property Masked;
  693.     property OnChange;
  694.     property ShareImages;
  695.     property Width;
  696.   end;
  697.  
  698. function IsDragObject(Sender: TObject): Boolean;
  699. function FindControl(Handle: HWnd): TWinControl;
  700. function FindVCLWindow(const Pos: TPoint): TWinControl;
  701. function FindDragTarget(const Pos: TPoint; AllowDisabled: Boolean): TControl;
  702. function GetCaptureControl: TControl;
  703. procedure SetCaptureControl(Control: TControl);
  704. procedure CancelDrag;
  705.  
  706. function CursorToString(Cursor: TCursor): string;
  707. function StringToCursor(const S: string): TCursor;
  708. procedure GetCursorValues(Proc: TGetStrProc);
  709. function CursorToIdent(Cursor: Longint; var Ident: string): Boolean;
  710. function IdentToCursor(const Ident: string; var Cursor: Longint): Boolean;
  711.  
  712. function GetShortHint(const Hint: string): string;
  713. function GetLongHint(const Hint: string): string;
  714.  
  715. var
  716.   CreationControl: TWinControl = nil;
  717.  
  718. function InitWndProc(HWindow: HWnd; Message, WParam: Longint;
  719.   LParam: Longint): Longint; stdcall;
  720.  
  721. const
  722.   CTL3D_ALL = $FFFF;
  723.  
  724. var
  725.   NewStyleControls: Boolean;
  726.  
  727. function SendAppMessage(Msg: Cardinal; WParam, LParam: Longint): Longint;
  728. procedure MoveWindowOrg(DC: HDC; DX, DY: Integer);
  729.  
  730. procedure SetImeMode(hWnd: HWND; Mode: TImeMode);
  731. procedure SetImeName(Name: TImeName);
  732. function Win32NLSEnableIME(hWnd: HWND; Enable: Boolean): Boolean;
  733. function Imm32GetContext(hWnd: HWND): HIMC;
  734. function Imm32ReleaseContext(hWnd: HWND; hImc: HIMC): Boolean;
  735. function Imm32GetConversionStatus(hImc: HIMC; var Conversion, Sentence: DWORD): Boolean;
  736. function Imm32SetConversionStatus(hImc: HIMC; Conversion, Sentence: DWORD): Boolean;
  737. function Imm32SetOpenStatus(hImc: HIMC; fOpen: Boolean): Boolean;
  738. function Imm32SetCompositionWindow(hImc: HIMC; lpCompForm: PCOMPOSITIONFORM): Boolean;
  739. function Imm32SetCompositionFont(hImc: HIMC; lpLogfont: PLOGFONTA): Boolean;
  740. function Imm32GetCompositionString(hImc: HIMC; dWord1: DWORD; lpBuf: pointer; dwBufLen: DWORD): Longint;
  741. function Imm32IsIME(hKl: HKL): Boolean;
  742. function Imm32NotifyIME(hImc: HIMC; dwAction, dwIndex, dwValue: DWORD): Boolean;
  743.  
  744. implementation
  745.