BBC BASIC for Windows
Programming >> BBC BASIC language >> Printing
http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1278766020

Printing
Post by JB91 on Jul 10th, 2010, 12:47pm

This thread is not about printing text to the output window, it's abut printing text to the printer. I know how to do it on the normal output window, but how do you print the text that someone has typed in the edit window. This window:

Hedit% = FN_createwindow("EDIT", "", 0, 0, @vdu%!208, @vdu%!212, 0, &200044, 0)

Please help!
Re: Printing
Post by admin on Jul 10th, 2010, 9:14pm

on Jul 10th, 2010, 12:47pm, JB91 wrote:
how do you print the text that someone has typed in the edit window.

There are various ways you might do it but the easiest is probably to read the text out of the edit control and then send that to the printer conventionally. Something like the following will work:

Code:
      SYS "SendMessage", Hedit%, WM_GETTEXTLENGTH, 0, 0 TO L%
      SYS "GlobalAlloc", 0, L%+1 TO F%
      SYS "SendMessage", Hedit%, WM_GETTEXT, L%+1, F%
      *OUTPUT 15
      PRINT $$F%
      *OUTPUT 0
      VDU 2,1,12,3
      SYS "GlobalFree", F% 

Richard.
Re: Printing
Post by JB91 on Jul 12th, 2010, 7:28pm

I have a menu in my program and when I click Print it goes to PROCprint. Am I supposed to put the code there? If so, it comes up with the error of "no such variable"

Please reply
Re: Printing
Post by admin on Jul 12th, 2010, 8:41pm

on Jul 12th, 2010, 7:28pm, JB91 wrote:
If so, it comes up with the error of "no such variable"

A 'No such variable' error should be easy to debug. Using the highlighting in the editor window along with the List Variables utility it should be straightforward to discover what variable it is complaining about.

As the code I listed contains Windows Constants, make sure to run Michael Hutton's 'Add Windows Constants' utility to insert the necessary definitions automatically (or do it yourself manually using API Viewer or whatever your preferred Windows API Reference is).

Richard.
Re: Printing
Post by JB91 on Jul 14th, 2010, 6:56pm

Thanks, it works!