604
社区成员
发帖
与我相关
我的任务
分享
//重载Paint函数,绘制显示模式
void __fastcall TZoomFFT::Paint()
{
float Scale; //max与控件的实际长度的比例系数
TRect rect=this->ClientRect;
Scale=rect.Width()/(float)FMax;
Canvas->Draw(0,0,backBmp);
Canvas->Brush->Color=FForceColor; //滑块
Canvas->FillRect(TRect((FPageCenter-FPageSize/2)*Scale+dis,1,(FPageCenter+FPageSize/2)*Scale+dis,rect.Height()-2));
}
void __fastcall TZoomFFT::MouseMove(Classes::TShiftState Shift, int X, int Y)
{
if(Canvas->Pixels[X][Y]==FForceColor)
{
Cursor= crSizeAll;
if(canMove)
{
dis=X-oldX;
Invalidate();
}
}
else
Cursor= crDefault;
}
//---------------------------------------------------------------------------
//鼠标在控件上
void __fastcall TZoomFFT::MouseDown(TMouseButton Button,Classes::TShiftState Shift, int X, int Y)
{
canMove=true;
oldX=X;
TRect rect=this->ClientRect;
backBmp->Width=rect.Width();
backBmp->Height=rect.Height();
backBmp->Canvas->Brush->Color=FBackColor; //绘背景
backBmp->Canvas->FillRect(rect);
backBmp->Canvas->Pen->Color=clBlack;
backBmp->Canvas->Pen->Style=psSolid;
backBmp->Canvas->Rectangle(rect);
}