[Gambas-user] Yet another simple printing question !

Tobias Boege taboege at ...626...
Fri Mar 21 12:42:45 CET 2014


On Thu, 20 Mar 2014, Vasilis Kanatas wrote:
> Thanks Rolf-Werner,
> 
> I tried
> Private $hImage As New Image
> and had the same result ! Printing white page!
> 
> What I want is to print the labels of a form or ScrollArea!!
> 
> I also tried to change the *Printing Example of Gambas 3* to make it work
> for my issue. Here's what I did (3 steps):
> 
> 1......I've changed Form_load as following to Grab the contents of
> srcImage.ScrollArea:
> 
> Public Sub Form_Open()
> 
>   Me.Center
> 
>   txtText.Text = File.Load("molly-malone.txt")
>   txtFontText.Text = Font["17"].ToString()
>   Try $hImage = scrImage.Grab
>  ' $hImage = New Image(scrImage.Width, scrImage.Height)
> 
>   'scrImage.ResizeContents($hImage.W, $hImage.H)
>   'scrImage.Refresh
> 
> End
> 

OK, you come immediately from Gambas 2, right? Control.Grab() worked
completely differently in Gambas 2. It took a screenshot of the control,
as you know.

In Gambas 3 it grabs the mouse and keyboard of the program, so that all
mouse and keyboard events produced are raised under that control's event
name. Look it up in the documentation[0].

So no wonder that your page remains empty, as the image you are painting
is also empty. You noticed that there was some problem with Grab(), right?
You use Try on the Grab() line because it would otherwise raise an error.
That's an indication to look at the documentation, especially if you use a
new major version the first time :-)

Regards,
Tobi

[0] http://gambaswiki.org/wiki/comp/gb.qt4/control/grab

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list