PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • Implementation
  • 1. Including the files of the C interface of WINDEV
  • 2. Including the HyperFileSQL declarations
  • Interfacing C++ with WINDEV
  • 1. Declaring the HyperFileSQL context and the work buffers of each file:
  • 2. Inheritance
  • 3. Constructor
  • 4. MAP of the user actions in the windows
  • 5. Association between a class member and a window control
  • Using HyperFileSQL in C++
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
This third method uses the notion of class inheritance to simplify the interfacing between a C++ application and WINDEV. This programming mode is recommended if you are already using an architecture based on classes for your developments (MFC for example).
The functions described in the 2nd method are used in background by the base classes supplied with this interface. See Details of commands for the external interface for more details
This mode is illustrated in:
  • the VC60API.dsp project (in Visual C++ 6 format) supplied in the "ExternalLanguages\C" sub-directory of the setup directory of WINDEV.
  • the BC50API.ide project (in Borland C 5 format) supplied in the "ExternalLanguages\C" sub-directory of the setup directory of WINDEV.
Note: Other modes are available for programming in external language. See The programming modes of the external languages for more details
Implementation

1. Including the files of the C interface of WINDEV

The following files must be included in a project that calls this interface. This list presents the VC60Api.dsp example supplied with WINDEV. The file named "WD External Language.h" is specific to this project and it must not be included in your own project.
The two following lines must be found in the code of the main .c file of your C project:
# include "WDWDial.h" // WINDEV language and objects
#include "HFContext.h" // HyperFileSQL DBMS

2. Including the HyperFileSQL declarations

