Uses "UI"
Dim x,y As Double
Begin ControlID
%ID_Canvas
%ID_hScroll
End ControlID
Function TBMain() As Long
Local hDlg As DWord '---Used to store window handle of main dialog
hDlg = Dialog_New Pixels, 0, "very wide graphics ", -1, -1, 1200, 775,
%WS_DLGFRAME |
%DS_CENTER |
%WS_CAPTION |
%WS_SYSMENU |
%WS_OVERLAPPEDWINDOW
Dialog Show Modal hDlg, Call cbDialog
End Function
CallBack Function cbDialog() As Long
STATIC lPos, lMin, lMax, lStep, lPage AS LONG
static vVirtualWidth as Long
Select Case CBMSG
Case %WM_INITDIALOG
Control Add Canvas, CBHNDL, %ID_Canvas, "", 50, 10,1000, 400, %WS_BORDER | %WS_CHILD | %WS_VISIBLE
Canvas_Attach(CBHNDL, %ID_Canvas, %FALSE)
vVirtualWidth = 100000
Canvas_SetVirtual(100000, 380)
Canvas_SetView(0,0)
Canvas_Width(2)
Canvas_Clear %BLACK
'---Add a scrollbar big enough to be used with fingers
Control add SCROLLBAR CBHNDL, %ID_hScroll, "", 50, 430,1000, 100
lStep = 2
lPage = 10
lMax = 110 'set maximum to intended max + page size to allow page scroll to max
lMin = 1
lPos = 1
SCROLLBAR_SETPAGESIZE CBHNDL, %ID_hScroll, lPage
SCROLLBAR_SETRANGE CBHNDL, %ID_hScroll, lMin, lMax
SCROLLBAR_SETPOS CBHNDL, %ID_hScroll, lPos
'---Draw something till 2000
For x = 0 To 2000 Step 0.1
y = Sin(x)*20* Rndf(1, 2)*Cos(x/3)^2
Canvas_Width(2)
Canvas_Line( (x*10, y +100), (x*10, y +100) , Rgb(255, 255, 0) )
Canvas_Redraw
Next
CASE %WM_HSCROLL
'Process messages and perform calculations to change thumb position
SELECT CASE LOWRD(CBWPARAM)
CASE %SB_LINELEFT
lPos -= lStep
CASE %SB_LINERIGHT
lPos += lStep
CASE %SB_PAGELEFT
lPos -= lPage
CASE %SB_PAGERIGHT
lPos += lPage
CASE %SB_TOP
lPos = lMin
CASE %SB_BOTTOM
lPos = lMax
CASE %SB_THUMBTRACK
lPos = HI(WORD, CBWPARAM)
lPos -= mod(lPos, lStep)
CASE ELSE
EXIT FUNCTION
END SELECT
'test limits, position thumb and update label showing position
IF lPos > (lMax - lPage) THEN lPos = (lMax - lPage)
IF lPos < lMin THEN lPos = lMin
SCROLLBAR_SETPOS CBHNDL, %ID_hScroll, lPos
Canvas_SetView(vVirtualWidth / 100 * lpos, 0)
End Select
End Function
Bookmarks