Canvas Only Partially Displays

Good Afternoon

I am a relatively new coder to Xojo and relatively random user!

I have just upgraded an inherited application from 2016R4 to 2020R1.2 and, whilst I have managed to resolve some compilation issues, I have one that I just cannot fix!

I have a reportviewer that uses a canvas with scrollbars, and for some reason, the canvas now only partially displays.

The Canvas has a paint action that contains the following code:

If mCurrentPicture <> Nil Then

g.DrawPicture( mCurrentPicture, 0, 0, Me.Width, Me.Height, Scrollbar2.Value, Scrollbar1.Value, Me.Width, Me.Height )
g.DrawRect( 0, 0, Me.Width, Me.Height )

Else
g.DrawRect( 0, 0, Me.Width, Me.Height )
End If

I have also included a view of the partially displayed canvas!

Can someone please advise what I need to change to make the canvas display properly?

Many thanks

Steve

Looks like mCurrentPicture has a to small width. Can it be?

What happens if you use this Code?

If mCurrentPicture <> Nil Then

  g.DrawPicture( mCurrentPicture, 0, 0, g.Width, g.Height, Scrollbar2.Value, Scrollbar1.Value, g.Width, g.Height )
  g.DrawRect( 0, 0, g.Width, g.Height )

Else

  g.DrawRect( 0, 0, g.Width, g.Height )

End If

Hi Martin

Thanks for the response, but unfortunately that didnā€™t result in any change!

Steve

OK and what about that?

Bit of a guess here as I donā€™t know if this is done using the reporting feature in xojo (which Iā€™ve never used):

How does the canvas look when the window opens?
Does this only happen when you increase the width of the window at runtime?

In the IDE check the locking of the canvas so the right padlock is enabled so the canvas width alters when you make the window wider. Click the canvas then open the inspector and check this is locked.

image

It might also be that the canvas isnā€™t wide enough in the IDE at design time, at which point, set it to where you want it at design time, then click the right side padlock so it expands when/if you alter the window width at runtime.

Also, if the padlock is checked, check that that isnt in the child of something that isnt checked.

Hi Martin

Apologies! You are indeed right, it is only 579 whereas the canvas width is 754, however, I cannot determine where this can be changed!

mDocument is the result of running a Report. The report width, in design, is set at 260 millimeters.

Any ideas from the limited information?

Thanks

Steve

Hi Julian

Thanks for the response!

The canvas looks as per the image uploaded originallyā€¦the final 3rd of the report is not showing. The background is white so Iā€™m guessing that is the report as the final third is gray, as per the canvas within the designer.

All 4 padlocks on the canvas are locked. I have tried unlocking the right hand one and running the application without any changes appearing. As Iā€™ve said previously, this issue has only occurred since recompiling the application with a later xojo compiler, the previous one being 2016!

I did have other issues with this relating to printed documents and specifically using scales. In order to get this sorted quickly, I have had to hardcode some numbers around the scale value (hate doing this but I have a customer who is chasing, Iā€™ll try to resolve this at a later date!). I only mention this in case itā€™s a related issue.

Thanks

Steve

Isnā€™t the width of that white page the ā€œsizeā€ of the paper chosen for the printer youā€™re using? E.g. if I set my default printer to my label printer, running the ListBoxReport example included with Xojo my white page size is tiny, but if I set my default printer to my A4 printer, the white portion is large, but it does have a right extent if I increase the size of the window.

Are you comparing the output from two different computers that have different printers set as default?

The scaling issue you mentioned could be the case as youā€™re limited by the size of the paper, maybe that code made things bigger/smaller so you could ā€œseeā€ more on the page?

Hi Julian

The application in question has a ā€˜Save Printer Settingsā€™ option which I have just run, saving the default as A4, which was previously Letterā€¦this resolved the issue! I also ran one of the reports where I had to hardcode the scaling and these still work so were actually unrelated!

Thanks for pointing me in the right direction.

Steve

2 Likes