CustomSlider

Started by Fred Tomke, October 27, 2009, 06:38:40 AM

Previous topic - Next topic

Fred Tomke

Hello,

now it's on me to publish something. Maybe it could help others, too. I'm looking forward to append another sample for a range selector next week.

Short sample description
Custom slider, custom scrollbar.

Requirements
OpenDCL Runtime 6.0.0.10

Used OpenDCL functionalities

  • Resizable modeless form
  • Preventing a form from closing after pressing Return in the textbox
  • Working with OnPaint event of a picture box
  • Working with temorary drawings and images in a picturebox
  • Working with mouse events
  • Working with integer values in textboxes
  • Working with comboboxes and drop down lists
  • event logging and publishing

Long sample description, genesis
I have a form with a standard windows scroll bar (screenshot). Many users asked me why mouse wheel is not supported for this control. They are familiar with scrolling in listviews but they want to do it with the previews, too. Thatââ,¬â,,¢s why I decided to create my own scrollbar control based on a picture control. The disadvantage of the control is that the current windows style cannot be applied very easy. But there are millions of further possibilities for individual styles.

Features of the test dialog

  • You can scroll the scrollbar/slider by mouse or by keys.
  • You can set the percentage value into the textbox.
  • The small increment can be any value below 20 and below large increment.
  • The large increment can be any value below 50 and over small increment.
  • The styles can be changed between standard scrollbar, picture defined sliders and solid based selectors.
  • The border style can frame the scrollbar if you need. In some cases (like standard scrollbar) it make sense, the bullet style looks much better without frame.
  • The event log demonstrates the events and the given arguments. It should be turned off if it is not needed.

Features of the scrollbar/slider

  • Click left mouse button over the scrollbar button, the value changes a large step up.
  • Click left mouse button below the scrollbar button, the value changes a large step down.
  • Click left mouse button on the scrollbar button, the value is changed to the defined destination.
  • Click right mouse button anywhere on the scrollbar, the value is changed to the defined destination.
  • When scrolling mousewheel up, the value changes a small step up.
  • When scrolling mousewheel down, the value changes a small step down.
  • When scrolling mousewheel while pressing shift key, the value changes in a large step.
  • When pressing PageUp key the value changes a large step up.
  • When pressing PageDown key the value changes a large step down.
  • When pressing Pos1 key the value changes to top.
  • When pressing End key the value changes to bottom.
  • When pressing Left or Up arrow key, the value changes a small step up.
  • When pressing Right or Down arrow key, the value changes a small step down.

Notes for implementation:
If you're interested in doing something like that in a case AutoCAD is going to hard work after each scroll (especially searching for drawings and showing them in a DWGPreview like in the screenshot above) you should decrease the number of scrolling events. So, for example, do only update the previews after OnMouseUp and not while OnMouseMove. The number of calling events is too much for doing that.

Enjoy it!

Fred

[EDIT] Due to some type mismatches I've uploaded a new release of the slider.lsp. Changes only in the documentations.
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]

owenwengerd

Well done, Fred. Do you mind if I include this as a standard sample?
Owen Wengerd (Outside The Box) / ManuSoft

BazzaCAD

Wow looks cool, thx Fred.
a.k.a.
Barry Ralphs
barryDOTralphsATgmailDOTcom

Fred Tomke

Quote from: owenwengerd on October 27, 2009, 07:53:36 AM
Well done, Fred. Do you mind if I include this as a standard sample?

Yes, if you do it, it would be a honor for me.

Fred
Fred Tomke
Dipl.-Ing. (FH) Landespflege

[ landscaper - landscape developer - digital landscape and urban design]