Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2349809
  • 博文数量: 816
  • 博客积分: 10000
  • 博客等级: 上将
  • 技术积分: 5010
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-17 17:57
文章分类

全部博文(816)

文章存档

2011年(1)

2008年(815)

分类:

2008-12-17 18:07:45

控件的内容如下:
__fastcall TFSImageButton::TFSImageButton(TComponent* Owner)
    : TImage(Owner)
{
        OldProc = WindowProc;
        WindowProc = NewProc;
        _FPictureOver   = new TPicture();
        _FPictureDown   = new TPicture();
        _FPictureIdle   = new TPicture();
        _FPictureDis    = new TPicture();

        _FPictureOver->OnChange = PictureChanged;
        _FPictureDown->OnChange = PictureChanged;
        _FPictureIdle->OnChange = PictureChanged;
        _FPictureDis->OnChange  = PictureChanged;
       
        _Down = false;   //-- 鼠标按下判断
        _FEnter = false; //-- 鼠标进入判断
        Cursor = crHandPoint;
       
}
//---------------------------------------------------------------------------
void __fastcall TFSImageButton::NewProc(TMessage& Message)
{

        if(Message.Msg == CM_MOUSEENTER) //--    WM_MOUSEMOVE
            {//-- 进入时
            if( _FEnter == true ) return;   //-- 如果已经进入就退出
            _FEnter = true;
            DrawPicture();
            }
        else if(Message.Msg == CM_MOUSELEAVE) //--   WM_MOUSELEAVE
            {//-- 离开时
            if( _FEnter == false ) return; //-- 如果已经离开就退出
            _FEnter = false;
            DrawPicture();
            }
        else if(Message.Msg == WM_LBUTTONUP)
            {//-- 弹起时
            _Down = false;
            DrawPicture();
            }
        else if(Message.Msg == WM_LBUTTONDOWN)
            {//-- 按下时
            _Down = true;
            DrawPicture();
            }
        OldProc(Message);
       
}
//---------------------------------------------------------------------------
void __fastcall TFSImageButton::DrawPicture(void)   //-- 画图
{
    //TRect       MyRect;         //-- 按钮的面积范围
    TPicture    *tmpPicture;    

    if ( _FEnter && !_Down )     //-- 鼠标进入时
        {
        tmpPicture = _FPictureOver;
        BringToFront();
        }
    else if( _Down && _FEnter  )  //-- 鼠标按下时
        {
        tmpPicture = _FPictureDown;
        }
    else if( (!_Down && !_FEnter) || !_FEnter ) //-- 鼠标离开时
        {
        tmpPicture = _FPictureIdle;
        }

    if( tmpPicture->Graphic == NULL )   //--如果没有图的时候
        {
        if( _FPictureOver->Graphic != NULL )
            {
            Width = _FPictureOver->Width;
            Height = _FPictureOver->Height;
            }
        Picture->Graphic = NULL;
        return;
        }
    Width  = tmpPicture->Graphic->Width;
    Height = tmpPicture->Graphic->Height;
    Picture = tmpPicture;

}
//---------------------------------------------------------------------------
现在的问题是很闪,具体文件下载(因为没有办法上传)

谢谢!

--------------------next---------------------

阅读(1097) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~