Administrator

Administrator

  • Admin
  • 2.2k
  • 1.4m

customed trackbar control problem

Apr 9 2003 4:19 AM
I have made a costomed trackbar like following, but it can't response "valuechanged" event when I use it in a winform. What can I do? thanks using System; using System.Collections; using System.ComponentModel; using System.Drawing; using System.Data; using System.Windows.Forms; namespace CquControl { public class TrackCtrl : System.Windows.Forms.TrackBar { private System.ComponentModel.Container components = null; public TrackCtrl() { this.SetStyle(ControlStyles.UserPaint, true); InitializeComponent(); MouseDown+=new MouseEventHandler(OnMouseDown); //EventHandler for MouseUp MouseUp+=new MouseEventHandler(OnMouseUp); //EventHandler for MouseEnter MouseMove+=new MouseEventHandler(OnMouseMove); /* other initial code */ } protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Component Designer generated code private void InitializeComponent() { components = new System.ComponentModel.Container(); //RotateComponent(); } #endregion protected override void OnPaint(PaintEventArgs pe) { base.OnPaint(pe); /* other paint code */ } private void OnMouseDown(object sender,MouseEventArgs e) { if(e.Button == MouseButtons.Left) { bCaptured = true; this.Invalidate(); } } private void OnMouseUp(object sender,MouseEventArgs e) { if(bCaptured && (e.Button & MouseButtons.Left) != 0) { bCaptured = false; } this.Invalidate(); } private void OnMouseMove(object sender,MouseEventArgs e) { if(bCaptured) { this.Invalidate(); } } } }