An inclusion (#include) must be added for each data file declared in the analysis of the WINDEV project. The declarations of data files are included in the file whose extension is.h (this file replaces the.wdr created with the earlier WINDEV version).
For example, in the Vc60.dsp project (supplied with WINDEV in the "ExternalLanguages" directory), the following line is used to manage the City and State files:
#include "WD External language.h"
Interfacing C++ with WINDEV

1. Declaring the HyperFileSQL context and the work buffers of each file:

If the application must manage data files, a HyperFileSQL working context must be declared as well as a buffer for each data file.
These declarations are performed in the Vc60API.dsp project via the following lines:
CHFContext    gclHF; // Manage the HyperFileSQL context
StCITY       gstCity; // HF buffer of City file
StSTATE gstState;       // HF buffer of State file

2. Inheritance

The use of the WINDEV windows from the C++ language is performed by inheritance of the CWDDialog class. The class that inherits from CWDDialog will automatically interface with the window graphic object and the controls found in this window. In most cases, a class is used per type of WINDEV window.
Example of inheritance:
class CMenu:public CWDDialog
{
...
}

3. Constructor

The constructor of the CWDDialog class receives two parameters as indicated below:
CWDDialog::CWDDialog(LPCSTR szNameWDW, HWND hWndParent)
Therefore, the constructor of your class must pass these parameters to CWDDialog when it is called. Let's see the code for the constructor of the CMenu class found in the VC60API.dsp example:
CMenu::CMenu(LPCSTR szNameWDW, HWND hWndParent): CWDDialog (szNameWDW,hWndParent)
{
}
The class constructor can receive additional parameters. See the constructor of the CSearch class in the VC60API.dsp project.

4. MAP of the user actions in the windows

The mechanism of the CWDDialog class is used to associate the user events in the WINDEV window with the methods of your class (like nWDSetCallbackNext), but in an automatic way.
This enables you to include the entire management of the window inside your class. To do so:
  • create the methods corresponding to the different processes that must be performed in your window
  • declare the MAP (method<->event association) of the window
  • retrieve (if necessary) the base actions supported by the CWDDialog class (optional)
Creating the methods
The methods of your class will be automatically called by the internal mechanism of the class inherited from CWDDialog. Therefore, they can be encapsulated with the 'protected' mode in your declaration.
Example of the CMenu class:
class CMenu:public CWDDialog
{
public:
CMenu(LPCSTR pszNameWDW, HWND hWndParent= NULL);
protected:
void Exit( void ) {Close();}
void FindCity( void );
void FindState( void );
void LstState( void );
void LstPrint( void );
void LstConfig( void );
void Find( void );
...
}
Declaring the map
The following declaration is used to associate the created methods with the user events. The events correspond, as for the previous method, to the content of WDKey string filled in the WLanguage code.
The first declaration to do in the declaration of the window class (after the declaration of methods) is as follows:
DECLARE_KEY_MAP(CMenu);
Then, all you have to do is fill the MAP with the method<:-event associations as follows (outside the declaration of the class). Example issued from the VC60API.dsp project:
START_KEY_MAP(CMenu)
{"FE", Exit},
{"RN", FindCity},
{"RD", FindState},
{"DD", LstState},
{"DI", LstPrint},
{"DC", LstConfig},
END_KEY_MAP()
Retrieving the base actions supported by CWDDialog
The CWDDialog class takes the ENTER and ESC keys into account (standard behavior for validation and cancelation). In order to retrieve these events, you can inherit from the mechanism described in the base class by the following line (found at the end of your declarations of methods): INHERIT_KEY_MAP(CWDDialog)
Full declaration code of the CMenu class:
class CMenu:public CWDDialog
{
public:
CMenu(LPCSTR pszNameWDW, HWND hWndParent= NULL);
protected:
void Exit( void ) {Close();}
void FindCity( void );
void FindState( void );
void LstState( void );
void LstPrint( void );
void LstConfig( void );
void Find( void );
DECLARE_KEY_MAP(CMenu);
INHERIT_KEY_MAP(CWDDialog); // Optional
};
START_KEY_MAP(CMenu)
{"FE", Exit},
{"RN", FindCity},
{"RD", FindState},
{"DD", LstState},
{"DI", LstPrint},
{"DC", LstConfig},
END_KEY_MAP()

5. Association between a class member and a window control

This type of association enables you to link a member of the class with a control of the window managed by the class. This can operate:
  • to automatically retrieve in a member the content of the control when validating (and exiting) the window
  • to automatically assign the content of a member in a control when opening the window
An association of this type is performed by the call to three macro-commands used to:
  • create the class member that will be linked to the control
  • initialize the management of the control/member associations
  • associate the window control with the member of the same name
The creation of the member is performed by the call to one of the macro-commands from the "DECLARE_MEMBER_INPUT_" family. For example, the DECLARE_MEMBER_INPUT macro command creates a integer member that can be associated with an integer control.
The "DECLARE_MEMBER_INPUT" macro-commands are used to declare a member whose name will correspond to the name of the control in the window. The following example is extracted from the declaration of the CSearch class:
DECLARE_MEMBER_INPUT_INT(Occur,0) // Integer control whose value = 0
A macro-command is available for each type of control (INT means integer). Their list is as follows (see the WDWDIAL.H file for more details):
// RADIO BUTTON
DECLARE_MEMBER_RADIOBUTTON(NAME, INITVAL)
// LIBELLE
DECLARE_MEMBER_STATIC(NAME, INITSTR, SIZE)
// STRING EDIT
DECLARE_MEMBER_EDIT_STR(NAME, INITSTR, SIZE)
// CSTRING STRING EDIT without size limit
DECLARE_MEMBER_EDIT_CSTRING(NAME, INITSTR)
// INTEGER EDIT
DECLARE_MEMBER_EDIT_INT(NAME, INITVAL)
// MULTIPLE CHECK BOX
// Example:
//  DECLARE_MEMBER_TABCHECKBOX(CBOX1, 10, "x x x x x ")
// set of 10 check boxes initialized so that every other one is checked
DECLARE_MEMBER_ARRCHECKBOX(NAMEWDCONTROL, NUMBER, INITSTR)
// SIMPLE CHECK BOX
DECLARE_MEMBER_CHECKBOX(NAME, INITSTATE)
// STRING COMBO BOX
DECLARE_MEMBER_COMBO_STR(NAME, INITSTR, SIZE)
// STRING LIST BOX
DECLARE_MEMBER_LIST_STR(NAME, INITSTR, SIZE)
// CTString STRING COMBO BOX without size limit
DECLARE_MEMBER_COMBO_CSTRING(NAME, INITSTR)
// INTEGER COMBO BOX
DECLARE_MEMBER_COMBO_INT(NAME, INITVAL)
The management of the controls/members is initialized by the "DECLARE_MANAGE_AUTO" macro. Example for the CSearch class:
DECLARE_MANAGE_AUTO(CFind)
Finally, the association between the window controls and the members of the class with the same name is done by the following macro-commands (example of the CFind class):
START_MANAGE_AUTO(CFind)
MANAGE_AUTO(Occur)
// place the other control/member associations here
END_MANAGE_AUTO()
Using HyperFileSQL in C++
The functions for accessing the data files can be used by calling nWDExecute (see the definition of this function). However, the interface of the C++ language provides a class (CVHFContext) for managing the HyperFileSQL files.
This class interfaces the use of the standard HyperFileSQL functions (WLanguage functions H*).
See the online help of WINDEV (WDLang.chm) and the HFContext.cpp file supplied with the VC60API.dsp project for more details
Minimum required version
  • Version 9
Comments
Click [Add] to post a comment