|
From: Carlos d. M. <cg...@wo...> - 2002-08-03 22:08:11
|
I want create a bitmap for hold a text string loaded from a file. I have a fixed width, given by the window, but the height depends on the string length, but I don't see any function in the win32 reference which could be used for achieve it in a simple way. Though in it is claimed that the result is width and height GetExtentPoint32 gives the dimensions of the string without considering that it will be displayed in multiple lines, so it gives a lpsize which has the cx length of all the characters of the string and the height of a single line. If I try to work with it in the simple ways (cy = cx /window widht * text height) I get a too short height (it seems to consider newlines as single characters or unextended ones), but if I try to calculate how many newlines are for adding more height I get a bitmap which is still either too long or too short. The book I am read is not useful, because it does not use the way I use, and when it treates about scrolling text hey have a simple example: they have only many short lines, so they know easily the height, and they know that no string will be truncated. If I try to calculate with the MaxCharWidth the chars per line and then calculate the height I still have the bitmap with a size that is too short if the amount of newlines is high. (not solved if then I add a new tmHeight per each newline). Is there some simple way to do what I intend? |