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


E-XD++ GDI VC++ Drawing Example: Draw Animate Line with CBrush

With E-XD++ you can create any custom shape quickly and easily, for example, if you want to create a new custom shape like below, E-XD++ will be the best component to build and Drawing Tool, below is a new link line with animate state:

  • Introduction

    This article shows the use of a animate line. The code is encapsulated in a E-XD++ MFC class. The class itself is derived from a CFODrawShape class. The code demonstrates the how perform flicker free drawing. The control works in a similar way to the standard Windows line.

    The main core of the code is in the drawing routine (OnDraw3d and OnDrawFlat).

    The public interface to access the class is shown here...

    void CAnimatedLinkShape::OnDrawFlat(CDC *pDC)
    {
    CFOLinkShape::OnDrawFlat(pDC);

    DoStartTimer();
    //FODO:Add your own code below.
    if (mySeg >= GetPointCount()-1)
    mySeg = 0;
    FOPPoint a = GetPointAt(mySeg);
    FOPPoint b = GetPointAt(mySeg+1);
    float len = (float)sqrt((b.x-a.x)*(b.x-a.x) + (b.y-a.y)*(b.y-a.y));
    float x = (float)b.x;
    float y = (float)b.y;
    if (myDist >= len)
    {
    mySeg++;
    myDist = 0;
    }
    else if (len >= 1)
    {
    x = a.x + (b.x-a.x)*myDist/len;
    y = a.y + (b.y-a.y)*myDist/len;
    }

    FOPRect rc(FOPPoint((int)(x-3), (int)(y-3)), 7);

    CBrush brush(RGB(255,0,0));
    CBrush *pBrush = (CBrush *)pDC->SelectObject(&brush);
    //FillEllipse(pDC, rc, RGB(255,0,0), RGB(255,0,0), 1);
    pDC->Ellipse(&rc);
    pDC->SelectObject(pBrush);
    brush.DeleteObject();
    }

    void CAnimatedLinkShape::OnDraw3d(CDC *pDC)
    {
    CFOLinkShape::OnDraw3d(pDC);

    DoStartTimer();
    //FODO:Add your own code below.
    if (mySeg >= GetPointCount()-1)
    mySeg = 0;
    FOPPoint a = GetPointAt(mySeg);
    FOPPoint b = GetPointAt(mySeg+1);
    float len = (float)sqrt((b.x-a.x)*(b.x-a.x) + (b.y-a.y)*(b.y-a.y));
    float x = (float)b.x;
    float y = (float)b.y;
    if (myDist >= len)
    {
    mySeg++;
    myDist = 0;
    }
    else if (len >= 1)
    {
    x = a.x + (b.x-a.x)*myDist/len;
    y = a.y + (b.y-a.y)*myDist/len;
    }

    FOPRect rc(FOPPoint((int)(x-3), (int)(y-3)), 7);

    CBrush brush(RGB(255,0,0));
    CBrush *pBrush = (CBrush *)pDC->SelectObject(&brush);
    //FillEllipse(pDC, rc, RGB(255,0,0), RGB(255,0,0), 1);
    pDC->Ellipse(&rc);
    pDC->SelectObject(pBrush);
    brush.DeleteObject();
    }

    The class is created with the E-XD++ default Create() member. The control can be any shape or size. The example code also shows how to add a client edge to the window.

  • It is tested on Visual Studio 6.0, Visual Studio.net 2013 and Visual Studio.net 2024.

    Downloads
    pie_Animate_Line_vc_source_code.rar - Download source VC++ demo Source Code - 20 Kb

    Notes: To make this codes works, you must has E-XD++ Enterprise Edition installed. See sample GaugeDemo.

     

    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