Home |
Class PegHScroll HMI (Human-Machine Interface) Classes |
Class PegHScrollPegHScroll is a horizontal scroll bar class. The scroll bar elevator is proportional to the visible area of the object being scrolled. PegHScroll takes two forms. The most common form is a NONCLIENT area scroll bar. In this form PegHScroll calls the parent window GetHScrollInfo function to determine position, size, and limit information. An instance of this form of PegHScroll has PSF_NONCLIENT system status. The second form is a client area scroll bar. This form does not have PSF_NONCLIENT system status. This type of scroll bar is under system software control, and does not attempt to automatically determine position and limit information. Client area PegHScroll objects are very similar in operation to PegSlider objects. They are useful for allowing the user to update a field on the display by dragging the scroll elevator or selecting the directional scrolling buttons. struct PegScrollInfo { int wMin; int wMax; int wCurrent; int wStep; int wVisible; }; class PegHScroll : public PegThing { public: PegHScroll(void); PegHScroll(const PegRect &InRect, PegScrollInfo * Info, PEGUINT wId = 0); virtual PEGINT Message(const PegMessage &Mesg); virtual void Draw(void); PegScrollInfo GetScrollInfo(void); void Reset(void); void Reset(PegScrollInfo * Info); void Resize(PegRect Rect); }; SignalsPegHScroll sends PSF_SCROLL_CHANGE signals when the position of the scroll bar elevator is changed either by dragging the elevator or by selecting the directional scroll buttons. lData is the current scroll position. iData has the last reported scroll position. pSource pointers to PegHScroll object. ConstructorsThe first constructor creates a non-client area scroll bar. The scroll bar will automatically determine its position and size itself to the width of the parent window. The second constructor creates a client area scroll bar. In this mode, a pointer to a PegScrollInfo structure is passed to setup the initial scrolling range. In this mode the scroll bar position and size are passed to the constructor, along with the scroll bar ID, if any. Method DrawPegHScroll overrides the Draw() function to fill the scroll bar background area. Method GetScrollInfoRetrieves the current scroll bar information. Method MessagePegHScroll catches PM_SHOW, directional button selection and elevator drag messages. Method ResetRecalculates or resets scroll bar position. The first form is used with non-client scroll bars, and the second form is used with client-area scroll bars that are under program control. Method ResizePegHScroll overrides the Resize() function to insure that the elevator remains proportional to the overall scroll bar size. Examples:The following are examples of PegHScroll: The following example initializes a PegScrollInfo structure and creates a client area scroll bar. The scroll bar will report values between 0 and 200, will initially be positioned at 100, and the scroll bar elevator will be 25% as wide as the scroll bar. void MyWindow::AddHScroll(void) { PegScrollInfo si; si.wMin = 0; si.wMax = 200; si.wCurrent = 100; si.wStep = 1; si.wVisible = 50; PegRect ScrollRect; ScrollRect.Set(10, 10, 120, PEG_SCROLL_WIDTH + 10); Add(new PegHScroll(ScrollRect, &si)); }
|