Jump to content
  • Advertisement


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


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

This topic is 5358 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

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!