Jo,
also ich ein nettes Tutorial gefunden (
www.blong.com/Confer...rop/4114.htm#VCLDLLs), wo das ganze erklärt wird.
Nun wollte ich mir die eine Komponente von dort abschreiben, hab allerdings 2 Probleme:
Hier der Source:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86:
| unit MyDragButton;
interface
uses SysUtils, Classes, Controls, StdCtrls, Graphics, Types, QControls;
type TMyDragButton = class(TButton) private FDragImages: TDragImageList; protected function GetDragImages: TDragImageList; override; procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; published end;
procedure Register;
implementation
constructor TMyDragButton.Create(AOwner: TComponent); begin inherited Create(AOwner); ControlStyle := ControlStyle + [csDisplayDragImage]; end;
destructor TMyDragButton.Destroy; begin FDragImages.Free; inherited; end;
function TMyDragButton.GetDragImages: TDragImageList; var Bmp: TBitmap; BmpIdx: Integer; Pt: TPoint; begin if not Assigned(FDragImages) then FDragImages := TDragImageList.Create(Self); Bmp := TBitmap.Create; try Bmp.Width := Width; Bmp.Height := Height; Bmp.Canvas.Lock; try PaintTo(Bmp.Canvas.Handle, 0, 0); finally Bmp.Canvas.Unlock end; FDragImages.Width := Width; FDragImages.Height := Height; BmpIdx := FDragImages.AddMasked(Bmp, clBtnFace); GetCursorPos(Pt); Pt := ScreenToClient(Pt); FDragImages.SetDragImage(BmpIdx, Pt.X, Pt.Y); Result := FDragImages; finally Bmp.Free end end;
procedure TDragButton.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin inherited; if ssCtrl in Shift then BeginDrag(True) end;
procedure Register; begin RegisterComponents('Samples', [TMyDragButton]); end;
end. |
Also 1.
Delphi-Quelltext
1:
| procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override; |
Hier meint er, das die Dekleration von der vorherigen Deklaration abweicht.
Verstehe ich nicht ganz, da die Procedur in der Doku genau so drinsteht...
Und 2.
Delphi-Quelltext
1:
| ontrolStyle := ControlStyle + [csDisplayDragImage]; |
Meint er hier, 'incomatible types'.
Woran könnte das liegen ?