Visit Gigasoft's Web Site
ProEssentials v6 Help
Chapter 5: DLL WIN32 Walk-Through

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

 

This example is a non-MFC example for reasons of simplicity. See various notes below regarding MFC development.

 

For help finding DLL features, use the Contents Tab at the top-left location within this help system, near the bottom, click Reference, and then Alphabetic Listing.

File / New... menu Installation...

When installing ProEssentials, the setup program installs the ProEssentials DLL into the system directory. It also installs a header file and import library into the C:\ProEssentials6\VC directory. The relevant files are:

 

PEGRP32D.DLL

ProEssentials Pro DLL
PEGRP32D.LIB ProEssentials Pro LIB File

PEGRPAPI.H

ProEssentials Header File

 

PEGRPDS.DLL

ProEssentials Standard DLL
PEGRPDS.LIB ProEssentials Standard  LIB File
 

PEGRPDL.DLL

ProEssentials Lite DLL
PEGRPDL.LIB ProEssentials Lite LIB File

 

 

Creating the Project... Win32 Application,  "Hello World!"...

 

Launch Visual C++ and use the File / New... menu to launch the [New] project dialog. Select [Win32 Application], supply a project name [MyFirst] and appropriate project location.

 

Selecting [OK] goes to the next page.  Now Select [Hello World] .

 

Project / Add to Project / Files... menu
Adding ProEssentials to a VC project...

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

 

2) Use the [Project / Add To Project / Files...] menu to add "PEGRPAPI.H" and "PEGRP32D.LIB" to the [MyFirst" project.

 

Note, if using Standard or Lite versions, use "PEGRPDS.LIB" or "PEGRPDL.LIB".

 

myfirst.cpp... Adding declarations and Window handle variable...

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 control.

 

Note: Within an MFC application, you'll generally add the include statement to the view class's ".cpp" file and add the variable m_hPE to the view class's ".h" file as a member variable of the view's class.

 

myfirst.cpp...  

Within the InitInstance function, add one line of code to initialize hPE to NULL. This is needed because we'll be adding code into the WM_SIZE and WM_DESTROY switches which assume a non-NULL hPE represents a ProEssentials control has been constructed.

 

hPE = NULL;

 

 

Add a few variables...  

Next, within the WndProc function, add the lines:

 

RECT r;
int s, p;
float f;

 

These will be needed within the WM_CREATE and WM_SIZE switches.

 

myfirst.cpp...     WM_CREATE, WM_SIZE  

case WM_CREATE:

    GetClientRect(hWnd, &r);

    hPE = PEcreate(PECONTROL_GRAPH, 0, &r, hWnd, 1000);

    PEnset(hPE, PEP_bPREPAREIMAGES, TRUE);

    PEnset(hPE, PEP_nSUBSETS, 2);

    PEnset(hPE, PEP_nPOINTS, 10);

    for (s=0; s<2; s++)

    {

        for (p=0; p<10; p++)

        {   f = (rand() % 10) + (rand() % 100) / 100.0F;

            PEvsetcellEx(hPE, PEP_faYDATA, s, p, &f);

        }

    }

    PEszset(hPE, PEP_szMAINTITLE, TEXT("My Title"));

    PEszset(hPE, PEP_szSUBTITLE, TEXT(""));

    PEszset(hPE, PEP_szYAXISLABEL, TEXT("My Data"));

    PEszset(hPE, PEP_szXAXISLABEL, TEXT(""));

    PEvsetcell(hPE, PEP_szaSUBSETLABELS, 0, TEXT("Hello"));

    PEvsetcell(hPE, PEP_szaSUBSETLABELS, 1, TEXT("World"));

    PEnset(hPE, PEP_bBITMAPGRADIENTMODE, TRUE);

    PEnset(hPE, PEP_nQUICKSTYLE, PEQS_LIGHT_INSET);

    PEnset(hPE, PEP_bFIXEDFONTS, TRUE);

    PEnset(hPE, PEP_nLEGENDSTYLE, PELS_1_LINE_INSIDE_AXIS);

    PEreinitialize(hPE);

    PEresetimage(hPE, 0, 0);

    break;

case WM_SIZE:

    if (hPE)

    {

        GetClientRect(hWnd, &r);

        MoveWindow(hPE, 0, 0, r.right, r.bottom, FALSE);

    }

    break;

 

Next, we add handlers for the WM_CREATE, and WM_SIZE message handlers.

 

WM_CREATE contains the ProEssentials creation code. The ProEssentials function PEcreate is similar to the Windows CreateWindow function, and if successful, returns a Windows handle which is stored in hPE.

PEnset is a ProEssentials function that sets 32 bit type properties such as INTEGER, BOOL and HANDLE.

 

Next a nested for loop passes data via PEvsetcellEx and the property YData. Note variable f is type float and this is important because PEvsetcellEx works by reading data at a void pointer's location and memory at this location must be of the type expected.

 

Next, PEszset is the ProEssentials function used to set textual type properties. Note, PEszsetA and/or PEszsetW may be called to work specifically with short-char or wide-char data. Else the presence of the UNICODE pragma will control if PEszset automatically maps to PEszsetA or PEszsetW.

 

PEvsetcell is then used to set the Subset Legend text for both subsets.

PEnset is then used to set various properties controlling visual aspects.

PEreinitialize and PEresetimage tell ProEssentials you're done setting properties.

 

The code in the WM_SIZE message handler causes the ProEssentials control to always consume the entire Windows client area.

 

 

myfirst.cpp...  WM_DESTROY...

 

 

The code in the WM_DESTROY message handler destroys the ProEssentials control and frees resources via PEdestroy.

 

if (hPE)

{

    PEdestroy(hPE);

    hPE = 0;

}

 

Results... Congratulations...

Use Visual C++'s Build / Build myfirst.exe menu (short cut F7) and then Build / Execute myfirst.exe (short cut Ctrl+F5) and you'll see the resulting Window to the left.

 

Congratulations, you've just completed your first Visual C++ / ProEssentials implementation.

 

This example is very simple and you'll likely set other properties such as:

PointLabels which will replace the "1,2,3..." along x axis.

SubsetLineTypes which controls line styles.

SubsetColors which controls line colors.

PlottingMethod which controls the type of chart created, Line, Bar, Area, Point, etc.

 

MFC User's Note: ProEssentials installs an MFC example [VC6 Example Project]. Within an MFC implementation, you'll generally add a HWND m_hPE member variable inside the View Class's declaration and then ProEssentials creation code within the View Class's  OnCreate handler after the base class call. You'll use the OnDestroy message handler to call PEdestroy.