Date: 02-16-2022
Return to Index
created by gbSnippets
'Compilable Example: (Jose Includes)
#Compile Exe
#Dim All
#Include "win32api.inc"
%IDC_TrackBar = 500
%ID_Timer = 501
%IDC_Label = 502
Function PBMain () As Long
Local hDlg As Dword
Dialog New 0, "TrackBar",,, 220, 50, %WS_Caption Or %WS_SysMenu, 0 To hDlg
Control Add "msctls_trackbar32", hDlg, %IDC_TrackBar, "", 5, 5, 210, 20, %WS_Child Or %WS_Visible Or %TBS_AutoTicks
Control Send hDlg, %IDC_TrackBar, %TBM_SetRange, 0, Mak(Long, 50, 1000) ' range
Control Send hDlg, %IDC_TrackBar, %TBM_SetTicFreq, 50, 1 ' interval frequency
Control Add Label, hDlg, %IDC_Label, "", 5, 35,150,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Static TimerInterval, iCount As Long
Select Case Cb.Msg
Case %WM_HScroll ' sent on trackbar scrollpos change
If Cb.LParam = GetDlgItem(Cb.Hndl, %IDC_TrackBar) Then
Control Send Cb.Hndl, %IDC_TrackBar, %TBM_GetPos, 0, 0 To TimerInterval 'get pos
KillTimer Cb.Hndl, %ID_Timer
SetTimer Cb.Hndl, %ID_Timer, TimerInterval, 0
Dialog Set Text Cb.Hndl, "TrackBar Timer Interval = " + Str$(TimerInterval)
End If
Case %WM_Timer
Incr iCount
Control Set Text Cb.Hndl, %IDC_Label, "Timer Event Counter: " + Str$(iCount)
End Select
End Function
'gbs_01388
'Date: 10-17-2014
http://www.garybeene.com/sw/gbsnippets.htm