FaxMan SDK Version 4.7
Setting Up to Communicate With FaxMan

Before your application can really start working with FaxMan, you'll want to add code to handle the event notifications FaxMan uses to keep your application informed. These events come to your app in the form of Windows messages sent to the HWND you registered with the server in the FaxRegisterApp function. To deal with these event messages, you'll need to add some code to the window handler for the registered window.

 

The notification messages sent to your application from the FaxMan server break down into the following groups:

 

Changes in Faxmodem Status (FAXMODEMMSG)

FAXMODEMMSG messages are sent to notify your app when a given faxmodem changes state (i.e., idle to sending a fax) or when a faxmodem is added to or removed from the FaxMan system.

 

Additions and Deletions from the fax logs (FAXLOGADD / FAXLOGREMOVE)

For example, when a scheduled fax transitions from the pending log to the sending log, your app will be notified of its removal from the pending log (FAXLOGREMOVE) and its addition to the sending log (FAXLOGADD).

 

Changes in Server Configuration (FAXSERVERCONFIGMSG)

When the fax server changes state, for instance when it goes from Auto Receive ON to Auto Receive OFF (possibly as the result of the actions of another application), your app is notified with one of these messages indicating the server configuration setting which changed and its new value.

 

Print status messages at print end time (FAXPRINTMSG)

When printing is completed, your app will receive this message which reports the outcome of the printing process.

 

Your application won't receive any of these messages unless it first calls the FaxSubscribe function to notify FaxMan that you want them. Here's a general idea of the code you would incorporate into your message handler if your application were subscribing to all of the available message types:

 

//

// First call FaxSubscribe to subscribe to the notifications.

// This can be done anywhere in your code, as long as you do it

// *before* you want to start getting notification messages. Most

// applications will call this as part of their FaxMan

// initialization code (probably right after FaxRegisterApp)

// as shown below...

//

PAPPINFO pInfo;

 

pInfo = FaxRegisterApp("MyGroovyFaxApp", hMyWnd);

FaxSubscribe(pInfo, SUBSCRIBE_LOG_ALL | //log subscriptions

        SUBSCRIBE_FAXMODEM |  //FAXMODEMMSG subscriptions

        SUBSCRIBE_SERVER_CONFIG); //FAXSERVERCONFIGMSGs

...

 

//

// The print messages will arrive whether you ask for them

// or not if you've configured this application as a

// "print receiver" for the FaxMan print driver.

//

// The following is the text of a window procedure you

// might create to handle the FaxMan notification messages.

//

LONG FAR PASCAL MyWndProc(HWND hWnd, WORD wMsg, WORD wParam, LONG lParam)

{

 PSEND_FAX  pFax;

 PPRINTSTAT ps;

 FAXDEVICE   *pDev;

 SERVER_CONFIG *pConfig;

 

 // You'll probably include the WM_FAXMSG identifier as part

 // of your outermost switch statement. Here we just return

 // if the wMsg isn't WM_FAXMSG, since we assume this window

 // exists only to service FaxMan messages.

 if (wMsg != WM_FAXMSG) return 0;

 

 switch (wParam) {

  case FAXSERVERCONFIGMSG: 

   //lParam points to a SERVER_CONFIG structure

   pConfig = (PSERVER_CONFIG)lParam;   

   ...

   break;

 

  case FAXMODEMMSG:

   //lParam points to a FAXDEVICE structure

   pDev = (PFAXDEVICE)lParam;    

   ...

   break;

 

  case FAXSENDMSG:

   //lParam points to a SEND_FAX structure

   pFax = (PSEND_FAX)lParam;    

   ...

   break;

 

  case FAXPRINTMSG:

   //lParam points to a PRINTSTAT structure

   ps = (PPRINTSTAT)lParam;    

   ...

   break;

 

  case FAXLOGADD:

   //lParam points to a SEND_FAX structure

   pFax = (PSEND_FAX)lParam; 

   switch (pFax->wLog) { 

   //pFax->wLog tells us which log we're adding to

    case SUBSCRIBE_LOG_PENDING:

     break;

    case SUBSCRIBE_LOG_SENDING:

     break;

    case SUBSCRIBE_LOG_COMPLETE:

     break;

    case SUBSCRIBE_LOG_FAILED:

     break;

    case SUBSCRIBE_LOG_RECEIVE:

     break;

   }

   ...

   break;

 

  case FAXLOGREMOVE:

   //lParam points to a SEND_FAX structure

   pFax = (PSEND_FAX)lParam; 

   switch (pFax->wLog) { 

    //pFax->wLog tells us which log we're removing from

    case SUBSCRIBE_LOG_PENDING:

     break;

    case SUBSCRIBE_LOG_SENDING:

     break;

    case SUBSCRIBE_LOG_COMPLETE:

     break;

    case SUBSCRIBE_LOG_FAILED:

     break;

    case SUBSCRIBE_LOG_RECEIVE:

     break;

   }

   ...

   break;

 }

 

 return 0L;

 

As you can see, setting up your application to receive these notification messages is a very straightforward process - it's just like dealing with any other Windows messages. Just remember that you must subscribe to them before you'll receive them.

 

 


© 2013 Data Techniques, Inc. All Rights Reserved.

Send comments on this topic.