很多控件只有鼠标移入事件OnMouseMove,但是我不知道鼠标移出控件时会激发什么事件。
    我想实现当鼠标移到控件(比如Panel)上时,控件的颜色发生变化,移出时控件颜色恢复。请各位不吝赐教,谢谢。

解决方案 »

  1.   

    1.使用外部控件的时候应该是不要专门在安装包中进行加载的
    2.不会自动注册,需要你在特定步骤指定注册
      具体放在那里,你可以找找相关资料,这个偶也不太清楚
    3.好好看看帮助吧,打包制作程序不是很复杂啊从TPanel上派生一个子类,如下
    TMyPanel=class(TPanel)
    protected
      procedure CMMouseLeave(var Msg:TMessage);override;   
    end;
    然后覆盖CMMouseLeave如下
    ...
    begin
      Inherited;
      ShowMessage('Leaving');
    end;
    最后在程序的初始化部分注册,如下
    initialization
      RegisterClass(TMyPanel);
    将这个单元文件引用到你需要使用的地方
    然后动态创建TMyPanel的对象(不要忘记指定Parent属性,否则不会显示的)
    当鼠标离开的时候就显示内容为‘Leaving’的对话矿了
      

  2.   

    分别在Form 和 Pane 的OnMouseMove事件中编程。
    在Pane 的 OnMouseMove 的事件中改变Pane 的颜色;
    在Form 的 OnMouseMove 的事件中把Pane 的颜色改变回来
      

  3.   

    procedure CMMouseEnter(var Msg: TMessage); message CM_MOUSEENTER;  
        procedure CMMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE;procedure TLabelEx.CMMouseEnter(var Msg: TMessage);
    begin
      FOldColor :=  Font .Color  ;
    // if msg.LParam=integer(pc_Main ) then
    //    showmessage('fsdkfs');
      Font.Color :=ColorMove;
      self.Top :=self.Top -1;
      Font.Style :=Font.Style+[fsunderline];
    end;procedure TLabelEx.CMMouseLeave(var Msg: TMessage);
    begin
      Font.Color :=FOldColor;
      self.Top :=self.Top +1;
      Font.Style :=Font.Style-[fsunderline];
    end;