YOU CAN CODE!

 

With The Case Of UCanCode.net  Release The Power OF  Visual C++ !   HomeProducts | PurchaseSupport | Downloads  
Download Evaluation
Pricing & Purchase?
E-XD++Visual C++/ MFC Products
Overview
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
Purchase
ActiveX COM Products
Overview
Download
Purchase
Technical Support
  General Q & A
Discussion Board
Contact Us

Links

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!"


VC++ Codes: Draw text along line and draw rotate text

 
 

draw text along line or draw rotate text


void CAestheticLinesView::OnLButtonUp(UINT nFlags, CPoint point) 
{
	 // If the left mouse button is released while we're tracking, release
    // the mouse if it's currently captured, erase the last rubber-band
    // line, and draw a thick red line in its place.
    //
    if (m_bTracking)
	{
        m_bTracking = FALSE;
        if (GetCapture () == this)
            ::ReleaseCapture ();

        CClientDC dc (this);
        InvertLine (&dc, m_ptFrom, m_ptTo);

		CPen pen (PS_SOLID, 2, RGB (0, 128,0));
		dc.SelectObject (&pen);


		//Draw the line 
		//You may uncomment thee following two lines ,to show line 
		// dc.MoveTo (m_ptFrom);
		// dc.LineTo (point);



		//calculate the slope of this line
		if(point.x-m_ptFrom.x==0) return;
		float slope= -(point.y -m_ptFrom.y)/(point.x-m_ptFrom.x);
		//find the inclination 
		float ang=atan2(m_ptFrom.y-point.y,point.x-m_ptFrom.x)*180.0f/3.1415927f;


		LOGFONT lf;
		lf.lfCharSet=SYMBOL_CHARSET;//For Symbol Fonts like  "Wingdings"
		lf.lfHeight=60;
		lf.lfEscapement=(long)ang*10;//Angle of the text
		lf.lfOrientation=(long)ang*10;//Angle of the text
		lf.lfItalic=false;
		lf.lfStrikeOut=false;
		lf.lfUnderline=false;
		lf.lfQuality=ANTIALIASED_QUALITY;
		//	lf.lfWeight=FW_BOLD;

		strcpy(lf.lfFaceName,_T("Wingdings"));//Select the desired font
		//strcpy(lf.lfFaceName,_T("Webdings"));//Select the desired font



		CFont fnt;
		fnt.CreateFontIndirect(&lf);//Create a Font object for the current Font
		dc.SetBkMode(TRANSPARENT);//To see that there's no clutter incase of overlap 
		dc.SelectObject(fnt);//Select the font for drawing text



		CString str;
		str=0x96;//0x5A ; //0xCB;//0x5E;//0x5D;//0xCB;//0x5c;//Hexadecimal value of the desired character/symbol from Character Map



		CSize sz=dc.GetTextExtent(str);//Do not use strlen() function
		int textwidth= sz.cx;//Widht of Symbol in pixels for the currently selected  Font



		//Length of line segement 
		float dist= sqrt( (point.y - m_ptFrom.y  )*(point.y-m_ptFrom.y )+(point.x-m_ptFrom.x)*(point.x-m_ptFrom.x) ) ;


		//Add Symbol to the text until the width of string is less than length of line
		while(textwidth < dist )
		{

		  str+=0x96;// 0x5A ; //0xCB;  //0x5E;//0x5D;//0xCB;//0x5c;

		  textwidth=dc.GetTextExtent(str).cx;

		}

		//dc.SetTextAlign(TA_BASELINE);
		dc.SetTextColor(RGB(0,128,0));
		dc.TextOut(m_ptFrom.x,m_ptFrom.y,str);//Voila !! , Here's is the Line Pattern


		}

		CView::OnLButtonUp(nFlags, point);
}

 

 

Copyright ?1998-2024 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 webmaster@ucancode.net