Hi all,
I try to combination schrollbar and/or trackbar to communicate with an timer.
Problem:
======
The user set with the scrollbar or trackbar the value of the timer.
Can someone help me how I can realised this problem with firefly SDK Designer v3
My trial
#INCLUDE Once "C:\headers\port_pb.inc"
'--------------------------------------------------------------------------------
Function FORM1_WM_CREATE ( _
hWndForm As Dword, _ ' handle of Form
ByVal UserData As Long _ ' optional user defined Long value
) As Long
Open_Serialport("COM2:9600,N,8,1")
SetTimer(HWND_FORM1_TIMER1,1,20,0)
End Function
'--------------------------------------------------------------------------------
Function FORM1_TIMER1_WM_TIMER ( _
hWndForm As Dword, _ ' handle of Form
wTimerID As Dword _ ' the timer identifier
) As Long
Local PulseTime As Word
FF_ScrollBar_SetPos(HWND_FORM1_HSCROLL1, PulseTime, 1)
Real_Time(1)
DTR_out(1)
Delay_us(PulseTime)
DTR_out(0)
Real_Time(0)
End Function
I hope this is what you mean. What I did: I created a form with a scrollbar, a timer and two labels. At design time I set the scrollbarvalue at 4 and the timer interval at 4000. If you run this example, just watch and see that every 4 seconds the time is update in lblTime. If you then change the value of the scrollbar, the label lblInterval contains the new value (in text) and the update-interval of the timer changes.
(this is my first test with Firefly scrollbars and timers so maybe others can improve...)
Wilko
Function FORM1_WM_CREATE ( _
hWndForm As Dword, _ ' handle of Form
ByVal UserData As Long _ ' optional user defined Long value
) As Long
Local ScrollBarPos As Dword
'determine design-time value of scrollbar
ScrollBarPos= GetScrollPos(HWND_FORM1_HSB, %SB_CTL)
'and display this in lblInterval
FF_TextBox_SetText(HWND_FORM1_LBLINTERVAL, "current interval: " & Str$(ScrollBarPos))
End Function
'--------------------------------------------------------------------------------
Function FORM1_HSB_WM_HSCROLL ( _
ControlIndex As Long, _ ' index in Control Array
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
nScrollCode As Long, _ ' scroll bar value
nPosition As Long _ ' current scroll bar position
) As Long
'parts here from FF-forum (FF2) February 21, 2009
Local ScrollBarPos As Dword
Local ScrlInfo As SCROLLINFO
ScrlInfo.cbSize = SizeOf(ScrlInfo)
ScrlInfo.fMask = %SIF_ALL
GetScrollInfo hWndControl, %SB_CTL, ByVal VarPtr(ScrlInfo)
Select Case nScrollCode
Case %SB_LINEUP: Decr ScrlInfo.nPos
Case %SB_LINEDOWN: Incr ScrlInfo.nPos
Case %SB_THUMBPOSITION: ScrlInfo.nPos = nPosition
Case %SB_PAGEUP: ScrlInfo.nPos = ScrlInfo.nPos - ScrlInfo.nPage
Case %SB_PAGEDOWN: ScrlInfo.nPos = ScrlInfo.nPos + ScrlInfo.nPage
End Select
SetScrollInfo hWndControl, %SB_CTL, ByVal VarPtr(ScrlInfo), %TRUE
'determine current value of scrollbar
ScrollBarPos= GetScrollPos(HWND_FORM1_HSB, %SB_CTL)
'and display this in lblInterval
FF_TextBox_SetText(HWND_FORM1_LBLINTERVAL, "current interval: " & Str$(ScrollBarPos))
'this part also from FF-forum: September 15, 2007
' Change timer interval. You need to kill the original timer
' and create a new timer with the new interval.
KillTimer hWndForm, IDC_FORM1_TIMER
HWND_FORM1_TIMER = SetTimer(hWndForm, IDC_FORM1_TIMER, ScrollBarPos*1000, ByVal %Null)
End Function
'--------------------------------------------------------------------------------
Function FORM1_TIMER_WM_TIMER ( _
hWndForm As Dword, _ ' handle of Form
wTimerID As Dword _ ' the timer identifier
) As Long
'display the current time just to show that we are here
FF_TextBox_SetText( HWND_FORM1_LBLTIME, Time$)
End Function