//--------------------------------------------------------------------------- #ifndef SkinTrackBarH #define SkinTrackBarH #include "vcl.h" //--------------------------------------------------------------------------- class PACKAGE TSkinTrackBar : public TPanel { private: TPaintBox *Slider; int FPosition; bool FOrientation, FEnabled; TNotifyEvent FOnChange; int FMax, FMin; int FPageSize; bool bDown; bool bMouse; void __fastcall Paint(void){}; void __fastcall DrawH(TWMMouse &Message); void __fastcall DrawV(TWMMouse &Message); void __fastcall SetMax(int Value); void __fastcall SetMin(int Value); void __fastcall SetPosition(int iPosition); void __fastcall SetOrientation(bool bOrientation); void __fastcall SetEnabled(bool bEnabled); void __fastcall SliderPaint(System::TObject* Sender); void __fastcall CMMouseEnter(System::TObject* Sender); void __fastcall CMMouseLeave(System::TObject* Sender); void __fastcall CMMouseDown(System::TObject* Sender, System::Uitypes::TMouseButton Button, System::Classes::TShiftState Shift, int X, int Y); MESSAGE void __fastcall WMMouseWheel(TWMMouseWheel &Message); MESSAGE void __fastcall WMSize(TWMSize &Message); MESSAGE void __fastcall WMEraseBkgnd(TWMEraseBkgnd &Message); MESSAGE void __fastcall WMLButtonDown(TWMLButtonDown &Message); MESSAGE void __fastcall WMLButtonUp(TWMLButtonUp &Message); MESSAGE void __fastcall WMMouseMove(TWMMouse &Message); BEGIN_MESSAGE_MAP MESSAGE_HANDLER(WM_SIZE, TWMSize, WMSize) MESSAGE_HANDLER(WM_LBUTTONDOWN, TWMLButtonDown, WMLButtonDown) MESSAGE_HANDLER(WM_LBUTTONUP, TWMLButtonUp, WMLButtonUp) MESSAGE_HANDLER(WM_MOUSEWHEEL, TWMMouseWheel, WMMouseWheel) MESSAGE_HANDLER(WM_ERASEBKGND, TWMEraseBkgnd, WMEraseBkgnd) MESSAGE_HANDLER(WM_MOUSEMOVE, TWMMouseMove, WMMouseMove) END_MESSAGE_MAP(TPanel) public: void __fastcall TMouseWheelEvent(System::TObject* Sender, System::Classes::TShiftState Shift, int WheelDelta, const System::Types::TPoint &MousePos, bool &Handled); __fastcall TSkinTrackBar(System::Classes::TComponent* AOwner); __fastcall ~TSkinTrackBar(); __published: __property bool Orientation = {read=FOrientation, write=SetOrientation, default=true}; __property TNotifyEvent OnChange = {read = FOnChange, write = FOnChange ,default = NULL}; __property bool Enabled = {read = FEnabled, write = SetEnabled, default=true }; __property int Max = {read = FMax, write = SetMax, default = 100}; __property int Min = {read = FMin, write = SetMin, default = 0}; __property int PageSize = {read = FPageSize, write = FPageSize, default = 1}; __property int Position = {read = FPosition, write = SetPosition, stored=FPosition, default = 0}; }; #endif /************************************************************ 使用说明: 1、内部参数 设置方向Orientation,最大值Max,最小值Min,位置Position 2、外部接口 OnChange 为 TNotifyEvent类型 3、使用例举 p_Track = new TSkinTrackBar(GeneralDialogPanel1); p_Track->Parent = GeneralDialogPanel1; p_Track->Top = 50; p_Track->Left = 100; p_Track->Width = 100; p_Track->Height = 100; p_Track->Position = 30; //初始位置 p_Track->ParentBackground = true; //是否背景透明,为true则背景为 Parent的背景---默认为true p_Track->Orientation = false; //滑块方向 横向为 true ,纵向为false 默认为 true 横向 p_Track->OnChange = Change; //外部接口Change p_Track->Show(); ************************************************************/