Creating your own Graph Tool is easier than you think. Why buy a canned graphing tool when you can fully automate and customize your graphs to meet your needs. Then you can distribute as needed and not worry about licensing. ProEssentials is royalty free to distribute within your custom software.
demonstrates how to create your first Visual Studio v6 Visual
C++ Visual Studio.Net Graph Tool implementation. Click here for Visual Studio VS2005 / VS2008 / VS2010 instructions.
This example is a non-MFC example for reasons of
simplicity. Instructions are based off VC6, but this article teaches the fundamentals that ProEssentials creates an HWND much like the CreateWindow API call. Then the control is utilized similar to any child window within the Windows operating system.
There are notes for MFC users at the bottom of this article.
When installing ProEssentials, the setup program
installs the ProEssentials DLL (our Dynamically Linkable Graph Tool Library) into the system
directory. It also installs a header file and
import library into the C:\ProEssentials6\VC directory.
The relevant files are:
||ProEssentials Pro DLL
||ProEssentials Standard DLL
||ProEssentials Lite DLL
Note this Walk-Through uses the Pro version.
Substitute the above Standard or Lite Graph Tool LIB file as needed.
Launch Visual C++ and use the File / New... menu
to launch the [New]
project dialog. Select [Win32 Application],
supply a project name [MyFirst]
Selecting [OK] goes to the next page. Now Select [Hello World] .
the C:\ProEssentials6\VC directory
to where the [MyFirst] project is located.
the [Project / Add To Project / Files...]
menu to add
the [MyFirst" project.
Open the file
"myfirst.cpp" and near the top add the lines:
The include statement
adds the ProEssentials header file which contains constants
and function declarations.
variable hPE is
used to store the Window's handle for the ProEssentials
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.
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.
Next, within the WndProc function, add the lines:
int s, p;
These will be needed
within the WM_CREATE and WM_SIZE switches.
// Our graph tool is created within the OnCreate for MFC developers //
hPE = PEcreate(PECONTROL_GRAPH,
0, &r, hWnd, 1000);
for (s=0; s<2; s++)
for (p=0; p<10; p++)
= (rand() % 10) + (rand() % 100) / 100.0F;
PEP_faYDATA, s, p, &f);
MoveWindow(hPE, 0, 0, r.right, r.bottom, FALSE);
Next, we add handlers
for the WM_CREATE, and WM_SIZE message
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
variable f is type float
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.
is the ProEssentials
function used to set textual type properties.
PEvsetcell is then used to set the Subset Legend text for both
PEnset is then used
to set various properties controlling visual aspects.
ProEssentials you're done setting properties.
The code in the
handler causes the ProEssentials control to always consume
the entire Windows client area.
The code in the
handler destroys the ProEssentials
graph tool and frees resources via PEdestroy.
hPE = 0;
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.
you've just completed your first Visual C++ / ProEssentials
Graph Tool implementation.
This example is very simple and you'll likely set
other properties such as:
PointLabels which will replace the "1,2,3..." along
SubsetLineTypes which controls line styles.
SubsetColors which controls line colors.
PlottingMethod which controls the type of graph created, Line,
Bar, Area, Point, etc.
MFC User's Note:
installs an MFC example [VC6 Example Project] located
via the Start Menu / All Programs / ProEssentials v6.
This project will load into any version of Visual Studio. Allow the project to automatically convert as needed.Within an MFC implementation, you'll generally add a
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. Within our included
VC6 example, look for "PeView.h" for the m_hPE
declaration and "PeView.cpp" for the implementation.
Complete online technical reference to the ProEssentials
product. The .NET Reference is the best mechanism
to navigate the large quantity of properties and features.
Walk-Throughs of graphing in VB.NET, C#.NET, ASP, VC,
VB6, and Delphi get you started quickly.
more about our graph tool in Chapter 5
Interactive Financial, Engineering, Scientific, and Business
examples give you an instant taste of ProEssentials' power.
online demo of our graph tool