On 2014/02/20 6:57, Ken Thomases wrote:
On Feb 19, 2014, at 3:42 PM, Aric Stewart wrote:
On 2014/02/20 0:32, Ken Thomases wrote:
I don't think this does what you want. GetDC() typically returns a DC whose parameters were reset. It doesn't know what font has previously been used in the window. So, you're basically getting the metrics for the System font. I suppose that may be better than nothing.
I never knew that about GetDC, I did not see anything about reset parameters in MSDN.
It's the first paragraph of the Remarks. http://msdn.microsoft.com/en-us/library/windows/desktop/dd144871%28v=vs.85%29.aspx Don't be confused by the last sentence with its mention of GetTextFace(). That's not a solution to the problem described in the rest of the paragraph; it's a non sequitur.
It was working for me pretty accurately in my testing even with different fonts. Is there a way to get the font metrics from a window handle?
No. This isn't a property of the window in the common case. It's only a property of the DC, which may exist only temporarily while drawing. And one may select various fonts into the DC at different times to draw different parts of the window.
humm, so how should i determine line height?
-aric