Visit Gigasoft's Web Site
ProEssentials v8 Help
Chapter 5 DLL Win32 Charting Walk-Through

he following information demonstrates how to create your first Visual Studio Visual C++ Win32 Charting implementation. It discusses installation, adding ProEssentials to a project, writing your first few lines of code, and shows the final results.

 

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.

 

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:\ProEssentials8\VC directory. The relevant files are:

PEGRP32F.DLL

ProEssentials Pro DLL
PEGRP32F.LIB ProEssentials Pro LIB File

PEGRPAPI.H

ProEssentials Header File

PEGRPSF.DLL

ProEssentials Standard DLL
PEGRPSF.LIB ProEssentials Standard   LIB File

File / New... menu

Creating the Project...

 

Launch Visual Studio and use the File / New... menu to launch the [New] project dialog. Within Tree select [Visual C++ - - Win32 ], select project template [Win32 Project], and supply a project name [MyFirst] and project location.

 

Project / Add Existing Item... menu

1) Copy "PEGRPAPI.H" and "PEGRP32F.LIB" from the C:\ProEssentials8\VC demo directory to where the [MyFirst] project is located.

 

Note, if using Standard version, use "PEGRPSF.LIB"

 

2) Use the [Project / Add Exiting Item...] menu to add "PEGRPAPI.H" and "PEGRP32F.LIB" to the [MyFirst"] project.

 

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

myfirst.cpp... near top Adding ProEssentials Charting header file ...


3) Open the file "myfirst.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's handle for the ProEssentials chart control.

 

 

 

myfirst.cpp... InitInstance Init Window handle...

4) Within file "myfirst.cpp"s InitInstance, initialize hPE to NULL.

hPE = NULL;

 

myfirst.cpp... near top of WndProc

 

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};


myfirst.cpp...

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

add case WM_CREATE: initialzes a chart after parent creates it's window

case WM_CREATE:

GetClientRect(&r);
hPE = PEcreate(PECONTROL_GRAPH, 0, &r, this->m_hWnd, 1000);
PEszset(hPE, PEP_szMAINTITLE, TEXT("Hello World"));
PEszset(hPE, PEP_szSUBTITLE, TEXT(""));
PEnset(hPE, PEP_nSUBSETS, 2);
PEnset(hPE, PEP_nPOINTS, 6);
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 Pass data in one call is much faster -> PEvset(hPE, PEP_faYDATA, f, 12);
PEvsetcell(hPE, PEP_szaPOINTLABELS, 0, TEXT("Jan"));
PEvsetcell(hPE, PEP_szaPOINTLABELS, 1, TEXT("Feb"));
PEvsetcell(hPE, PEP_szaPOINTLABELS, 2, TEXT("Mar"));
PEvsetcell(hPE, PEP_szaPOINTLABELS, 3, TEXT("Apr"));
PEvsetcell(hPE, PEP_szaPOINTLABELS, 4, TEXT("May"));
PEvsetcell(hPE, PEP_szaPOINTLABELS, 5, TEXT("June"));
PEvsetcell(hPE, PEP_szaSUBSETLABELS, 0, TEXT("For .Net Framework"));
PEvsetcell(hPE, PEP_szaSUBSETLABELS, 1, TEXT("or MFC, ActiveX, VCL"));
PEszset(hPE, PEP_szYAXISLABEL, TEXT("Simple Quality Rendering"));
PEszset(hPE, PEP_szXAXISLABEL, TEXT(""));
dwColor = PERGB(60, 0, 180, 0); PEvsetcell(hPE, PEP_dwaSUBSETCOLORS, 0, &dwColor);
dwColor = PERGB(180, 0, 0, 130); PEvsetcell(hPE, PEP_dwaSUBSETCOLORS, 1, &dwColor);
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_nFONTSIZE, PEFS_LARGE);
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);
PEnset(hPE, PEP_bALLOWDATAHOTSPOTS, TRUE);
PEnset(hPE, PEP_bBITMAPGRADIENTMODE, FALSE);
PEnset(hPE, PEP_nQUICKSTYLE, PEQS_LIGHT_SHADOW);
PEnset(hPE, PEP_bFIXEDFONTS, TRUE);
PEreinitialize(hPE);
PEresetimage(hPE, 0, 0);

break;


WM_DESTROY:

cleans up the chart resource at same time parent is cleaned up

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

add case WM_SIZE fills client rect of parent with chart, ERASEBKGND prevents flicker

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

 

case WM_ERASEBKGND: // Adding this prevents flashing on resize
break;

WM_COMMAND: this handles the hot spot event, showing a message box.

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, TEXT("DataPoint %d value %.2f"), hsd.w2, yvalue);
::MessageBox(this->m_hWnd, buffer, TEXT("Hello World"), 0);
}
break;
}

MainTitle and SubTitle are set first. Note that setting SubTitle to an empty string hides the subtitle.

Subsets and Points define the amount of data you'll be passing.

Next, we pass some random data into the YData[s,p] two dimensional property array. PointLabels[0] sets the first data point label located below axis.

SubsetLabels[0] sets the first subset label.

Next, we set various other properties controlling visual aspects, and enable flicker free updates with PrepareImages.

Finally PEreinitialize and PEresetimage tells ProEssentials to initialize and resetimage the image, in other words, you're done setting properties.

Your code window will look similar to below...

 

Win32 Charting Results... Congratulations...
Win32 Charting library

Run your project and you'll see the chart on left.

Congratulations, you've just completed your first Win32 Charting ProEssentials implementation.