How to get Width and Height of a specified number of characters ,font Size , font type and font style.
ex :
font size = 14
font type = "Times New Roman"
font style = "Regular"
No of Characters = 50
What is the width and height ?
From stackoverflow
-
In C++, look at the "GetTextExtent" functions.
For C#, use MeasureString
shubha : i am using MFC , please give me sample code or any example. -
For Windows GDI font/display, use DrawText with the DT_CALCRECT flag in the uFormat parameter. It will calculate and return the bounding box for the string you provide using the font currently selected in the HDC.
shubha : i am using mfc dialog based application,so i have no idea how to calculate width and height , please give me an example.dthorpe : In MFC, DrawText is a member of the CDC class. See MSDN for details: http://msdn.microsoft.com/en-us/library/a6x7y2a4.aspx
0 comments:
Post a Comment