How to handle VPE Events using the MFC

<< Click to Display Table of Contents >>

Navigation:  Addendum >

How to handle VPE Events using the MFC

Previous pageReturn to chapter overview

The events fired by VPE can be handled in two ways:

either use VPE_FIXED_MESSAGES when calling VpeOpenDoc()

or do the following:

 

Define the message map in your parent window of VPE as:

BEGIN_MESSAGE_MAP(CMyWnd)

 ON_REGISTERED_MESSAGE(uVpeDestroyWindow, OnVpeDestroyWindow)

 ON_REGISTERED_MESSAGE(uVpeHelp, OnVpeHelp)

 ON_REGISTERED_MESSAGE(uVpePrint, OnVpePrint)

 ON_REGISTERED_MESSAGE(uVpePrintNewPage, OnVpePrintNewPage)

 ON_REGISTERED_MESSAGE(uVpeCloseWindow, OnVpeCloseWindow)

 ON_REGISTERED_MESSAGE(uVpeObjectClicked, OnVpeObjectClicked)

 ON_REGISTERED_MESSAGE(uVpeUDOPaint, OnVpeUDOPaint)

 ON_REGISTERED_MESSAGE(uVpeAutoPageBreak, OnVpeAutoPageBreak)

 ON_REGISTERED_MESSAGE(uVpeBeforeMail, OnVpeBeforeMail)

 ON_REGISTERED_MESSAGE(uVpeAfterMail, OnVpeAfterMail)

 ON_REGISTERED_MESSAGE(uVpePrintDevData, OnVpePrintDevData)

END_MESSAGE_MAP()

 

and the constants itself as public in the CMyWnd.h class:

// Registered window messages

public:

 static const UINT uVpeDestroyWindow;

 static const UINT uVpePrint;

 static const UINT uVpeAutoPageBreak;

 static const UINT uVpePrintNewPage;

 static const UINT uVpeHelp;

 static const UINT uVpeCloseWindow;

 static const UINT uVpeObjectClicked;

 static const UINT uVpeUDOPaint;

 static const UINT uVpeBeforeMail;

 static const UINT uVpeAfterMail;

 static const UINT uVpePrintDevData;

In CMyWnd.cpp assign the according values to the constants in the global initialization block of the module, i.e. not within a method:

const UNT CMyWnd::uVpeDestroyWindow = RegisterWindowMessage (_T(")/$%!VpeDestroyWindow"));

 

const UINT CMyWnd::uVpePrint = RegisterWindowMessage (_T(")/$%!VpePrint"));

 

const UINT CMyWnd::uVpeAutoPageBreak = RegisterWindowMessage (_T(")/$%!VpeAutoPageBreak"));

 

const UINT CMyWnd::uVpePrintNewPage = RegisterWindowMessage (_T(")/$%!VpePrintNewPage"));

 

const UINT CMyWnd::uVpeHelp = RegisterWindowMessage (_T(")/$%!VpeHelp"));

 

const UINT CMyWnd::uVpeCloseWindow = RegisterWindowMessage (_T(")/$%!VpeCloseWindow"));

 

const UINT CMyWnd::uVpeObjectClicked = RegisterWindowMessage (_T(")/$%!VpeObjectClicked"));

 

const UINT CMyWnd::uVpeUDOPaint = RegisterWindowMessage (_T(")/$%!VpeUDOPaint"));

 

const UINT CMyWnd::uVpeBeforeMail = RegisterWindowMessage (_T(")/$%!VpeBeforeMail"));

 

const UINT CMyWnd::uVpeAfterMail = RegisterWindowMessage (_T(")/$%!VpeAfterMail"));

 

const UINT CMyWnd::uVpePrintDevData = RegisterWindowMessage (")/$%!VpePrintDevData");