W
wrl_001
Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下:
function CreateLabelCursor(ALabel: TLabel): HCursor;
var
A, B: array of Byte;
bm:TBitmap;
r:TRect;
begin
bm:=TBitmap.Create;
r:=Rect(0,0,ALabel.Width,ALabel.Height);
SetLength(A, ALabel.Width*ALabel.Height);
SetLength(B, ALabel.Width*ALabel.Height);
bm.Width :=ALabel.Width;
bm.Height :=ALabel.Height;
bm.Canvas.CopyRect(r,ALabel.Canvas,r);
Form1.Canvas.Draw(0,0,bm);
// GetObject(bm.Handle ,Sizeof(a),a);
GetBitmapBits(bm.Handle,sizeof(a),a);
// GetBitmapBits(bm.Handle,sizeof(b),b);
Result:=CreateCursor(Application.Handle,Round(ALabel.Width/2),Round(ALabel.Height/2),
ALabel.Width, ALabel.Height, @A[0], @B[0]);
bm.Free;
end;
procedure TForm1.Memo1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept:=Source is TLabel;
end;
procedure TForm1.Memo1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
Memo1.Lines.add(TLabel(Source).Caption);
end;
procedure TForm1.Label1StartDrag(Sender: TObject;
var DragObject: TDragObject);
begin
if Screen.Cursors[1]<>Screen.Cursors[crDefault] then
DestroyCursor(Screen.Cursors[1]);
Screen.Cursors[1]:=CreateLabelCursor(TLabel(Sender));
TLabel(Sender).DragCursor :=1;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
if Screen.Cursors[1]<>Screen.Cursors[crDefault] then
DestroyCursor(Screen.Cursors[1]);
end;
不知道错在哪里?哪位帮忙看看
function CreateLabelCursor(ALabel: TLabel): HCursor;
var
A, B: array of Byte;
bm:TBitmap;
r:TRect;
begin
bm:=TBitmap.Create;
r:=Rect(0,0,ALabel.Width,ALabel.Height);
SetLength(A, ALabel.Width*ALabel.Height);
SetLength(B, ALabel.Width*ALabel.Height);
bm.Width :=ALabel.Width;
bm.Height :=ALabel.Height;
bm.Canvas.CopyRect(r,ALabel.Canvas,r);
Form1.Canvas.Draw(0,0,bm);
// GetObject(bm.Handle ,Sizeof(a),a);
GetBitmapBits(bm.Handle,sizeof(a),a);
// GetBitmapBits(bm.Handle,sizeof(b),b);
Result:=CreateCursor(Application.Handle,Round(ALabel.Width/2),Round(ALabel.Height/2),
ALabel.Width, ALabel.Height, @A[0], @B[0]);
bm.Free;
end;
procedure TForm1.Memo1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept:=Source is TLabel;
end;
procedure TForm1.Memo1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
Memo1.Lines.add(TLabel(Source).Caption);
end;
procedure TForm1.Label1StartDrag(Sender: TObject;
var DragObject: TDragObject);
begin
if Screen.Cursors[1]<>Screen.Cursors[crDefault] then
DestroyCursor(Screen.Cursors[1]);
Screen.Cursors[1]:=CreateLabelCursor(TLabel(Sender));
TLabel(Sender).DragCursor :=1;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
if Screen.Cursors[1]<>Screen.Cursors[crDefault] then
DestroyCursor(Screen.Cursors[1]);
end;
不知道错在哪里?哪位帮忙看看