VpeMapMessage

<< Click to Display Table of Contents >>

Navigation:  Management Functions >

VpeMapMessage

Previous pageReturn to chapter overviewNext page

[Windows platform only]

This method maps a globally registered VPE Message into one of the VPE_xyz message constants.

Working with the VPE Messages is not necessary, but it makes the use of VPE and the interaction between your application, VPE and the end user much more well-appointed.

The messages generated by VPE (e.g. VPE_DESTROYWINDOW, etc.) are globally registered in the windows system to avoid conflicts with other controls and applications. As it is unknown, what value equals each message, you need to map the messages with this method in your window-procedure.

If your tool is not able to process dynamically window-messages, or if you want to gain the old behavior of VPE prior to v3.0 (having fixed values for each message), use the new flag VPE_FIXED_MESSAGES in VpeOpenDoc(). If you use VPE_FIXED_MESSAGES, VPE will directly send the VPE_xyz message constants to the window procedure of your parent window, instead of sending the globally registered messages. You may not call VpeMapMessage(), if you are using VPE_FIXED_MESSAGES.

UINT VpeMapMessage(

VpeHandle hDoc,

UINT message

)

VpeHandle hDoc

Document Handle

UINT message

the message received in the window procedure of your parent window

Returns:

One of the VPE_xyz message constants, see Messages Generated by VPE ‑ DLL.

Remarks:

To make things easier if you have multiple open documents, VpeMapMessage() assumes for hDoc = NULL that no fixed messages are used and directly maps the message into the dynamic message map. You can only make use of this feature, if ALL VPE-Documents were created with dynamic message mapping.

 

C/C++ Example with fixed messages VpeOpenDoc(..., VPE_FIXED_MESSAGES):

// ==================================================================

//                              WndProc

// ==================================================================

long FAR PASCAL _export WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)

{

 switch (message)

 {

 case WM_LBUTTONDOWN:

         if (!hDoc)

                 MiniDemo(hwnd);        // creates doc, sets global hDoc-variable

         return 0;

 

 case VPE_DESTROYWINDOW:

         hDoc = 0;

         PostMessage(hwnd, WM_CLOSE, 0, 0);        // only, if preview is embedded!

         return 0;

 

 case WM_CLOSE:

         if (!VpeCloseDoc(hDoc))

         {

                 Msg("The application cannot terminate until all jobs have finished printing.");

                 return 0;

         }

         DestroyWindow(hwnd);

         return 1;

 

 case WM_DESTROY:

         PostQuitMessage(0);

         return 0;

 }

 

 return DefWindowProc(hwnd, message, wParam, lParam);

}

 

C/C++ Example with dynamic message mapping:

// ==================================================================

//                              WndProc

// ==================================================================

long FAR PASCAL _export WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)

{

 switch (message)

 {

 case WM_LBUTTONDOWN:

         if (!hDoc)

                 MiniDemo(hwnd);        // creates doc, sets global hDoc-variable

         return 0;

 

 case WM_CLOSE:

         if (!VpeCloseDoc(hDoc))

         {

                 Msg("The application cannot terminate until all jobs have finished printing.");

                 return 0;

         }

         DestroyWindow(hwnd);

         return 1;

 

 case WM_DESTROY:

         PostQuitMessage(0);

         return 0;

 }

 

 if (hDoc)

 {

         switch (VpeMapMessage(hDoc, message))

         {

         case VPE_DESTROYWINDOW:

                 hDoc = 0;

                 PostMessage(hwnd, WM_CLOSE, 0, 0);   // only, if preview is embedded!

                 return 0;

         }

 }

 

 return DefWindowProc(hwnd, message, wParam, lParam);

}

 

C/C++ Example with dynamic message mapping and multiple documents:

// ==================================================================

//                              WndProc

// ==================================================================

long FAR PASCAL _export WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)

{

 switch (message)

 {

 

 .

 .

 .

 

 case WM_CLOSE:

         if (!VpeCloseDoc(hDocRTF) ||

                 !VpeCloseDoc(hDocUDO) ||

                 !VpeCloseDoc(hDocScale2Gray))

         {

                 Msg("The application cannot terminate until all jobs have finished printing.");

                 return 0;

         }

         DestroyWindow(hwnd);

         return 1;

 

 case WM_DESTROY:

         PostQuitMessage(0);

         return 0;

 }

 

 switch (VpeMapMessage(NULL, message))

 {

 case VPE_DESTROYWINDOW:

         if (hDocRTF == lParam)                // identify document, the message is for...

                 hDocRTF = 0;

         else if (hDocUDO == lParam)

                 hDocUDO = 0;

         else if (hDocScale2Gray == lParam)

                 hDocScale2Gray = 0;

         return 0;

 

 case VPE_PRINT: // the following MessageBoxes will appear for all Docs

         switch (wParam)

         {

         case PRINT_MSG_SETUPABORT:  // User aborted Setup-Dialog

                 MessageBox(hwnd, "Caught event from VPE: Setup aborted.", szAppName, MB_OK);

                 break;

 

         case PRINT_MSG_SETUPSTART: // Setup-Dialog started

                 MessageBox(hwnd, "Caught event from VPE: Setup started.", szAppName, MB_OK);

                 break;

         }

         return 0;

 }

 return DefWindowProc(hwnd, message, wParam, lParam);

}