This is the trackbar example coming with the installation of IWB.
I added some lines of code to create a line following the slider. But to see a moving line the line at the old position must be colored with the background color to disappear.
I'm unable to change the color of the line. What am I doing wrong ?
Richard
Quote/*
IWBASIC example program
Shows how to create a trackbar CONTROL with CONTROLEX
Compile as a WINDOWS target
*/
/* styles the trackbar can have */
CONST TBS_AUTOTICKS = 0x0001
CONST TBS_VERT = 0x0002
CONST TBS_HORZ = 0x0000
CONST TBS_TOP = 0x0004
CONST TBS_BOTTOM = 0x0000
CONST TBS_LEFT = 0x0004
CONST TBS_RIGHT = 0x0000
CONST TBS_BOTH = 0x0008
CONST TBS_NOTICKS = 0x0010
CONST TBS_ENABLESELRANGE = 0x0020
CONST TBS_FIXEDLENGTH = 0x0040
CONST TBS_NOTHUMB = 0x0080
CONST TBS_TOOLTIPS = 0x0100
/*messages you can send to the trackbar with SENDMESSAGE */
CONST WM_USER = 0x400
CONST TBM_GETPOS = (WM_USER) /* returns position wparam and lparam ignored */
CONST TBM_GETRANGEMIN = (WM_USER+1) /* returns miminum range wparam and lparam ignored */
CONST TBM_GETRANGEMAX = (WM_USER+2) /* returns maximum range wparam and lparam ignored */
CONST TBM_GETTIC = (WM_USER+3) /* returns logical position of tic. wparam = iTic */
CONST TBM_SETTIC = (WM_USER+4) /* inserts a new tic mark. lparam = position */
CONST TBM_SETPOS = (WM_USER+5) /* Sets the slider position. wparam = bRedraw, lparam = position */
CONST TBM_SETRANGE = (WM_USER+6) /* Sets the sliders range (16 bit). wparam = bRedraw, lparam = (high << 16 | low) */
CONST TBM_SETRANGEMIN = (WM_USER+7) /* Sets the sliders minimum range (32 bit). wparam = bRedraw, lparam = min range */
CONST TBM_SETRANGEMAX = (WM_USER+8) /* Sets the sliders maximum range (32 bit). wparam = bRedraw, lparam = max range */
CONST TBM_CLEARTICS = (WM_USER+9) /* clears all tic marks. wparam = bRedraw */
CONST TBM_SETSEL = (WM_USER+10) /* Sets the selection range(16 bit). wparam = bRedraw, lParam = (high << 16 | low) */
CONST TBM_SETSELSTART = (WM_USER+11) /* Sets the selection range(32 bit). wparam = bRedraw, lParam = selection start */
CONST TBM_SETSELEND = (WM_USER+12) /* Sets the selection range(32 bit). wparam = bRedraw, lParam = selection end */
CONST TBM_GETPTICS = (WM_USER+14) /* returns a pointer to an array of UINT values containing the tic positions. Does not include start/end tics */
CONST TBM_GETTICPOS = (WM_USER+15) /* returns the distance (pixels) from the upper left of the CONTROL to the specified tic. wparam = iTic */
CONST TBM_GETNUMTICS = (WM_USER+16) /* returns total number of tics in the Trackbar. wparam and lparam ignored */
CONST TBM_GETSELSTART = (WM_USER+17) /* Returns the starting position of the selection. wparam and lparam ignored */
CONST TBM_GETSELEND = (WM_USER+18) /* Returns the ending position of the selection. wparam and lparam ignored */
CONST TBM_CLEARSEL = (WM_USER+19) /* clears the selection. wParam = bRedraw */
CONST TBM_SETTICFREQ = (WM_USER+20) /* sets the spacing of the tics. wParam = spacing, defaults to 1 */
CONST TBM_SETPAGESIZE = (WM_USER+21) /* sets how far a trackbar moves for pgup,pgdown or clicking in channel. lparam = size */
CONST TBM_GETPAGESIZE= (WM_USER+22) /* returns the current page size. wparam and lparam ignored */
CONST TBM_SETLINESIZE = (WM_USER+23) /* sets how far the track bar slider moves in response to arrow keys. lparam = size */
CONST TBM_GETLINESIZE = (WM_USER+24) /* returns the current LINE size. wparam and lparam ignored */
CONST TBM_GETTHUMBRECT = (WM_USER+25) /* fills in a WINRECT with the dimensions of the thumb CONTROL. lparam = passed WINRECT */
CONST TBM_GETCHANNELRECT = (WM_USER+26) /* fills in a WINRECT with the dimensions of the channel. lparam = passed WINRECT */
CONST TBM_SETTHUMBLENGTH = (WM_USER+27) /* sets the length(or height if vertical) of the thumb slider. wparam = size */
CONST TBM_GETTHUMBLENGTH = (WM_USER+28) /* returns the size of the thumb slider. wparam and lparam ignored */
CONST TBM_SETTOOLTIPS = (WM_USER+29) /* sets the current tooltip CONTROL of the trackbar. wparam = hwnd of the tooltip CONTROL. lparam must be zero */
CONST TBM_GETTOOLTIPS = (WM_USER+30) /* returns the handle to the current tooltip CONTROL if any */
CONST TBM_SETTIPSIDE = (WM_USER+31) /* Positions a ToolTip CONTROL used by a trackbar CONTROL. wparam = Tip Side */
' TrackBar Tip Side flags
CONST TBTS_TOP = 0
CONST TBTS_LEFT = 1
CONST TBTS_BOTTOM = 2
CONST TBTS_RIGHT = 3
CONST TBM_SETBUDDY = (WM_USER+32) :'// wparam = BOOL fLeft; (or right)
CONST TBM_GETBUDDY = (WM_USER+33) :'// wparam = BOOL fLeft; (or right)
'values contained in @WPARAM when receiveing an @IDHSCROLL or @IDVSCROLL message
CONST TB_LINEUP = 0
CONST TB_LINEDOWN = 1
CONST TB_PAGEUP = 2
CONST TB_PAGEDOWN = 3
CONST TB_THUMBPOSITION = 4
CONST TB_THUMBTRACK = 5
CONST TB_TOP = 6
CONST TB_BOTTOM = 7
CONST TB_ENDTRACK = 8
DECLARE IMPORT,GetSysColor(id as INT),UINT
DIALOG d1
UINT hTrackBar
int tempX,offsetX
CREATEDIALOG d1,0,0,250,300,@CAPTION|@SYSMENU|@BORDER,0,"TrackBar",&dialoghandler
CONTROL d1,@STATIC,"",4,10,236,20,0,10
CONTROLEX d1,"msctls_trackbar32","",4,40,236,40,TBS_AUTOTICKS|TBS_FIXEDLENGTH,0,20
offsetX = 120
DOMODAL d1
END
SUB dialoghandler
SELECT @MESSAGE
CASE @IDPAINT
LINE (d1,125,90,125,280,RGB(0,100,0)) ' draw a line before any mouseclick
CASE @IDINITDIALOG
CENTERWINDOW d1
'a fuchsia colored trackbar
SETCONTROLCOLOR d1,20,0,RGB(230,50,150)
'for convenience
hTrackBar = GETCONTROLHANDLE(d1,20)
SENDMESSAGE hTrackBar,TBM_SETRANGEMIN,0,-100
SENDMESSAGE hTrackBar,TBM_SETRANGEMAX,0,100
SENDMESSAGE hTrackBar,TBM_SETTICFREQ,10,0
SENDMESSAGE hTrackBar,TBM_SETPAGESIZE,0,20
SENDMESSAGE hTrackBar,TBM_SETTHUMBLENGTH,20,0
SENDMESSAGE hTrackBar,TBM_SETPOS,TRUE,0
SETCONTROLTEXT d1,10,USING("Current Position: ####",SENDMESSAGE(hTrackBar,TBM_GETPOS,0,0))
CASE @IDCLOSEWINDOW
CLOSEDIALOG d1,@IDOK
CASE @IDHSCROLL: 'or @IDVSCROLL if your trackbar is verical
IF @CONTROLID = 20: 'in case you have more than one
SELECT @WPARAM
CASE TB_LINEUP
CASE& TB_LINEDOWN
CASE& TB_PAGEUP
CASE& TB_PAGEDOWN
CASE& TB_THUMBPOSITION
CASE& TB_THUMBTRACK
CASE& TB_TOP
CASE& TB_BOTTOM
CASE& TB_ENDTRACK
tempX = SENDMESSAGE(hTrackBar,TBM_GETPOS,0,0)' for later use to delete previous line
SETCONTROLTEXT d1,10,USING("Current Position: ####",tempX)
'draw the line following the slider
LINE (d1,tempX+offsetX,90,tempX+offsetX,280,RGB(0,100,0))
ENDSELECT
ENDIF
ENDSELECT
RETURN 0
ENDSUB
all the examples I find for graphics is on WINDOWS and not DIALOGS.
I converted d1 to a WINDOW and rearranged things.
You've still got a scaling issue with the position of the line because the slider pointer doesn't go the full width of the slider control itself.
Maybe you were just wanting to use CONTROLEX but the trackbar control is in the CONTROL PAK. Using it keeps you from having to load your program up with all those constants.
Anyway, here's the revised code:
/*
IWBASIC example program
Shows how to create a trackbar CONTROL with CONTROLEX
Compile as a WINDOWS target
*/
/* styles the trackbar can have */
CONST TBS_AUTOTICKS = 0x0001
CONST TBS_VERT = 0x0002
CONST TBS_HORZ = 0x0000
CONST TBS_TOP = 0x0004
CONST TBS_BOTTOM = 0x0000
CONST TBS_LEFT = 0x0004
CONST TBS_RIGHT = 0x0000
CONST TBS_BOTH = 0x0008
CONST TBS_NOTICKS = 0x0010
CONST TBS_ENABLESELRANGE = 0x0020
CONST TBS_FIXEDLENGTH = 0x0040
CONST TBS_NOTHUMB = 0x0080
CONST TBS_TOOLTIPS = 0x0100
/*messages you can send to the trackbar with SENDMESSAGE */
CONST WM_USER = 0x400
CONST TBM_GETPOS = (WM_USER) /* returns position wparam and lparam ignored */
CONST TBM_GETRANGEMIN = (WM_USER+1) /* returns miminum range wparam and lparam ignored */
CONST TBM_GETRANGEMAX = (WM_USER+2) /* returns maximum range wparam and lparam ignored */
CONST TBM_GETTIC = (WM_USER+3) /* returns logical position of tic. wparam = iTic */
CONST TBM_SETTIC = (WM_USER+4) /* inserts a new tic mark. lparam = position */
CONST TBM_SETPOS = (WM_USER+5) /* Sets the slider position. wparam = bRedraw, lparam = position */
CONST TBM_SETRANGE = (WM_USER+6) /* Sets the sliders range (16 bit). wparam = bRedraw, lparam = (high << 16 | low) */
CONST TBM_SETRANGEMIN = (WM_USER+7) /* Sets the sliders minimum range (32 bit). wparam = bRedraw, lparam = min range */
CONST TBM_SETRANGEMAX = (WM_USER+8) /* Sets the sliders maximum range (32 bit). wparam = bRedraw, lparam = max range */
CONST TBM_CLEARTICS = (WM_USER+9) /* clears all tic marks. wparam = bRedraw */
CONST TBM_SETSEL = (WM_USER+10) /* Sets the selection range(16 bit). wparam = bRedraw, lParam = (high << 16 | low) */
CONST TBM_SETSELSTART = (WM_USER+11) /* Sets the selection range(32 bit). wparam = bRedraw, lParam = selection start */
CONST TBM_SETSELEND = (WM_USER+12) /* Sets the selection range(32 bit). wparam = bRedraw, lParam = selection end */
CONST TBM_GETPTICS = (WM_USER+14) /* returns a pointer to an array of UINT values containing the tic positions. Does not include start/end tics */
CONST TBM_GETTICPOS = (WM_USER+15) /* returns the distance (pixels) from the upper left of the CONTROL to the specified tic. wparam = iTic */
CONST TBM_GETNUMTICS = (WM_USER+16) /* returns total number of tics in the Trackbar. wparam and lparam ignored */
CONST TBM_GETSELSTART = (WM_USER+17) /* Returns the starting position of the selection. wparam and lparam ignored */
CONST TBM_GETSELEND = (WM_USER+18) /* Returns the ending position of the selection. wparam and lparam ignored */
CONST TBM_CLEARSEL = (WM_USER+19) /* clears the selection. wParam = bRedraw */
CONST TBM_SETTICFREQ = (WM_USER+20) /* sets the spacing of the tics. wParam = spacing, defaults to 1 */
CONST TBM_SETPAGESIZE = (WM_USER+21) /* sets how far a trackbar moves for pgup,pgdown or clicking in channel. lparam = size */
CONST TBM_GETPAGESIZE= (WM_USER+22) /* returns the current page size. wparam and lparam ignored */
CONST TBM_SETLINESIZE = (WM_USER+23) /* sets how far the track bar slider moves in response to arrow keys. lparam = size */
CONST TBM_GETLINESIZE = (WM_USER+24) /* returns the current LINE size. wparam and lparam ignored */
CONST TBM_GETTHUMBRECT = (WM_USER+25) /* fills in a WINRECT with the dimensions of the thumb CONTROL. lparam = passed WINRECT */
CONST TBM_GETCHANNELRECT = (WM_USER+26) /* fills in a WINRECT with the dimensions of the channel. lparam = passed WINRECT */
CONST TBM_SETTHUMBLENGTH = (WM_USER+27) /* sets the length(or height if vertical) of the thumb slider. wparam = size */
CONST TBM_GETTHUMBLENGTH = (WM_USER+28) /* returns the size of the thumb slider. wparam and lparam ignored */
CONST TBM_SETTOOLTIPS = (WM_USER+29) /* sets the current tooltip CONTROL of the trackbar. wparam = hwnd of the tooltip CONTROL. lparam must be zero */
CONST TBM_GETTOOLTIPS = (WM_USER+30) /* returns the handle to the current tooltip CONTROL if any */
CONST TBM_SETTIPSIDE = (WM_USER+31) /* Positions a ToolTip CONTROL used by a trackbar CONTROL. wparam = Tip Side */
' TrackBar Tip Side flags
CONST TBTS_TOP = 0
CONST TBTS_LEFT = 1
CONST TBTS_BOTTOM = 2
CONST TBTS_RIGHT = 3
CONST TBM_SETBUDDY = (WM_USER+32) :'// wparam = BOOL fLeft; (or right)
CONST TBM_GETBUDDY = (WM_USER+33) :'// wparam = BOOL fLeft; (or right)
'values contained in @WPARAM when receiveing an @IDHSCROLL or @IDVSCROLL message
CONST TB_LINEUP = 0
CONST TB_LINEDOWN = 1
CONST TB_PAGEUP = 2
CONST TB_PAGEDOWN = 3
CONST TB_THUMBPOSITION = 4
CONST TB_THUMBTRACK = 5
CONST TB_TOP = 6
CONST TB_BOTTOM = 7
CONST TB_ENDTRACK = 8
DECLARE IMPORT,InitCommonControls(),INT
DECLARE IMPORT,GetSysColor(id as INT),UINT
window d1
UINT hTrackBar
int tempX,offsetX,lastX
openwindow d1,0,0,250,300,@CAPTION|@SYSMENU|@BORDER,0,"TrackBar",&dialoghandler
CONTROL d1,@STATIC,"",4,10,236,20,0,10
CONTROLEX d1,"msctls_trackbar32","",4,40,236,40,TBS_AUTOTICKS|TBS_FIXEDLENGTH,0,20
'a fuchsia colored trackbar
SETCONTROLCOLOR d1,20,0,RGB(230,50,150)
'for convenience
hTrackBar = GETCONTROLHANDLE(d1,20)
SENDMESSAGE hTrackBar,TBM_SETRANGEMIN,0,-100
SENDMESSAGE hTrackBar,TBM_SETRANGEMAX,0,100
SENDMESSAGE hTrackBar,TBM_SETTICFREQ,10,0
SENDMESSAGE hTrackBar,TBM_SETPAGESIZE,0,20
SENDMESSAGE hTrackBar,TBM_SETTHUMBLENGTH,20,0
SENDMESSAGE hTrackBar,TBM_SETPOS,TRUE,0
SETCONTROLTEXT d1,10,USING("Current Position: ####",SENDMESSAGE(hTrackBar,TBM_GETPOS,0,0))
offsetX = 122
lastX = SENDMESSAGE(hTrackBar,TBM_GETPOS,0,0)
LINE (d1,lastX+offsetX,90,lastX+offsetX,280,RGB(0,100,0))
waituntil d1=0
END
SUB dialoghandler
SELECT @MESSAGE
CASE @IDPAINT
CASE @IDcreate
CENTERWINDOW d1
CASE @IDCLOSEWINDOW
CLOSEwindow d1
CASE @IDHSCROLL: 'or @IDVSCROLL if your trackbar is verical
IF @CONTROLID = 20: 'in case you have more than one
SELECT @WPARAM
CASE TB_LINEUP
CASE& TB_LINEDOWN
CASE& TB_PAGEUP
CASE& TB_PAGEDOWN
CASE& TB_THUMBPOSITION
CASE& TB_THUMBTRACK
CASE& TB_TOP
CASE& TB_BOTTOM
CASE& TB_ENDTRACK
LINE (d1,lastX+offsetX,90,lastX+offsetX,280,0xffffff)
tempX = SENDMESSAGE(hTrackBar,TBM_GETPOS,0,0)' for later use to delete previous line
SETCONTROLTEXT d1,10,USING("Current Position: ####",tempX)
'draw the line following the slider
LINE (d1,tempX+offsetX,90,tempX+offsetX,280,RGB(0,100,0))
lastX=tempX
ENDSELECT
ENDIF
ENDSELECT
RETURN 0
ENDSUB
LarryMc
The same with dialog... (for iwb 2) :
/*
iwbasic example program
Shows how to create a trackbar CONTROL with CONTROLEX
Compile as a WINDOWS target
*/
/* styles the trackbar can have */
CONST TBS_AUTOTICKS = 0x0001
CONST TBS_VERT = 0x0002
CONST TBS_HORZ = 0x0000
CONST TBS_TOP = 0x0004
CONST TBS_BOTTOM = 0x0000
CONST TBS_LEFT = 0x0004
CONST TBS_RIGHT = 0x0000
CONST TBS_BOTH = 0x0008
CONST TBS_NOTICKS = 0x0010
CONST TBS_ENABLESELRANGE = 0x0020
CONST TBS_FIXEDLENGTH = 0x0040
CONST TBS_NOTHUMB = 0x0080
CONST TBS_TOOLTIPS = 0x0100
/*messages you can send to the trackbar with SENDMESSAGE */
CONST WM_USER = 0x400
CONST TBM_GETPOS = (WM_USER) /* returns position wparam and lparam ignored */
CONST TBM_GETRANGEMIN = (WM_USER+1) /* returns miminum range wparam and lparam ignored */
CONST TBM_GETRANGEMAX = (WM_USER+2) /* returns maximum range wparam and lparam ignored */
CONST TBM_GETTIC = (WM_USER+3) /* returns logical position of tic. wparam = iTic */
CONST TBM_SETTIC = (WM_USER+4) /* inserts a new tic mark. lparam = position */
CONST TBM_SETPOS = (WM_USER+5) /* Sets the slider position. wparam = bRedraw, lparam = position */
CONST TBM_SETRANGE = (WM_USER+6) /* Sets the sliders range (16 bit). wparam = bRedraw, lparam = (high << 16 | low) */
CONST TBM_SETRANGEMIN = (WM_USER+7) /* Sets the sliders minimum range (32 bit). wparam = bRedraw, lparam = min range */
CONST TBM_SETRANGEMAX = (WM_USER+8) /* Sets the sliders maximum range (32 bit). wparam = bRedraw, lparam = max range */
CONST TBM_CLEARTICS = (WM_USER+9) /* clears all tic marks. wparam = bRedraw */
CONST TBM_SETSEL = (WM_USER+10) /* Sets the selection range(16 bit). wparam = bRedraw, lParam = (high << 16 | low) */
CONST TBM_SETSELSTART = (WM_USER+11) /* Sets the selection range(32 bit). wparam = bRedraw, lParam = selection start */
CONST TBM_SETSELEND = (WM_USER+12) /* Sets the selection range(32 bit). wparam = bRedraw, lParam = selection end */
CONST TBM_GETPTICS = (WM_USER+14) /* returns a pointer to an array of UINT values containing the tic positions. Does not include start/end tics */
CONST TBM_GETTICPOS = (WM_USER+15) /* returns the distance (pixels) from the upper left of the CONTROL to the specified tic. wparam = iTic */
CONST TBM_GETNUMTICS = (WM_USER+16) /* returns total number of tics in the Trackbar. wparam and lparam ignored */
CONST TBM_GETSELSTART = (WM_USER+17) /* Returns the starting position of the selection. wparam and lparam ignored */
CONST TBM_GETSELEND = (WM_USER+18) /* Returns the ending position of the selection. wparam and lparam ignored */
CONST TBM_CLEARSEL = (WM_USER+19) /* clears the selection. wParam = bRedraw */
CONST TBM_SETTICFREQ = (WM_USER+20) /* sets the spacing of the tics. wParam = spacing, defaults to 1 */
CONST TBM_SETPAGESIZE = (WM_USER+21) /* sets how far a trackbar moves for pgup,pgdown or clicking in channel. lparam = size */
CONST TBM_GETPAGESIZE= (WM_USER+22) /* returns the current page size. wparam and lparam ignored */
CONST TBM_SETLINESIZE = (WM_USER+23) /* sets how far the track bar slider moves in response to arrow keys. lparam = size */
CONST TBM_GETLINESIZE = (WM_USER+24) /* returns the current LINE size. wparam and lparam ignored */
CONST TBM_GETTHUMBRECT = (WM_USER+25) /* fills in a WINRECT with the dimensions of the thumb CONTROL. lparam = passed WINRECT */
CONST TBM_GETCHANNELRECT = (WM_USER+26) /* fills in a WINRECT with the dimensions of the channel. lparam = passed WINRECT */
CONST TBM_SETTHUMBLENGTH = (WM_USER+27) /* sets the length(or height if vertical) of the thumb slider. wparam = size */
CONST TBM_GETTHUMBLENGTH = (WM_USER+28) /* returns the size of the thumb slider. wparam and lparam ignored */
CONST TBM_SETTOOLTIPS = (WM_USER+29) /* sets the current tooltip CONTROL of the trackbar. wparam = hwnd of the tooltip CONTROL. lparam must be zero */
CONST TBM_GETTOOLTIPS = (WM_USER+30) /* returns the handle to the current tooltip CONTROL if any */
CONST TBM_SETTIPSIDE = (WM_USER+31) /* Positions a ToolTip CONTROL used by a trackbar CONTROL. wparam = Tip Side */
' TrackBar Tip Side flags
CONST TBTS_TOP = 0
CONST TBTS_LEFT = 1
CONST TBTS_BOTTOM = 2
CONST TBTS_RIGHT = 3
CONST TBM_SETBUDDY = (WM_USER+32) :'// wparam = BOOL fLeft; (or right)
CONST TBM_GETBUDDY = (WM_USER+33) :'// wparam = BOOL fLeft; (or right)
'values contained in @WPARAM when receiveing an @IDHSCROLL or @IDVSCROLL message
CONST TB_LINEUP = 0
CONST TB_LINEDOWN = 1
CONST TB_PAGEUP = 2
CONST TB_PAGEDOWN = 3
CONST TB_THUMBPOSITION = 4
CONST TB_THUMBTRACK = 5
CONST TB_TOP = 6
CONST TB_BOTTOM = 7
CONST TB_ENDTRACK = 8
DECLARE IMPORT,GetSysColor(id as INT),UINT
DIALOG d1
UINT hTrackBar
int tempX, oldx,offsetX
CREATEDIALOG d1,0,0,250,100,@CAPTION|@SYSMENU|@BORDER,0,"TrackBar",&dialoghandler
CONTROL d1,@STATIC,"",4,10,236,20,0,10
CONTROLEX d1,"msctls_trackbar32","",4,40,236,40,TBS_AUTOTICKS|TBS_FIXEDLENGTH,0,20
offsetX = 122
DOMODAL d1
END
SUB dialoghandler
SELECT @MESSAGE
CASE @IDPAINT
' LINE (d1,125,90,125,280,RGB(0,100,0)) ' draw a line before any mouseclick
RASTERMODE d1, @RMCOPYPEN
CASE @IDINITDIALOG
CENTERWINDOW d1
'a fuscia colored trackbar
SETCONTROLCOLOR d1,20,0,RGB(230,50,150)
'for convenience
hTrackBar = GETCONTROLHANDLE(d1,20)
SENDMESSAGE hTrackBar,TBM_SETRANGEMIN,0,-100
SENDMESSAGE hTrackBar,TBM_SETRANGEMAX,0,100
SENDMESSAGE hTrackBar,TBM_SETTICFREQ,10,0
SENDMESSAGE hTrackBar,TBM_SETPAGESIZE,0,20
SENDMESSAGE hTrackBar,TBM_SETTHUMBLENGTH,20,0
SENDMESSAGE hTrackBar,TBM_SETPOS,TRUE,-100
SETCONTROLTEXT d1,10,USING("Current Position: ####",SENDMESSAGE(hTrackBar,TBM_GETPOS,0,0))
CASE @IDCLOSEWINDOW
CLOSEDIALOG d1,@IDOK
'trackbars are basically scrollbars so we can use most of the same techniques.
CASE @IDHSCROLL: 'or @IDVSCROLL if your trackbar is verical
IF @CONTROLID = 20: 'in case you have more than one
SELECT @WPARAM
CASE TB_LINEUP
CASE& TB_LINEDOWN
CASE& TB_PAGEUP
CASE& TB_PAGEDOWN
CASE& TB_THUMBPOSITION
CASE& TB_THUMBTRACK
CASE& TB_TOP
CASE& TB_BOTTOM
CASE& TB_ENDTRACK
SETCONTROLTEXT d1,10,USING("Current Position: ####",SENDMESSAGE(hTrackBar,TBM_GETPOS,0,0))
'frontpen d1,getsyscolor(15)
tempX = SENDMESSAGE(hTrackBar,TBM_GETPOS,0,0)' for later use to delete previous line
LINE (d1,oldX+offsetX,90,oldX+offsetX,280,getsyscolor(15))
LINE (d1,tempX+offsetX,90,tempX+offsetX,280,RGB(0,100,0))
oldx=tempx
ENDSELECT
ENDIF
ENDSELECT
RETURN 0
ENDSUB
Thanks Larry, thanks Zaphod.
@Larry
QuoteUsing it keeps you from having to load your program up with all those constants.
Does this mean that defining all those constants is already included in the trackbar control ?
Richard
This is what is predefined in the controlpak.incc file which handles most cases.
'*************Trackbar control*************
$command TrackBarControl(win as WINDOW,l as INT,t as INT,w as INT,h as INT,flags as INT,exStyle as INT,id as UINT),UINT
$command SetTrackBarRange(win as WINDOW,id as UINT,min as INT,max as INT)
$command GetTrackBarRangeMin(win as WINDOW,id as UINT),INT
$command GetTrackBarRangeMax(win as WINDOW,id as UINT),INT
$command GetTrackBarPosition(win as WINDOW,id as UINT),INT
$command SetTrackBarPosition(win as WINDOW,id as UINT,pos as INT)
$command GetTrackBarPageSize(win as WINDOW,id as UINT),INT
$command SetTrackBarPageSize(win as WINDOW,id as UINT,size as INT)
$command GetTrackBarLineSize(win as WINDOW,id as UINT),INT
$command SetTrackBarLineSize(win as WINDOW,id as UINT,size as INT)
$command SetTrackBarTickFreq(win as WINDOW,id as UINT,freq as INT)
$command SetTrackBarThumbLength(win as WINDOW,id as UINT,length as INT)
SETID "TB_LINEUP", 0
SETID "TB_LINEDOWN", 1
SETID "TB_PAGEUP", 2
SETID "TB_PAGEDOWN", 3
SETID "TB_THUMBPOSITION", 4
SETID "TB_THUMBTRACK", 5
SETID "TB_TOP", 6
SETID "TB_BOTTOM", 7
SETID "TB_ENDTRACK", 8
/* styles the trackbar can have */
SETID "TBS_AUTOTICKS", 0x0001
SETID "TBS_VERT", 0x0002
SETID "TBS_HORZ", 0x0000
SETID "TBS_TOP", 0x0004
SETID "TBS_BOTTOM", 0x0000
SETID "TBS_LEFT", 0x0004
SETID "TBS_RIGHT", 0x0000
SETID "TBS_BOTH", 0x0008
SETID "TBS_NOTICKS", 0x0010
SETID "TBS_ENABLESELRANGE", 0x0020
SETID "TBS_FIXEDLENGTH", 0x0040
SETID "TBS_NOTHUMB", 0x0080
SETID "TBS_TOOLTIPS", 0x0100
LarryMc