我想做一个鼠标点击Label标签,标签变色的简单操作,可是失败了~~~~~~~
当我把label1MouseDown放进panel1MouseDown中时,点击panel1是标签变色了,但这不是我想要的.
下面是我的代码:((请多多指教!!))
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Panel1: TPanel;
Label1: TLabel;
Button1: TButton;
procedure Label1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Button1Click(Sender: TObject);
procedure Label1EndDrag(Sender, Target: TObject; X, Y: Integer);
procedure Panel1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure Label1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
panel1_x,panel1_y,label1_x,label1_y : integer;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Label1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
label1_x :=x;
label1_y := y;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
close();
end;
procedure TForm1.Label1EndDrag(Sender, Target: TObject; X, Y: Integer);
begin
label1.Left:=panel1_x-label1_x;
label1.top :=panel1_y-label1_y;
end;
procedure TForm1.Panel1DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
panel1_x:=x;
panel1_y:=y;
end;
procedure TForm1.Panel1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
panel1_x:=x;
panel1_y:=y;
end;
procedure TForm1.Label1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if button = mbleft
then label1.Color:=cllime;
end;}
end.