Write a few lines of a line using GDI +

I have a small display on my keyboard, this is 320x240, I create a plugin that allows me to see skype messages on this display, even when I play full-screen games.

The biggest problem that I encountered after I decided everything about interacting with skype is that I need to display chat messages in such a small area.

I use a font of size 10 to avoid unreadable text, this will allow me no more than 7 lines and about 40 characters per line.

I need a way to write a line on several lines, I presented some ways, but I do not want to reinvent the wheel, I'm sure someone found a better solution for this, otherwise I could not write this question :)

So, how to write a few lines of a line with gdi + on a 320x240 image? (well, we should consider it 290x240 in size because I have a caption).

+4
source share
1 answer

I solved the problem myself: First, the drawstring method does โ€œwhat I wantโ€ (makes the text fill the rectangle, if possible, otherwise continue to write it, increasing the height rather than the width).

Using the measurement method, you can complete the task.

I was able to split a string into multiple lines using some custom algorithms that spoke well about performance. I will not go into details because the algorithm is focused on my application and is definitely not general.

+3
source

All Articles