C++ Charting-Bibliothek Lernprogramm Quellcode Hinzufügen von Diagrammen in C++-Sprache. - VS2019

point 1
symbol 2
symbol
shape
shape
point
shape
symbol

VS2019 MINIMAL C++ CHARTING LIBRARY Walk Through

ProEssentials DLL interfaces are used when creating stand-alone Desktop or Embedded EXEs to be distributed royalty-free and ran on an end-users machine. This VS2019 Minimal C++ Charting Walk-through includes instructions for Visual Studio VS2019. For a C++ MFC walkthrough see: Click here for VS2019 MFC Walkthough.

Siehe die Demo...
Best WPF Chart to download, evaluate, and choose for your Financial Scientific Charting.
Best .NET Chart download for Scientific Charting, Engineering Charting.
Hello World - Walk Through - Tutorial

IMPORTANT: For help finding DLL specific features in our help system, click the Contents Tab at the top-left location, then near the bottom click ProEssentials Reference, and then see the Alphabetic Listing. The .Net Reference section is the best source for researching properties and still shows DLL specific syntax.

When installing ProEssentials, the setup program installs the ProEssentials DLL into the System32 directory, SysWow64 on 64 bit systems. It also installs a header file and import library into the C:\ProEssentials9\VC directory. The relevant files are:

  • PEGRP32G.DLL : ProEssentials Pro DLL
  • PEGRP32G.LIB : ProEssentials Pro LIB File
  • PEGRPAPI.H : ProEssentials Header File

  • PEGRPSG.DLL : ProEssentials Standard DLL
  • PEGRPSG.LIB : ProEssentials Standard LIB File

Creating a new project...

1) Start Visual Studio.NET and create a new project targeting [C++] [Windows] [Desktop] and [Windows Desktop Application]. Accept the default project name of [WindowsProject1].

C++ charting component new project VS 2019

C++ Charting Project, Adding Existing Items...

2) First manually copy 'PEGRPAPI.H' and 'PEGRP32G.LIB' from the C:\ProEssentials9\VC demo directory to where the WindowsProject1 project files are located.

Note, if using the Standard version instead of Pro version, use 'PEGRPSG.LIB'.

From the top level Visual Studio menus, use [Project / Add Exiting Item...] menu to add 'PEGRPAPI.H' and 'PEGRP32G.LIB' to the WindowsProject1 project.

The image shows the existing files being added to your project.

C++ Chart property Window in VS2019
C++ Charting Project, Adding Header File...

3) Open the file 'WindowsProject1.cpp' and near the top add the lines:

#include “Pegrpapi.h“
 HWND hPE;

The include statement adds the ProEssentials header file which contains constants and function declarations.

The variable hPE is used to store the Window handle for the ProEssentials chart control.

C++ Chart Component adding header file VS2019
C++ Charting Project, Adding a Window Handle for the Chart...

4) Also within the file 'WindowsProject1.cpp' add this line to the InitInstance function:

hPE = NULL;

This will initialize our window handle to NULL at the start of the process, and we will later set to a valid handle in WM_CREATE. The chart we create will be a standard Window; as if we called the CreateWindow API call.


C++ Chart Component adding windows handle
C++ Charting Project, Adding simple data...

5) Near the top of WndProc, add variables used later to initialize the chart.

RECT r;
int s, p;
int dwColor;
float f[] = {10, 30, 20, 40, 30, 50, 15, 63, 74, 54, 25, 34};

C++ Chart Component WndProc
C++ Charting Project, Message Switch statement...

6)Add the below message switch statements. See images below for clarity.

case WM_CREATE: creates and initialzes a chart after parent window is created.

::GetClientRect(hWnd, &r);

// PEcreate is similar to CreateWindow API call, returns a Window Handle //
hPE = PEcreate(PECONTROL_GRAPH, 0, &r, hWnd, 1000);
PEszset(hPE, PEP_szMAINTITLE, (LPWSTR) L"Hello World");
PEszset(hPE, PEP_szSUBTITLE, (LPWSTR) L"");
PEnset(hPE, PEP_nSUBSETS, 2); // Subsets = Rows //
PEnset(hPE, PEP_nPOINTS, 6);  // Points = Columns //

// Passing data one piece at a time //
for (s=0; s<2; s++)
{
    for (p=0; p<6; p++)
    {   // (s*6)+p or (SubsetIndex * NumberPoints) + PointIndex //
        PEvsetcellEx(hPE, PEP_faYDATA, s, p, &f[(s*6)+p]);
    }
}
// or Passing data in one call is much faster: PEvset(hPE, PEP_faYDATA, f, 12); //

PEvsetcell(hPE, PEP_szaPOINTLABELS, 0, (LPVOID) TEXT("Jan"));
PEvsetcell(hPE, PEP_szaPOINTLABELS, 1, (LPVOID) TEXT("Feb"));
PEvsetcell(hPE, PEP_szaPOINTLABELS, 2, (LPVOID) TEXT("Mar"));
PEvsetcell(hPE, PEP_szaPOINTLABELS, 3, (LPVOID) TEXT("Apr"));
PEvsetcell(hPE, PEP_szaPOINTLABELS, 4, (LPVOID) TEXT("May"));
PEvsetcell(hPE, PEP_szaPOINTLABELS, 5, (LPVOID) TEXT("June"));
PEvsetcell(hPE, PEP_szaSUBSETLABELS, 0, (LPVOID) TEXT("For .Net Framework"));
PEvsetcell(hPE, PEP_szaSUBSETLABELS, 1, (LPVOID) TEXT("or MFC, ActiveX, VCL"));
PEszset(hPE, PEP_szYAXISLABEL, (LPWSTR) L"Simple Quality Rendering");
PEszset(hPE, PEP_szXAXISLABEL, (LPWSTR) L"");
dwColor = PERGB(60, 0, 180, 0); PEvsetcell(hPE, PEP_dwaSUBSETCOLORS, 0, &dwColor);
dwColor = PERGB(180, 0, 0, 130); PEvsetcell(hPE, PEP_dwaSUBSETCOLORS, 1, &dwColor);

