Board index » delphi » TRichEdit and NT 4.0

TRichEdit and NT 4.0

I think I have found a bug in the TRichEdit control.
Under WinNT 4.0 when you issue a Print method you
get a Division by Zero error (repeatedly), under Win95
it works fine.

Anyone know of a fix/workaround?

brant
...

 

Re:TRichEdit and NT 4.0


Quote
Brant <bra...@smartt.com> wrote:
>I think I have found a bug in the TRichEdit control.
>Under WinNT 4.0 when you issue a Print method you
>get a Division by Zero error (repeatedly), under Win95
>it works fine.
>Anyone know of a fix/workaround?
>brant
>...

The reason is not exactly straightforward, but here goes:

The default Printer object does not create a permanent DC until the
BeginDoc method is called. The EndDoc method releases the DC.

If you access the Printer.Handle property before BeginDoc is called,
the VCL creates an IC (Information Context). This allows such
information as PageWidth, PageHeight, etc., to be retrieved for the
default printer.

The TRichEdit Print method use EM_SETTARGETDEVICE, and passes it
Printer.Handle. However, the Printer.Handle is accessed _before_ the
BeginDoc method is called. Thus, the control attempts to print on an
information context--which will fail.

I had to dig this out myself and this is my understanding of what
happened. I am open to revisions of my world view. :)

Hope this helps.

David R. Michael
davi...@busprod.com
www.busprod.com/davidrm

Other Threads