[Gambas-user] Printing from a module

Rolf-Werner Eilert eilert-sprachen at ...221...
Thu Nov 15 16:04:59 CET 2012



Am 15.11.2012 14:38, schrieb Tobias Boege:
> On Thu, 15 Nov 2012, Rolf-Werner Eilert wrote:
>> Hi folks, I have a question:
>>
>> In FMain I have a Printer object (Printer icon) and a Button to click on
>> for printing.
>>
>> The whole printing procedure should take place in a separate module to
>> keep the lengthy code apart from FMain code.
>>
>> The Button_Click event calls druck.start in the module "druck". But my
>> printing object "drucker" isn't known there.
>>
>> So, what must I write to switch from FMain to the printing module? How
>> can the module know about my printer object?
>>
>> I have made public the forms, I have made public the Printer object. But
>> still its name ("drucker") is unknown in the module.
>
> If you successfully made your control public, I don't know what could be
> wrong but you can still do druck.start(drucker), i.e. give the object as
> a parameter to the module. This would make the code even more generic ;-)
>
> (It _may_ be possible that you just have to use FMain.drucker but I don't
> remember.)
>
> Regards,
> Tobi
>

That's what I tried at first, but it didn't work, it wondered about the 
"." in the name...


What really helped was giving FMain its own printer object, but I admit 
it just accepts it and nothing really happens. It produces blank pages.

The point is, where do I have to hand over what name? If FMain calls a 
Sub in the module, it should deliver the name of the printer object, but 
it complaints it doesn't know the name.

When I have the printer object on FMain, the module produces a blank 
page and never falls into its own _Draw event because it calls that of 
FMain (at least this is my impression after trying around a bit).

Let me try one more thing...

Yes, this way it runs:

In FMain:

   druck.test

In the module druck:

   Sub test()

   Start()

End

Private Sub Start()

Dim drucker As Printer
drucker = New Printer As "drucker"

   drucker.OutputFile = "~/test.pdf"

   drucker.Print()

End


Public Sub drucker_Draw()

   Paint.Text("Hallo", 20, 20)

End


But it prints a blank page... Where's the text? It does call 
drucker_Draw(), I've checked that...

Rolf




More information about the User mailing list