HP-UX SNAplus2 CPI-C Programmer's Guide (June 2003)
Writing CPI-C Applications
Windows Considerations
Chapter 2 109
• Issue CPI-C calls on other conversations for which the processing
mode is CM_NON_BLOCKING
Default Blocking Function
The standard blocking function used by the Windows CPI-C library is as
follows:
BOOL DefaultBlockingHook (void) {
MSG msg;
/* get the next message if any */
if ( PeekMessage (&msg,0,0,PM_NOREMOVE) ) {
if ( msg.message == WM_QUIT )
return FALSE; // let app process WM_QUIT
PeekMessage (&msg,0,0,PM_REMOVE);
TranslateMessage (&msg);
DispatchMessage (&msg);
}
/* TRUE if no WM_QUIT received */
return TRUE;
}
If the application needs to have other processing performed as part of the
blocking function, it can specify its own blocking function to replace the
default one provided by CPI-C. To do this, it uses the
WinCPICSetBlockingHook() call, described in Chapter 3, “CPI-C Calls.”
A blocking function must return FALSE if it receives a WM_QUIT
message; this means that CPI-C returns control to the application, which
can then process the message and terminate. Otherwise, the function
must return TRUE.
Terminating Applications
CPI-C cannot tell when an application terminates under Windows.
Therefore if an application must close (for example, if it receives a
WM_CLOSE message), the application should issue the
WinCPICCleanup() call. Failure to issue the call leaves the system in an
indeterminate state; however, as much cleanup as possible is done when
CPI-C later detects that the application has terminated.
Compiling and Linking CPI-C Applications
This section provides information about compiling and linking CPI-C
applications on Windows systems.