Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Mike

Big problem with Graphics.MeasureString [c#]...

This topic is 5276 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am developing my own text editor and I''m having a huge problem with getting the caret drawn in the correct spot. I''ve been looking at SharpDev trying to find the difference between it''s code and mine. Unfortunatly, that has not helped me. Gerenally the problem is that the caret falls behind where it is supose to be, for example, when you start typing a long word you have "a|", after the word gets long enough, you eventually have "aaaaaaaaaaaaaaaaaaaaaaaa|a" (the caret is one character behind where it is supose to be). This almost seems like a rounding error (the position falling behind little by little each keypress). However, that can''t be the case... In order to place the caret, I use Graphics.MeasureString( string, font, 2000, StringFormat.DefualtTypgraphics).Width (DefaultTypgrphics is what SharpDev uses). I then just set the caret position to that value using Win32 API just like SharpDev. I thought perhpas it was the font, but the font is "Currior New", 12 everywhere, so that''s not it. Has anyone had a similar problem? Any ideas? I''ve been working on this issue for two weeks now with no luck.

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!