With The Case Of  Release The Power OF  Visual C++ !   HomeProducts | PurchaseSupport | Downloads  
Download Evaluation
Pricing & Purchase?
E-XD++Visual C++/ MFC Products
Features Tour 
Electronic Form Solution
Visualization & HMI Solution
Power system HMI Solution
CAD Drawing and Printing Solution

Bar code labeling Solution
Workflow Solution

Coal industry HMI Solution
Instrumentation Gauge Solution

Report Printing Solution
Graphical modeling Solution
GIS mapping solution

Visio graphics solution
Industrial control SCADA &HMI Solution
BPM business process Solution

Industrial monitoring Solution
Flowchart and diagramming Solution
Organization Diagram Solution

Graphic editor Source Code
UML drawing editor Source Code
Map Diagramming Solution

Architectural Graphic Drawing Solution
Request Evaluation
ActiveX COM Products
Technical Support
  General Q & A
Discussion Board
Contact Us


Get Ready to Unleash the Power of UCanCode .NET

UCanCode Software focuses on general application software development. We provide complete solution for developers. No matter you want to develop a simple database workflow application, or an large flow/diagram based system, our product will provide a complete solution for you. Our product had been used by hundreds of top companies around the world!

"100% source code provided! Free you from not daring to use components because of unable to master the key technology of components!"

Draw Rotate Text with GetTextExtent and SetTextAlign and ExtTextOut, VC++ Example


Code Snippet

Drawing Rotate Text with GetTextExtent, SetTextAlign and ExtTextOut.

First, create a CFont with the angle of rotation specified in nEscapement. Let your DC select this font and call the following function:

Collapse Copy Code
#include <cmath>
// pDC : pointer to your device-context
// str : the text
// rect: the rectangle
// nOptions: can be a combination of ETO_CLIPPED and ETO_OPAQUE
// (see documentation of ExtTextOut for more details)
void DrawRotatedText(CDC* pDC, const CString str, CRect rect, 
                     double angle, UINT nOptions = 0)
   // convert angle to radian
   double pi = 3.141592654;
   double radian = pi * 2 / 360 * angle;
   // get the center of a not-rotated text
   CSize TextSize = pDC->GetTextExtent(str);
   CPoint center;
   center.x = / 2;
   center.y = / 2;
   // now calculate the center of the rotated text
   CPoint rcenter;
   rcenter.x = long(cos(radian) * center.x - sin(radian) * center.y);
   rcenter.y = long(sin(radian) * center.x + cos(radian) * center.y);
   // finally draw the text and move it to the center of the rectangle
   pDC->ExtTextOut(rect.left + rect.Width() / 2 - rcenter.x, 
          + rect.Height() / 2 + rcenter.y,
                   nOptions, rect, str, NULL);




Copyright ?1998-2022 UCanCode.Net Software , all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.

Please direct your questions or comments to