home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic 4 Unleashed
/
Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso
/
chartfx
/
cfxvbx
/
cfxvbx.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1995-01-24
|
7KB
|
200 lines
// cfxvbx.cpp : implementation of the CFXVBX struct
// This file permits C++ applications to use CHARTFX functions with the VBX version
// You don't need to include any LIB files to use these functions
// MFC USERS: Do not use the precompiled header for this file. Use Automatic Pre-Compiler Headers Instead.
// IF you want to use Precompiled headers (stdafx) for all files, you must add this line:
// #include "stdafx.h"
#include <windows.h>
// Function prototypes in Chart FX
typedef HWND (far pascal *PFNCFX_CREATE)(long,long,HWND,int,int,int,int,int,int,UINT,DWORD);
typedef long (far pascal *PFNCFX_SEND)(HWND,UINT,WPARAM,LPARAM);
typedef long (far pascal *PFNCFX_OPENDATA)(HWND,UINT,DWORD);
typedef BOOL (far pascal *PFNCFX_CLOSEDATA)(HWND,UINT);
typedef long (far pascal *PFNCFX_SETVALUE)(HWND,int,int,double);
typedef long (far pascal *PFNCFX_SETINIVALUE)(HWND,int,int,double);
typedef long (far pascal *PFNCFX_SETXVALUE)(HWND,int,int,double);
typedef long (far pascal *PFNCFX_SETCONST)(HWND,int,double);
typedef long (far pascal *PFNCFX_SETCOLOR)(HWND,int,DWORD,BOOL);
typedef void (far pascal *PFNCFX_SETADM)(HWND,int,double);
typedef long (far pascal *PFNCFX_SETSTRIPE)(HWND,int,double,double,DWORD);
typedef long (far pascal *PFNCFX_SETSTATUSITEM)(HWND,int,BOOL,UINT,BOOL,int,int,int,DWORD);
typedef long (far pascal *PFNCFX_GET)(HWND,long,UINT);
typedef double (far pascal *PFNCFX_GET2)(HWND,long,UINT,double far *);
typedef long (far pascal *PFNCFX_PAINT)(HWND,HDC,int,int,int,int, BOOL, LPPAINTSTRUCT);
typedef double (far pascal *PFNCFX_GETEX)(HWND,int,int,UINT);
typedef void (far pascal *PFNCFX_GETEX2)(HWND,int,int,UINT,double far *);
typedef long (far pascal *PFNCFX_OPENDATAEX)(HWND,UINT,int,int);
typedef double (far pascal *PFNCFX_GETADM)(HWND,int);
typedef void (far pascal *PFNCFX_GETADM2)(HWND,int,double far *);
// Function Ordinals in DLL and VBX
enum {
CFX_CREATE=2,
CFX_SEND,
CFX_PAINT,
CFX_OPENDATA,
CFX_CLOSEDATA,
CFX_SETVALUE,
CFX_SETINIVALUE,
CFX_SETCONST,
CFX_SETCOLOR,
CFX_SETSTRIPE,
CFX_SETADM,
CFX_SETXVALUE,
CFX_SETSTATUSITEM,
CFX_GET,
CFX_GET2,
CFX_OPENDATAEX,
CFX_GETADM,
CFX_GETADM2,
CFX_GETPAINTINFO,
CFX_GETEX,
CFX_GETEX2,
};
#define CFX_FIRST CFX_CREATE
#define CFX_LAST CFX_GET2
// Struct used to encapsulate LoadLibrary - FreeLibrary
struct CFXVBX {
HINSTANCE hInstance; // Instance of ChartFX
FARPROC pFunction[CFX_LAST - CFX_FIRST + 1]; // Array of Pointer to functions
// Implementation
CFXVBX(); // Constructor
~CFXVBX(); // Destructor
};
// Static Variable for automatic startup/cleanup
static CFXVBX cfxVbx;
// Initialization code
CFXVBX::CFXVBX()
{
int i;
// Load CHART2FX.VBX (Increment module count)
hInstance = LoadLibrary("CHART2FX.VBX");
// Load Function Pointers by Ordinal
for(i=CFX_FIRST;i<=CFX_LAST;i++)
pFunction[i-CFX_FIRST] = GetProcAddress(hInstance,(LPCSTR) i);
}
// Termination code
CFXVBX::~CFXVBX()
{
// Free CHART2FX.VBX (Decrement module count)
FreeLibrary(hInstance);
}
extern "C" {
// All ChartFX Functions must be C (and FAR PASCAL) code for chart2fx.hpp header file compatibility
HWND WINAPI chart_Create(long lType,long lStyle,HWND hDad,int x,int y,int w,int h,int nPoint,
int nSerie,UINT wID,DWORD dwStyle)
{
return ((PFNCFX_CREATE) (cfxVbx.pFunction[CFX_CREATE-CFX_FIRST]))(lType,lStyle,hDad,x,y,w,h,nPoint,nSerie,wID,dwStyle);
}
long WINAPI chart_Send(HWND hWnd,UINT wMsg,WPARAM wParam,LPARAM lParam)
{
return ((PFNCFX_SEND) (cfxVbx.pFunction[CFX_SEND-CFX_FIRST]))(hWnd,wMsg,wParam,lParam);
}
long WINAPI chart_OpenData(HWND hWnd,UINT nCode,DWORD dwData)
{
return ((PFNCFX_OPENDATA) (cfxVbx.pFunction[CFX_OPENDATA-CFX_FIRST]))(hWnd,nCode,dwData);
}
BOOL WINAPI chart_CloseData(HWND hWnd,UINT nCode)
{
return ((PFNCFX_CLOSEDATA) (cfxVbx.pFunction[CFX_CLOSEDATA-CFX_FIRST]))(hWnd,nCode);
}
long WINAPI chart_SetValue(HWND hWnd,int nSeries,int nPoint,double dValue)
{
return ((PFNCFX_SETVALUE) (cfxVbx.pFunction[CFX_SETVALUE-CFX_FIRST]))(hWnd,nSeries,nPoint,dValue);
}
long WINAPI chart_SetIniValue(HWND hWnd,int nSeries,int nPoint,double dValue)
{
return ((PFNCFX_SETINIVALUE) (cfxVbx.pFunction[CFX_SETINIVALUE-CFX_FIRST]))(hWnd,nSeries,nPoint,dValue);
}
long WINAPI chart_SetXvalue(HWND hWnd,int nSeries,int nPoint,double dValue)
{
return ((PFNCFX_SETXVALUE) (cfxVbx.pFunction[CFX_SETXVALUE-CFX_FIRST]))(hWnd,nSeries,nPoint,dValue);
}
long WINAPI chart_SetConst(HWND hWnd,int n,double dValue)
{
return ((PFNCFX_SETCONST) (cfxVbx.pFunction[CFX_SETCONST-CFX_FIRST]))(hWnd,n,dValue);
}
long WINAPI chart_SetColor(HWND hWnd,int nColor,DWORD rgb,BOOL bBack)
{
return ((PFNCFX_SETCOLOR) (cfxVbx.pFunction[CFX_SETCOLOR-CFX_FIRST]))(hWnd,nColor,rgb,bBack);
}
void WINAPI chart_SetAdm(HWND hWnd,int nCode,double dValue)
{
((PFNCFX_SETADM) (cfxVbx.pFunction[CFX_SETADM-CFX_FIRST]))(hWnd,nCode,dValue);
}
long WINAPI chart_SetStripe(HWND hWnd,int nStripe,double dBegin,double dEnd,DWORD rgb)
{
return ((PFNCFX_SETSTRIPE) (cfxVbx.pFunction[CFX_SETSTRIPE-CFX_FIRST]))(hWnd,nStripe,dBegin,dEnd,rgb);
}
long WINAPI chart_SetStatusItem(HWND hWnd,int nItem,BOOL bText,UINT wID,BOOL bFrame,int nWidth,int nMin,int nDesp,DWORD dwStyle)
{
return ((PFNCFX_SETSTATUSITEM) (cfxVbx.pFunction[CFX_SETSTATUSITEM-CFX_FIRST]))(hWnd,nItem,bText,wID,bFrame,nWidth,nMin,nDesp,dwStyle);
}
double WINAPI chart_Get(HWND hWnd,long l,UINT wCode)
{
return ((PFNCFX_GET) (cfxVbx.pFunction[CFX_GET-CFX_FIRST]))(hWnd,l,wCode);
}
void WINAPI chart_Get2(HWND hWnd,long l,UINT wCode,double far *dValue)
{
((PFNCFX_GET2) (cfxVbx.pFunction[CFX_GET2-CFX_FIRST]))(hWnd,l,wCode,dValue);
}
void WINAPI chart_Paint(HWND hWnd,HDC hDC,int xLeft,int yTop,int xRight,int yBottom, BOOL bPrint, LPPAINTSTRUCT lps)
{
((PFNCFX_PAINT) (cfxVbx.pFunction[CFX_PAINT-CFX_FIRST]))(hWnd,hDC,xLeft,yTop,xRight,yBottom,bPrint,lps);
}
double WINAPI chart_GetEx(HWND hWnd,int nSerie,int nPoint,UINT wCode)
{
return ((PFNCFX_GETEX) (cfxVbx.pFunction[CFX_GETEX-CFX_FIRST]))(hWnd,nSerie,nPoint,wCode);
}
void WINAPI chart_GetEx2(HWND hWnd,int nSerie,int nPoint,UINT wCode, double far *pfResult)
{
((PFNCFX_GETEX2) (cfxVbx.pFunction[CFX_GETEX2-CFX_FIRST]))(hWnd,nSerie,nPoint,wCode,pfResult);
}
long WINAPI chart_OpenDataEx (HWND hWnd,UINT wType,int nSerie,int nPoint)
{
return ((PFNCFX_OPENDATAEX) (cfxVbx.pFunction[CFX_OPENDATAEX-CFX_FIRST]))(hWnd,wType,nSerie,nPoint);
}
double WINAPI chart_GetAdm(HWND hWnd,UINT wCode)
{
return ((PFNCFX_GETADM) (cfxVbx.pFunction[CFX_GETADM-CFX_FIRST]))(hWnd,wCode);
}
void WINAPI chart_GetAdm2(HWND hWnd,UINT wCode,double far *pfResult)
{
((PFNCFX_GETADM2) (cfxVbx.pFunction[CFX_GETADM2-CFX_FIRST]))(hWnd,wCode,pfResult);
}
}; // Extern C