# Printing.rb run time error

**URL:** <https://www.ruby-forum.com/t/printing-rb-run-time-error/207496>\
**Category:** wxRuby\
**Created:** [May 27, 2011, 12:50am UTC](https://www.ruby-forum.com/t/printing-rb-run-time-error/207496 "2011-05-27T00:50:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [May 27, 2011, 12:50am UTC](https://www.ruby-forum.com/t/printing-rb-run-time-error/207496/1 "2011-05-27T00:50:39Z")

</div>

I have attached a copy of printing.rb for reference.

When running this program which I got from the samples is that it gets  
an  
error under the following scenario.

1.0 Run the program.  
2.0 Select the File/PageSet up menu  
3.0 Hit ok on the page set up dialog.  
4.0 Run your mouse over the window that exists after the dialog closes  
5.0 The program dies.

a. My best guess is that the dc shown in MyCanvas class (line 196 in  
the  
attachment) has been somehow lost during the page set up dialog  
processing.  
I am such a Ruby newbie that I don’t know if this could be correct.

b. It appears that the on\_draw(dc) at line 196 is called from Windows.  
If  
my hypothesis about the dc being lost is correct, how could I capture,  
save,  
and restore it. All my attempts have failed.

c. I am digging through the printing.rb sample and putting in comments  
as I  
understand it better. My plan is to send the commented version  
somewhere  
when I finish it so that it will be easier for other Ruby newbies to  
understand.

- Where would I send it when I finish adding comments?\*
