VrDeskTop.pas
上传用户:hbszzs
上传日期:2008-08-20
资源大小:628k
文件大小:3k
源码类别:

Delphi控件源码

开发平台:

Delphi

  1. {*****************************************************}
  2. {                                                     }
  3. {     Varian Component Workshop                       }
  4. {                                                     }
  5. {     Varian Software NL (c) 1996-2000                }
  6. {     All Rights Reserved                             }
  7. {                                                     }
  8. {*****************************************************}
  9. unit VrDeskTop;
  10. {$I VRLIB.INC}
  11. interface
  12. uses
  13.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  14.   VrConst, VrControls, VrSysUtils;
  15. type
  16.   TVrDeskTop = class(TVrGraphicImageControl)
  17.   private
  18.     FGlyph: TBitmap;
  19.     FFormDrag: Boolean;
  20.     procedure SetGlyph(Value: TBitmap);
  21.     procedure WMLButtonDown(var Msg: TWMLBUTTONDOWN); message WM_LBUTTONDOWN;
  22.   protected
  23.     procedure Paint; override;
  24.     function GetPalette: HPalette; override;
  25.   public
  26.     constructor Create(AOwner: TComponent); override;
  27.     destructor Destroy; override;
  28.   published
  29.     property Glyph: TBitmap read FGlyph write SetGlyph;
  30.     property FormDrag: Boolean read FFormDrag write FFormDrag default false;
  31.     property Color default clBlack;
  32. {$IFDEF VER110}
  33.     property Anchors;
  34.     property Constraints;
  35. {$ENDIF}
  36.     property Align;
  37.     property DragCursor;
  38. {$IFDEF VER110}
  39.     property DragKind;
  40. {$ENDIF}
  41.     property DragMode;
  42.     property Hint;
  43.     property ParentColor default false;
  44.     property ParentShowHint;
  45.     property PopupMenu;
  46.     property ShowHint;
  47.     property Visible;
  48.     property OnClick;
  49. {$IFDEF VER130}
  50.     property OnContextPopup;
  51. {$ENDIF}    
  52.     property OnDblClick;
  53.     property OnDragDrop;
  54.     property OnDragOver;
  55. {$IFDEF VER110}
  56.     property OnEndDock;
  57. {$ENDIF}
  58.     property OnEndDrag;
  59.     property OnMouseDown;
  60.     property OnMouseMove;
  61.     property OnMouseUp;
  62. {$IFDEF VER110}
  63.     property OnStartDock;
  64. {$ENDIF}
  65.     property OnStartDrag;
  66.   end;
  67. implementation
  68. { TVrDeskTop }
  69. constructor TVrDeskTop.Create(AOwner: TComponent);
  70. begin
  71.   inherited Create(AOwner);
  72.   ControlStyle := ControlStyle + [csReplicatable];
  73.   Width := 150;
  74.   Height := 150;
  75.   Color := clBtnFace;
  76.   ParentColor := false;
  77.   FFormDrag := false;
  78.   FGlyph := TBitmap.Create;
  79. end;
  80. destructor TVrDeskTop.Destroy;
  81. begin
  82.   FGlyph.Free;
  83.   inherited Destroy;
  84. end;
  85. function TVrDeskTop.GetPalette: HPalette;
  86. begin
  87.   Result := FGlyph.Palette;
  88. end;
  89. procedure TVrDeskTop.Paint;
  90. begin
  91.   if FGlyph.Empty then
  92.     ClearBitmapCanvas
  93.   else DrawTiledBitmap(BitmapCanvas, ClientRect, FGlyph);
  94.   if Designing then
  95.     with inherited BitmapCanvas do
  96.     begin
  97.       Pen.Style := psDot;
  98.       Brush.Style := bsClear;
  99.       Rectangle(0, 0, Width, Height);
  100.     end;
  101.   inherited Paint;
  102. end;
  103. procedure TVrDeskTop.SetGlyph(Value: TBitmap);
  104. begin
  105.   FGlyph.Assign(Value);
  106.   UpdateControlCanvas;
  107. end;
  108. procedure TVrDeskTop.WMLButtonDown(var Msg: TWMLBUTTONDOWN);
  109. var
  110.   AOwner: TComponent;
  111. begin
  112.   inherited;
  113.   if FFormDrag then
  114.   begin
  115.     ReleaseCapture;
  116.     AOwner := GetOwnerControl(Self);
  117.     if AOwner <> nil then
  118.       TWinControl(AOwner).Perform(WM_SYSCOMMAND, SC_DRAGMOVE, 0);
  119.   end;
  120. end;
  121. end.