Canvas limit error

Hello Guys,

MacOS Mojave, latest and previous 2 versions.

I have a canvas that gets used similar to a listbox and recently after adding few extra features we discovered that the customers start complaining that the app crashes like crazy, after little debugging we discovered that we get errors on Canvas , with the error :

[quote]An exception of class OutOfBoundsException was not handled. The application mush shut down. Exception Message : Width/Height needs to be in the range 1-32767 [/quote] and my drawing hight apparently reached to 32770. Now because I did not find anything related to this in docs and in the canvas side, can somebody tell me if this is a bug or a Canvas limitation ? so that I know how do I have to handle this for the future. If we release the next implemented feature then 98 % of our customers will start to complain and that is not an option for us .

Second option will be to implement that in the Listbox but that means refactoring a big part of the app so big headache In a short time.

Any help is more than welcomed.

Thanks a lot.

Yes and no.

Read there:

[quote=439572:@Emile Schwarz]Yes and no.

Read there:[/quote]
Hello Emile , read what ? if you go to your link you get [quote]There is currently no text in this page. You can search for this page title in other pages, or search the related logs, but you do not have permission to create this page.[/quote]

Exceptions Exception Reason OutOfBoundsException Raised if Width and Height are outside the range 1 - 32767. OutOfMemoryException Raised if there is not enough memory to create the picture.

I reloaded the page to get the text above…

I guess I found that in the XOJO docs locally In the Language Reference, well that’s a bad news. I guess I will have to find another way of fixing this fast .


The forum automatic link parser has issues with closing parenthesis:
Click here

The docs web site also dislike the case error(s): it reject the URL with wrong cases.

BTW: 32767 is a large number of pixels, I certainly do not know a monitor that is able to display this amount of pixels.

Right. Only draw the portion that you need to display at any given time.

Well as I mentioned in the post, it is used as a history listbox like so I do have it as a canvas with a scroll bar to scroll on the records, I guessed that the drawing part is done automatically when you scroll , never taught that It will take the whole canvas and even if you scroll or not the total amount of pixels is used

And while I was looking on the docs website on the Listbox part while I was searching for options I got this [quote]Databases
A ListBox is often used to display the results of database queries. A ListBox can be populated with the results of a query programmatically. See the example “Database Example” in the Examples folder.[/quote] Now , the [quote]See the example “Database Example” in the Examples folder[/quote] is quite confusing, I checked on the Desktop → Controls → ListBox , I did not find any DatabaseExample there, as for the database part I guess I’ll have to search in each type.

@72 DPI 32767pixels is 455 inches (roughly 37 feet)

Either use the piDog listbox or TableView from the MBS plugins. Both listboxes can be bound to a database.

There is a Forum entry that “documents” how to create a Data On Demand (SQLite --> Listbox) to populate a Listbox from a database.

Sorry, I do not found it. The example used LIMIT (I think) to get a certain number of Records to be displayed…

Sounds like you are creating a huge canvas and then moving the canvas up and down the page.

At the simplest , consider the size of the screen.
if the canvas is full screen, and each row is (say) 50 pixels tall, you can only display <height / 50> = rows at any time.
Instead of drawing all the rows, keep the canvas small, and draw only the rows that are visible.

Eg if you ‘scroll’ the current canvas to a place that shows the 30th record,
instead you want to leave the canvas, but draw only rows of data, starting with the 30th at the top of the canvas, in the Paint() event

eg Canvas doesn’t have 400 rows, it may only have 40 rows, and the data at 0,0 is not the first record in your data, but is one based on the ‘scroll position’, followed by the next 39 of them.

Change the scroll position, repaint the canvas and you see a different set of 40

Thanks to all for the feedback, Jeff Indeed this is what happens, the problem is that the height of each record is dynamically created so if I have a row it can be for example 30 px and if I have 30 lines then it will be like 400 px so hard to estimate, I guess I have to store as well the size and then play with the display.