//----------------------------------------
  {编辑容器的定义}
  TEditSrcb = Class(TScrollbox)
  private
    procedure MouseDown(Sender: TObject; Button: TMouseButton;
                      Shift: TShiftState; X, Y: Integer);
    procedure DragDrop( Sender,Source: TObject; X, Y: Integer);
    procedure DragOver(Sender, Source: TObject; X, Y: Integer;
                         State: TDragState; var Accept: Boolean);
    published
    {publish declarations}
    property LabCount: integer read sLabCount write SetsLabCount;
  protected
    {protected declarations}
  public
    {public declarations}    arryLab: array of TEdtRuleLabel;  //----> array the  TEdtRuleLabel   
                                                         //objects;
    
    constructor Create(AOwner: TComponent;RuleToEdit: string;CHElements:  
            array of TChoosedElements);
    Destructor  Destroy; override;    procedure ReSetLabs;dynamic;
    procedure InitLabsOrder(arryLabels: array of TEdtRuleLabel);
  end;//--------------------------------
//---------------------------------
constructor TEditSrcb.Create(AOwner: TComponent;RuletoEdit: 
                          string;CHElements: array of TChoosedElements);
begin
  inherited create(AOwner); //arryLabels: array of TEdtRuleLabel  OnMouseDown:= MouseDown;
  OnDragOver:= DragOver;
  OnDragDrop:= DragDrop; //---> 说明方式对吗?
  self.Color:= Clgreen;
  ChangeStrToEdtLabels(RuletoEdit,CHElements);
  InitLabsOrder(arryLab);
end;procedure TEditSrcb.DragDrop( Sender,Source: TObject; X, Y: Integer);
begin
  //-------
  {操作步骤//--->问题是X,Y取出的值好像不对。不知道为什么,是不是函数的说明方
   式不对呀?}   
  //--------
end;

解决方案 »

  1.   

    MouseDown、DragOver、DragDrop等函数可以从祖先类继承而来,不需要手工去写一个事件的代码。
    你可以去查ScrollBox等VCL的源码,例子很多,代码写得非常漂亮。
      

  2.   

    这个  你要重载DragDrop
    这样定义    procedure DragDrop(Sender,Source: TObject; X, Y: Integer);override;<--注意这里后面实现的代码这样写
    procedure TEditSrcb.DragDrop( Sender,Source: TObject; X, Y: Integer);
    begin
      inherited;<--注意这里
      //-------
      你的代码.....
      //--------
    end;
      

  3.   

    我觉得你最好不要在创建使用OnDragDrop:= DragDrop,因为可能会使用中修改OnDragDrop的值,最好使用 snowtiger2000(snowtiger)的方法;
    定义:procedure DragDrop(Sender,Source: TObject; X, Y: Integer);override;
    实现:
    procedure TEditSrcb.DragDrop( Sender,Source: TObject; X, Y: Integer);
    begin
      inherited;
      //实现
    end;