鼠标在窗体上拉一下,得到拉的区域的长,宽,高是多少?
请各位高手指教一下!谢谢!

解决方案 »

  1.   

    在mousedown,和mouseup中处理
    mousedown记录起始点
    mouseup记录结束点
    这两个点即可以确定一个区域
      

  2.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Label1: TLabel;
        Label2: TLabel;
        procedure FormMouseDown(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
        procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      x1,y1:integer;implementation{$R *.dfm}procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      x1:=x;
      y1:=y;
    end;procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      label1.Caption:=inttostr(x-x1);
      label2.Caption:=inttostr(y-y1);
    end;end.
      

  3.   

    窗体上放置两个label,分别显示鼠标拉出的矩形框的长和宽
      

  4.   

    谢谢各位xinxinshou2009 ,bdmh的解答,再请大家请教一个问题,在windows桌面按住鼠标拖动时,会显示一个虚线框。那么在delphi 的窗体,也按住鼠标拖动,也能显示一个长方型的虚线框?
      

  5.   

    谢谢xinxinshou2009 ,bdmh的解答,再请大家请教一个问题,在windows桌面按住鼠标拖动时,会显示一个虚线框。那么在delphi 的窗体,也按住鼠标拖动,也能显示一个长方型的虚线框?
      

  6.   

    如果直接在form或者panel上拖动,不会有虚线框出现。如果需要虚线框出现,必须对form的canvas进行编程