Printing the contents of a window directly - Problem with listboxes

Hello!

I hava a problem with my listboxes when i print directly my window (the contents of my window).
As i saw from another conversation i made my code like this below:
//start of my code
//me = button, self=window
me.Visible = False
dim g as Graphics
dim mPrinterSetup As New PrinterSetup
mPrinterSetup.Landscape = True
g = OpenPrinterDialog( mPrinterSetup, self)

if g<>nil then
dim p as new Picture( self.Width, self.Height, 32)
self.DrawInto(p.Graphics, 0, 0)
dim gheight as Integer = (g.Width/p.Width*p.Height)

g.DrawPicture(p, 0, 0, g.Width, gheight, 0, 0, p.Width, p.Height)

end if
me.Visible = True
//end of my code

It seems like everything works fine, but ,please, check my link out.(It’s an image of my pdf file)

the image of my pdf

I use XOJO - Version: 2016 Release: 3

try using a newer version of xojo

Looks OK. What are we supposed to see ?

@Michel Bujardet
The lines of my listbox are not on the right position.

I cannot use a newer version of xojo, because of my plugins. In the furute maybe i could, but now it is impossible for my project.

George:
can you add the missing lines in red (with Paint for example) ?

The image as is: I cannot understand what can be wrong.

My guess is that both listbox show blank space that should not be there. The number ‘1’ should be below A/A (top left corner) in both.

[quote=379898:@George Georgiadis]@Michel Bujardet
The lines of my listbox are not on the right position.[/quote]

You could try to do a screen grab instead. It is possible with MBS plugins (Christian, are you here ?), with screencapture on Mac, or with bitblt on Windows.

http://osxdaily.com/2010/07/11/take-a-screen-capture-from-the-command-line/
https://forum.xojo.com/14489-get-the-windows-backcolor/0

Drawinto method is a bad idea.
Better write your own code to format list on a printout.
Paper has a different layout than screen.

But Christian, you do have plugins to do a screen grab, right ?

Of course. But you don’t want to send a screen grab to printer!

If you can’t do the layout yourself, maybe look into table examples for our DynaPDF plugin. The plugin can output a table over several pages with repeating header lines and dynamic cell sizes.

Well, the OP seems to be satisfied with drawinto, and drawing each control would require a significant refactoring.

Thank you very much for your time and your advices. I will try to solve my problem with your advices.

Here’s a copy of my old drawinto fix, see if it works any better for you:

https://www.dropbox.com/s/im8d4ds68e74u61/DrawInto2.xojo_binary_project?dl=1

I just tried to amend <https://xojo.com/issue/47887> to suggest using your method to implement a functional DrawInto for Windows HTMLViewer, but that pesky feedback crashed in my face and lost the case in the process.

Mr @ thank you a lot for your help. Your project fixed my problem.
Thank all of you for your help!