Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Drawing / November 2004

Tip: Looking for answers? Try searching our database.

Problem with Text

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
THeavey - 29 Nov 2004 22:40 GMT
In the following code the text will not display if I use the
stringFormat in the Drawstring and will separate the two strings if I
do not use the stringFormat:

graph = e.Graphics;
pen = new Pen(Color.Black,2);

//graph.DrawLine( pen,100,100,200,100);
drawFont = new System.Drawing.Font("Arial", 8, FontStyle.Bold);
drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);

String sTest = "MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM";
Region[] stringRegions = new Region[1];
StringFormat stringFormat = new StringFormat();
stringFormat = StringFormat.GenericDefault;
stringFormat.Trimming = System.Drawing.StringTrimming.Character;
stringFormat.FormatFlags += 16384;
//graph.TextRenderingHint = TextRenderingHint.AntiAlias;
CharacterRange[] characterRanges = new CharacterRange[1];
characterRanges[0] = new CharacterRange(0,sTest.Length);
stringFormat.SetMeasurableCharacterRanges(characterRanges);
stringRegions = graph.MeasureCharacterRanges( sTest, drawFont,
this.ClientRectangle, stringFormat);
RectangleF rect = stringRegions[0].GetBounds(graph);
//rect.Offset(10,10);
//graph.DrawString(sTest,drawFont,drawBrush,rect);
graph.DrawString(sTest,drawFont,drawBrush,rect,stringFormat);
rect.Offset(rect.Width,0);
//graph.DrawString(sTest,drawFont,drawBrush,rect);
graph.DrawString(sTest,drawFont,drawBrush,rect,stringFormat);

Please help
Tom Heavey - 29 Nov 2004 23:03 GMT
I made a mistake in the previous post. The stringFormat should be initialized
with the GenericTypegraphic instead of the GenericDefault.

Thank you

> In the following code the text will not display if I use the
> stringFormat in the Drawstring and will separate the two strings if I
[quoted text clipped - 28 lines]
>
> Please help
Tom Heavey - 29 Nov 2004 23:49 GMT
I have found a solution. If I set the FormatFlags to NoClip the code works.
This brings up a couple of questions. Why does this work and is there a more
complete explanation of the FormatFlags especially the top bit (32K bit) that
is not documented? I am also wondering about the property nativeFormat that
is not documented, but is displayed in the debugger. Some internet help
features say this is a private property. How do private properties get
exposed in the debugging environment?

Thank you,

Tom

> In the following code the text will not display if I use the
> stringFormat in the Drawstring and will separate the two strings if I
[quoted text clipped - 28 lines]
>
> Please help

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.