Groups | Blog | Home
all groups > dotnet drawing api > february 2008 >

dotnet drawing api : ichTextBox print GDI v.s + GDI+


Damien
2/5/2008 3:08:36 AM
Hi,

I really hope someone can help me with this.
I'm developing a windows application (c#, .NET 2.0).
In my solution I have created a custom control that extends the
RichTextBox control.
The reason for this is because I need to perform certain funtions that
are not directly available through the RichTextBox control. i.e. set
transparent control, load specific dll and ClassName based on OS
(RichEd20, msftedit), etc. Another of the benefits was that I could
use the documented WYSIWYG printing using the method outlined here
http://msdn2.microsoft.com/en-us/library/ms996492.aspx.

My problem is with the WYSIWYG printing and the slight differences
between GDI and GDI+ coordinates and rendering. When I print preview
the control text the font is very slightly in the wrong position and
also a different size. This would normally not be noticable except
that I am using graphics.DrawLine() based on EXACT COORDINATES AND
LETTER SIZE from the extended richtextbox. So the result is that I am
drawing lines that are almost in the correct positionbut not quite.
Unfortuneatly, in this case close is very wrong.

I know that I am mixing GDI and GDI+. And I don't want to loop through
each line in the textbox and use graphics.DrawString() for printing
because there could be images in the control.

Does anybody have any solutions/suggestions for this?

I hope I've been clear enough with my problem.
Thanks,
Bob Powell [MVP]
2/11/2008 10:58:18 AM
You won't find a solution. The two layout systems are different and you'll
never manage to relate one to the other.


--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.


[quoted text, click to view]
AddThis Social Bookmark Button