14.4.6 User-defined DLL compatible with VIEW/ViewDAQ

 

Users can call  a user-defined function located inside a DLL from within ViewDAQ/View Client. The user-defined function can be, for example, a customized dialog box. The syntax is of the Key Macro is:

 

<DLLEXEC>MyFunction^data@MyDLL.dll

 

                             

 

MyFunction residing in MyDLL.dll must have the prototype as follows:

 

 

#ifdef MYDLL_EXPORTS

#define MY_API __declspec(dllexport)

#else

#define MY_API __declspec(dllimport)

#endif

#ifdef __cplusplus

extern "C" {

#endif  /* __cplusplus */

void MY_API MyFunction(HWND hWnd_main, const char *data);

#ifdef __cplusplus

}

#endif

 

Please note that the execution flow of ViewDAQ/View Client will be blocked. Therefore, we also provide a function -- VcViewTimerCallback()-- to be used with MyFunction to prevent from blocking the execution flow.  Users must implement a 25 msec timer to call this function and take actions according the return value. The following is an example of how this can be done.

 

void CMyFunction::OnTimer(UINT nIdEvent)

{

     If (nIdEvent == FG_UPDATE_TIMER) {

           LRESULT dlgState = VcViewTimerCallback();

           if (dlgState == DAQDLG_QUIT)

                OnCancel();

           else if (dlgState == DAQDLG_HIDE) {

                ShowWindow(SW_HIDE);

           }                       

           else if (dlgState == DAQDLG_SHOW) {

                ShowWindow(SW_SHOWNA);

           }

     }

}

 

 

We also provide three more functions for users to GetValue from, SetValue to, and SendCmd to ViewDAQ/View client that invokes MyFunction: They are:

 

char VC_API * VcViewGetValue(LPCTSTR Tag);

void VC_API VcViewSetValue(LPCTSTR Tag, LPCTSTR Value);

void VC_API VcViewSendCmd(LPCTSTR Cmd);

 

There are four functions for users to create their URL displays inside dialog boxes in the user-defined DLL. They are:

 

void VC_API VcCreateWebBrowser(HWND hWndParent, RECT Rect, const char *UrlString);

void VC_API VcUpdateWebBrowser(const char *UrlString);

void VC_API VcResizeWebBrowser(RECT Rect);

void VC_API VcDeleteWebBrowser();

 

Where UrlString can be any ordinary URLs or in the format of UTI:/DAQ:/VDO: syntax. Please note that only one URL display is allowed in a dialog box. Please also make sure that the dialog box has the WS_CLIPCHILDREN attribute to avoid redrawing issues.

 

A sample MyDLL project exists to demonstrate how to use these APIs is available from Broadwin’s Milpitas office. To test MyDLL.dll, please copy MyDLL.dll to WebAccess\Node directory and use MyDLL.bgr the call up the sample dialog box.

 

The required header file and library file for these functions are located in WebAccess/node directory. Please note that MyDLL.dll must be put in WebAccess/node directory. When calling up MyFunction from with View client, MyDLL.dll will be automatically downloaded from the SCADA node to client computers.

 

See also, 11.1.34.1 DLLEXEC.