Dear Paul and others FF3 users,
I find no template or example for writing the event code (message) for schrollbar.
Can anyone post an example of applying a schrollbar with messages for the scrollbar
What code do I post here at "FORM1_HSCROLL1_WM_HSCROLL" because I can move the horizontal scroll bar with small and large steps and the position of the mouse. The scrollbar is separated component of the form (child control)
I would like that someone help me and post an template example that handle the events of the scrollbar.
Example:
======
By clicking on the button the application sends a byte
In this case, the position of a slider is send as a numerical value between 0 and 255.
Each byte is received in a textbox.
Minimum value : 0
Maximum value : 255
LargeChange : 1
SmallChange : 1
'--------------------------------------------------------------------------------
Function FORM1_WM_CREATE ( _
hWndForm As Dword, _ ' handle of Form
ByVal UserData As Long _ ' optional user defined Long value
) As Long
Static lPos As Long
Static lMax As Long
Static lMin As Long
Static lPage As Long
Static lStep As Long
lMin = 0
lMax = 255
lStep = 1
lPage = 1
lPos = lMax / 255
'SetScrollRange(HWND_FORM1_HSCROLL1, %SB_CTL, lMin, lMax, %FALSE)
'SetScrollPos(HWND_FORM1_HSCROLL1,%SB_CTL,lPos,%FALSE)
FF_ScrollBar_SetRange(HWND_FORM1_HSCROLL1, lMin, lMax)
FF_ScrollBar_SetPos(HWND_FORM1_HSCROLL1, lPos, %FALSE)
'Open_SerialPort("COM1:1200,N,8,1")
End Function
'--------------------------------------------------------------------------------
Function FORM1_WM_DESTROY ( _
hWndForm As Dword _ ' handle of Form
) As Long
'Close_SerialPort()
End Function
'--------------------------------------------------------------------------------
Function FORM1_COMMAND1_BN_CLICKED ( _
ControlIndex As Long, _ ' index in Control Array
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
idButtonControl As Long _ ' identifier of button
) As Long
Local d As Long
'De ingestelde waarde opslaan in een variabele van de scrollbar
d = FF_ScrollBar_GetPos (HWND_FORM1_HSCROLL1)
MsgBox Str$(d)
End Function
'--------------------------------------------------------------------------------
Function FORM1_HSCROLL1_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
Local lPos As Long
Local lMax As Long
Local lMin As Long
Local lPage As Long
Local lStep As Long
Select Case LoWrd(nScrollCode)
'==========================================================================
'LargeChange = Grote verandering
'==========================================================================
Case %SB_PAGELEFT
lPos = lPos - lPage
Case %SB_PAGERIGHT
lPos = lPos + lPage
'==========================================================================
'==========================================================================
'SmallChange = Kleine verandering
'==========================================================================
Case %SB_LINELEFT
lPos = lPos - lStep
Case %SB_LINERIGHT
lPos = lPos + lStep
'==========================================================================
'==========================================================================
'Positie van de schrollbar
'==========================================================================
Case %SB_THUMBPOSITION
lPos = HiWrd(nPosition)
lPos = lPos - (lPos Mod lStep)
'Case %SB_THUMBTRACK
'==========================================================================
'==========================================================================
'Begin en einde van verandering
'==========================================================================
Case %SB_LEFT
lPos = 0
Case %SB_RIGHT
lPos = 255
'==========================================================================
'==========================================================================
'Case %SB_PAGEDOWN
'Case %SB_PAGEUP
'==========================================================================
'Case %SB_LINEDOWN
'Case %SB_LINEUP
'==========================================================================
'Case %SB_TOP
'Case %SB_BOTTOM
'==========================================================================
'Case %SB_THUMBPOSITION
'Case %SB_THUMBTRACK
'==========================================================================
End Select
'SetScrollPos(HWND_FORM1_HSCROLL1,%SB_CTL,value,%TRUE)
FF_ScrollBar_SetPos(HWND_FORM1_HSCROLL1, lPos, %TRUE)
End Function
'--------------------------------------------------------------------------------
Function FORM1_TIMER1_WM_TIMER ( _
hWndForm As Dword, _ ' handle of Form
wTimerID As Dword _ ' the timer identifier
) As Long
Local d As Long
SetTimer(HWND_FORM1_TIMER1,IDC_FORM1_TIMER1,500,&0)
'd = Read_Byte()
If(d = 1) Then
FF_TextBox_SetText(HWND_FORM1_TEXT1,Str$(d))
End If
End Function
Screenshot
========
(https://www.planetsquires.com/protect/forum/proxy.php?request=http%3A%2F%2Fimg88.imageshack.us%2Fimg88%2F395%2Fimage2js.jpg&hash=7572bdc626545f76a579146211f76934e03ce012) (http://imageshack.us/photo/my-images/88/image2js.jpg/)
Hi Developers,
Can someone post here an full example that used the scrollbar because I waiting for an example that handled event (message) code for handling the scrollbar in FF3
I have need an example for an scrollbar
Thanks
Stephane
Here is what I have used in the HScroll routine. I think it originally came from one of Paul's posts.
'--------------------------------------------------------------------------------
Function FORM1_HSCROLL1_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
'nScrollCode
'-----------------------------------------------
'SB_BOTTOM Scrolls To the lower Right.
'SB_ENDSCROLL Ends scroll.
'SB_LINEUP Scrolls Up by one unit.
'SB_LINEDOWN Scrolls Down by one unit.
'SB_PAGEUP Scrolls Up by the Width Of the window.
'SB_PAGEDOWN Scrolls Down by the Width Of the window.
'SB_LINELEFT Scrolls Left by one unit.
'SB_LINERIGHT Scrolls Right by one unit.
'SB_PAGELEFT Scrolls Left by the Width Of the window.
'SB_PAGERIGHT Scrolls Right by the Width Of the window.
'SB_THUMBPOSITION Scrolls To the absolute position. The current position is specified by the nPos parameter.
'SB_THUMBTRACK Drags scroll box To the specified position. The current position is specified by the nPos parameter.
'SB_TOP Scrolls To the upper Left.
Local ScrlInfo As SCROLLINFO
Local st As String
ScrlInfo.cbSize = SizeOf(ScrlInfo)
ScrlInfo.fMask = %SIF_ALL
GetScrollInfo hWndControl, %SB_CTL, ByVal VarPtr(ScrlInfo)
Select Case nScrollCode
'Vertical Scroll Code
'Case %SB_LINEUP: Decr ScrlInfo.nPos
'Case %SB_LINEDOWN: Incr ScrlInfo.nPos
'Case %SB_PAGEUP: ScrlInfo.nPos = ScrlInfo.nPos - ScrlInfo.nPage
'Case %SB_PAGEDOWN: ScrlInfo.nPos = ScrlInfo.nPos + ScrlInfo.nPage
'Horizontal Scroll Code
Case %SB_LINELEFT: Decr ScrlInfo.nPos
Case %SB_LINERIGHT: Incr ScrlInfo.nPos
Case %SB_PAGELEFT: ScrlInfo.nPos = ScrlInfo.nPos - ScrlInfo.nPage
Case %SB_PAGERIGHT: ScrlInfo.nPos = ScrlInfo.nPos + ScrlInfo.nPage
'Case %SB_THUMBPOSITION: ScrlInfo.nPos = nPosition
Case %SB_THUMBTRACK: ScrlInfo.nPos = nPosition
Case %SB_ENDSCROLL
End Select
SetScrollInfo hWndControl, %SB_CTL, ByVal VarPtr(ScrlInfo), %TRUE
End Function