Page 1 of 1

PostPosted: Mon Feb 24, 2003 11:23 am
by Red_as_blood
With the createctrl() function can i create scroll bars?

if it is possible how do i control them (with sendmsg function?)

or i must use CE API? because i do not know how to use these librarys

PostPosted: Mon Feb 24, 2003 1:38 pm
by guy
If you want individual scroll bar controls then you need to use CEAPI to set them up. If you just want scroll bars on another control like an EDIT control or a list or combo box then you can simply set a flag in the style for the control when you create it.

The following code is the scroll bar example program included with CEAPI (sbtest.pc):

Code: Select all

#include "/pocketc/winuser.h"

#define IDC_SCROLLBAR 100           // guiid to use for scroll bar

main() {

    HWND        hScrollBar ;        // Window handle for scroll bar
    SCROLLINFO  rScroll ;           // Scroll bar set/read info

    createctrl("SCROLLBAR", "", WS_VISIBLE | WS_CHILD | SBS_HORZ, 0, 100, 100, 200, 25, IDC_SCROLLBAR) ;

    hScrollBar = gethwnd(IDC_SCROLLBAR) ;

    rScroll.cbSize      = 0 ;       // Set by CEAPI interface
    rScroll.fMask       = SIF_ALL ; // Set all parameters
    rScroll.nMin        = 0 ;       // Scroll range is from 0
    rScroll.nMax        = 100 ;     // To 100
    rScroll.nPage       = 0 ;
    rScroll.nPos        = 0 ;
    rScroll.nTrackPos   = 0 ;

//  Setup the scroll bar

    SetScrollInfo(hScrollBar, SB_CTL, &rScroll, 1) ;

//  Sit in a loop reading the current scroll position and where the user has moved it to

    while (TRUE) {

//      Get the current position and user's desired position

        rScroll.fMask = SIF_TRACKPOS | SIF_POS ;
        GetScrollInfo(hScrollBar, SB_CTL, &rScroll) ;

//      Display them both on the screen

        text(100, 150, "" + rScroll.nPos + "    ") ;
        text(100, 175, "" + rScroll.nTrackPos + "    ") ;

//      Update the actual position with where the user wants it to be

        sleep(1) ;
        SetScrollPos(hScrollBar, SB_CTL, rScroll.nTrackPos, 1) ;
    }
}




The scroll bar doesn't update itself, unlike the track bar. If you drag the slider on a scroll bar and let go then it will bounce back to where it was before unless the program repositions it.

Guy
[url]mailto:pcform@pcform.net[/url]
http://www.pcform.net
PocketC CE API interface: http://www.networkdynamics.net/PCForm.html#library
PCForm and CE API forum: http://www.networkdynamics.net/forum