Retreiving string pixel width and height
-
I want to get the pixel width and height of a string for a particular font. I have searched the MSDN and i found the function below public: SizeF MeasureString( String^ text, Font^ font } How can i use this function in my VC++ 2005 MFC project? I have tried to use System::Drawing but failed.
-
I want to get the pixel width and height of a string for a particular font. I have searched the MSDN and i found the function below public: SizeF MeasureString( String^ text, Font^ font } How can i use this function in my VC++ 2005 MFC project? I have tried to use System::Drawing but failed.
It seems that your question is depends to Managed C++/CLI forum. ;)
-
I want to get the pixel width and height of a string for a particular font. I have searched the MSDN and i found the function below public: SizeF MeasureString( String^ text, Font^ font } How can i use this function in my VC++ 2005 MFC project? I have tried to use System::Drawing but failed.
The code you found (as Hamid pointed out) is for managed c++ code, and would be best in the CLI forum. You message seems to be confused between .net, and mfc. System::Drawing is not in any way related to MFC. Assuming you're doing MFC, you can select the font into a DC, and use GetTextExtentEx to get dimensions of a string using that font. You need to specify text, as "i" is usually narrower than "W". Iain.
Iain Clarke appears because CPallini still cares.