
16 Appendix A1 Extending Ox
dlg.m_cAcf = OxInt(OxArray(pv, 2), 0);
if (dlg.DoModal() == IDOK)
{
OxInt(OxArray(pv, 0), 0) = dlg.m_cT;
OxInt(OxArray(pv, 1), 0) = dlg.m_cDim;
OxInt(OxArray(pv, 2), 0) = dlg.m_cAcf;
OxInt(rtn, 0) = 1; // return 1 if successful
}
else
OxInt(rtn, 0) = 0;
}
.................................................................................
• The three arguments are checked for type array, then the first in each array is
checked for type integer.
• OxArray(pv, 0) access the first element in pv as an array, OxInt(., 0) the
integer in the first element of the array.
• If the user presses OK in the dialog, the new values are set in the arguments, and
the return value is changed to one.
A1.6 Adding a user-friendly interface with Visual Basic
A1.6.1 Calling the Ox DLL from Visual Basic
The first step is to establish the mechanisms for calling C-style functions residing in the
Ox DLL from Visual Basic. Once this works, all results from previous sections can be
used. We use Micosoft Visual Basic version 6 throughout. The syntax used for calling
the Ox DLL is similar to calling the Windows API from Visual Basic. Ox always uses
32 bit integers, and the corresponding VB type is Long. In particular, for the types used
in the Ox code:
C/Ox type allocation equivalent Function/Sub declaration
int Dim i As Long ByVal i As Long
bool Dim b As Long ByVal b As Long
double Dim d As Double ByVal d As Double
char * Dim s As String ByVal s As String
VECTOR Dim d() As Double d As Double
MATRIX Dim m As Long ByVal m As Long
OxVALUE * Dim pv As Long ByVal pv As Long
The ox\dev\OxWin.bas file declares all functions which are exported by Ox (doc-
umented in §A2.1 and §A2.5). The ox\dev\OxGiveWin.bas file declares the functions
which are required to establish the link with GiveWin 2 (documented in §A2.4).
The MATRIX (§A2.5.1) and OxVALUE (§A2.3) types use pointers, which cannot be
directly manipulated in VB. However, passing such pointers back and forth in Ox func-
tion calls is not a problem.
Komentarze do niniejszej Instrukcji