Maximum width of canvas = 1348921, but why?
OK, here I am with my silly virtual canvas questions again.
Here is a sample program:
Code:
Uses "UI"
Uses "OS"
Uses "GDIP"
'---Constant declarations
Begin ControlID
%ID_Canvas,
End ControlID
%CANVAS_LENGTH = 1348921 ' Width of graph in pixels
%CANVAS_HEIGHT = 380 ' Height of graph in pixels
%VP_WIDTH = 1000 ' Width, in pixels, of viewport into canvas
'------------------------------------------------------------------------------
' Program start point
'------------------------------------------------------------------------------
Function TBMain() As Long
Local hDlg As DWord '---Used to store window handle of main dialog
'---Create a new dialog
hDlg = Dialog_New Pixels, 0, "Canvas Test", -1, -1, 1020, 420,
%WS_DLGFRAME |
%DS_CENTER |
%WS_CAPTION |
%WS_SYSMENU |
%WS_OVERLAPPEDWINDOW
'---Show dialog in modal mode
'---cbDialog function is the callback function handling dialog events
'---Application control will pass to dialog callback till dialog will exists
Dialog Show Modal hDlg, Call cbDialog
End Function
'------------------------------------------------------------------------------
' Callback procedure for main window
'------------------------------------------------------------------------------
CallBack Function cbDialog() As Long
Select Case CBMSG
Case %WM_INITDIALOG
Local i As Long
'---Add controls
Control Add Canvas, CBHNDL, %ID_Canvas, "", 10, 10, %VP_WIDTH, %CANVAS_HEIGHT + 20, %WS_BORDER | %WS_CHILD | %WS_VISIBLE | %SS_NOTIFY, Call cbDialog
Canvas_Attach(CBHNDL, %ID_Canvas, TRUE)
' Set the canvas to be very wide (virtualy)
Canvas_SetVirtual(%CANVAS_LENGTH, %CANVAS_HEIGHT)
Canvas_SetView(0, 0)
' Write something on the canvas so we can know when it moves
For i = 1 To %CANVAS_LENGTH Step 100
Canvas_SetPos(i, 100)
Canvas_Print(i)
Next i
End Select
End Function
Now, if you run this program, it will work just fine. You can use the thumb to drag the canvas underneath the viewport, and you can see all of the numbers (showing that you have access to the whole canvas).
But if you use %CANVAS_LENGTH = 1348922 (just one more than is in the program above) then it will not work. The canvas will not scroll around, and you can't see any more of the numbers.
But why? My computer has tons of RAM (32GB). Could it be possible to use canvases that are much, much bigger than this? (say 21600000 pixels wide) I have 250 data points coming in from my embedded system every second, and I'd like to be able to graph 24 hours of data on one canvas.
Everything works wonderfully up to 1348921.
I think it has to do with the total size (area) of the canvas, because if I reduce the canvas height I can increase the width.
Is it because 1348922 * 380 * 4 is getting close to 2^31?
*Brian