// Quick way to set many colors via QuickStyle property //
PEnset(hPE, PEP_bBITMAPGRADIENTMODE, FALSE);
PEnset(hPE, PEP_nQUICKSTYLE, PEQS_LIGHT_SHADOW);

PEnset(hPE, PEP_nGRAPHPLUSTABLE, PEGPT_BOTH);
PEnset(hPE, PEP_nDATAPRECISION, 0);
PEnset(hPE, PEP_bLABELBOLD, TRUE);
PEnset(hPE, PEP_nPLOTTINGMETHOD, PEGPM_BAR);
PEnset(hPE, PEP_nGRADIENTBARS, 8);
PEnset(hPE, PEP_bBARGLASSEFFECT, TRUE);
PEnset(hPE, PEP_nLEGENDLOCATION, PELL_LEFT);
PEnset(hPE, PEP_nDATASHADOWS, PEDS_3D);
PEnset(hPE, PEP_bFIXEDFONTS, TRUE);
PEnset(hPE, PEP_nFONTSIZE, PEFS_LARGE);

// You will likely set these for all charts //
PEnset(hPE, PEP_bPREPAREIMAGES, TRUE);
PEnset(hPE, PEP_bCACHEBMP, TRUE);
PEnset(hPE, PEP_nRENDERENGINE, PERE_DIRECT2D);
PEnset(hPE, PEP_bANTIALIASGRAPHICS, TRUE);
PEnset(hPE, PEP_bANTIALIASTEXT, TRUE);

// Setting this TRUE will enable Data HotSpots, //
// but we need to add code to respond to hot spot message //

PEnset(hPE, PEP_bALLOWDATAHOTSPOTS, TRUE);

// Always finish your property settings with these function calls //
PEreinitialize(hPE);
PEresetimage(hPE, 0, 0);

case WM_DESTROY: clean up chart resource at same time parent is cleaned up

if (hPE) { PEdestroy(hPE); hPE = 0; }

case WM_SIZE: this causes chart to always fill client rect of parent

if (hPE)
{
    RECT r; ::GetClientRect(hWnd, &r);
    ::MoveWindow(hPE, 0, 0, r.right, r.bottom, FALSE);
}

case WM_COMMAND: listen for notification message to handle hot spot

int wmId = LOWORD(wParam);
int wmEvent = HIWORD(wParam);
switch (wmEvent)
{
case PEWN_CLICKED:
    HOTSPOTDATA hsd; TCHAR buffer[128]; float yvalue;
    PEvget(hPE, PEP_structHOTSPOTDATA, &hsd);
    if (hsd.nHotSpotType == PEHS_DATAPOINT)
    {
        PEvgetcellEx(hPE, PEP_faYDATA, hsd.w1, hsd.w2, &yvalue);
        swprintf_s(buffer, (LPWSTR) L“DataPoint %d value %.2f“, hsd.w2, yvalue);
        ::MessageBox(hWnd, buffer, (LPWSTR) L“Hello World“, 0);
    }
    break;
}

Your project code files should look similar to...

C++ Chart code window for WM_CREATE VS2019
C++ Chart code window for WM_COMMAND VS2019
C++ Chart code window for WM_DESTROY and WM_SIZE VS2019

Success!!!

8) Save and run the project. Your project will show an image as follows. Move the mouse over a bar and click to trigger the DataHotSpot event.

This completes this walkthrough.

Please read the remaining sections within Chapter 5 and review the demo code and documentation that's installed with the eval/product.

Once installed, the demo program can be accessed via shortcut...

Start / ProEssentials v9 / PeDemo

Note that our main charting demo is replicated in WPF and Winform C#.NET,  VB.NET, VC++ MFC, Delphi, Builder all accessible from where you installed ProEssentials.   These are great for modifying an existing demo to test potential modifications before implementing within your applications.

C++ Charting Library within your software!


Thank you for researching. Please contact our engineers if you have a question.

C++ Charting Library Tutorial Scientific Financial 2D Contour 3D Surface Scatter

Unsere Aufgabe

Ihr Erfolg ist unser höchstes Ziel, indem wir Ihrem Unternehmen und Ihren Endbenutzern den einfachsten und professionellsten Nutzen bieten.

Wir sind Ingenieure

ProEssentials wurde von professionellen Elektroingenieuren erschaffen, die ihre eigenen Charting-Komponenten benötigten. Treten Sie unserer großen Liste von Top-Engineering-Unternehmen bei, die ProEssentials einsetzen.

Danke sehr

Vielen Dank, dass Sie ein ProEssentials-Kunde sind, und vielen Dank, dass Sie die ProEssentials-Charting-Engine recherchieren.