Write multiple line string with GDI+
I have a small display on my keyboard, it's 320x240, I'm creating a plugin that allows me to see skype messages on this display even when I'm playing full screen games.
The biggest problem I have, after solving all things about interacting with skype, is that I need to show chat messages in such a small area.
I'm using a font with size 10 to avoid unreadable text, this will allow me nothing more than 7 lines and around 40 characters per line.
I need a way to write a string on multiple lines, I've imagined some ways but I don't want to reinvent the wheel, I'm开发者_StackOverflow中文版 sure someone found the best solution for this, otherwise I couldn't have written this question :)
So, how to write multiple line string with gdi+ on an image of size 320x240? (well, we should consider it of size 290x240 because I have a header).
I solved the problem by myself: First, drawstring method do already "what i want" (makes the text fill a rectangle, if possible, otherwise keep writing it increasing height and not width).
With measurestring method, you can do the job.
I managed to split the string in multiple lines using some custom algorithms that worked well talking about performance. I won't enter into details because the algorithm is focused on my application and is definitely not generic.
精彩评论