home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / inole2 / interfac / imsgfilt.cpp < prev    next >
C/C++ Source or Header  |  1996-05-21  |  4KB  |  169 lines

  1. /*
  2.  * IMSGFILT.CPP
  3.  *
  4.  * Template IMessageFilter object.
  5.  *
  6.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  7.  *
  8.  * Kraig Brockschmidt, Microsoft
  9.  * Internet  :  kraigb@microsoft.com
  10.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  11.  */
  12.  
  13.  
  14. #include "imsgfilt.h"
  15.  
  16.  
  17. /*
  18.  * CMessageFilter::CMessageFilter
  19.  * CMessageFilter::~CMessageFilter
  20.  *
  21.  * Parameters (Constructor):
  22.  *  None
  23.  */
  24.  
  25. CMessageFilter::CMessageFilter(void)
  26.     {
  27.     m_cRef=0;
  28.     return;
  29.     }
  30.  
  31. CMessageFilter::~CMessageFilter(void)
  32.     {
  33.     return;
  34.     }
  35.  
  36.  
  37.  
  38. /*
  39.  * CMessageFilter::QueryInterface
  40.  * CMessageFilter::AddRef
  41.  * CMessageFilter::Release
  42.  *
  43.  * Purpose:
  44.  *  Delegating IUnknown members for CMessageFilter.
  45.  */
  46.  
  47. STDMETHODIMP CMessageFilter::QueryInterface(REFIID riid
  48.     , LPVOID *ppv)
  49.     {
  50.     *ppv=NULL;
  51.  
  52.     if (IID_IUnknown==riid || IID_IMessageFilter==riid)
  53.         *ppv=this;
  54.  
  55.     if (NULL!=*ppv)
  56.         {
  57.         ((LPUNKNOWN)*ppv)->AddRef();
  58.         return NOERROR;
  59.         }
  60.  
  61.     return ResultFromScode(E_NOINTERFACE);
  62.     }
  63.  
  64. STDMETHODIMP_(ULONG) CMessageFilter::AddRef(void)
  65.     {
  66.     return ++m_cRef;
  67.     }
  68.  
  69. STDMETHODIMP_(ULONG) CMessageFilter::Release(void)
  70.     {
  71.     if (0!=--m_cRef)
  72.         return m_cRef;
  73.  
  74.     delete this;
  75.     return 0;
  76.     }
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83. /*
  84.  * CMessageFilter::HandleInComingCall
  85.  *
  86.  * Purpose:
  87.  *  Requests that the container call OleSave for the object that
  88.  *  lives here.  Typically this happens on server shutdown.
  89.  *
  90.  * Parameters:
  91.  *  dwCallType      DWORD indicating the type of call received, from
  92.  *                  the CALLTYPE enumeration
  93.  *  hTaskCaller     HTASK of the caller
  94.  *  dwTickCount     DWORD elapsed tick count since the outgoing call
  95.  *                  was made if dwCallType is not CALLTYPE_TOPLEVEL.
  96.  *                  Ignored for other call types.
  97.  *  pInterfaceInfo  LPINTERFACEINFO providing information about the
  98.  *                  call.  Can be NULL.
  99.  *
  100.  * Return Value:
  101.  *  DWORD           One of SERVERCALL_ISHANDLED (if the call might
  102.  *                  be handled), SERVERCALL_REJECTED (call cannot
  103.  *                  be handled), or SERVERCALL_RETRYLATER (try
  104.  *                  again sometime).
  105.  */
  106.  
  107. STDMETHODIMP_(DWORD) CMessageFilter::HandleInComingCall
  108.     (DWORD dwCallType, HTASK htaskCaller, DWORD dwTickCount
  109.     , LPINTERFACEINFO pInterfaceInfo)
  110.     {
  111.     return SERVERCALL_ISHANDLED;
  112.     }
  113.  
  114.  
  115.  
  116.  
  117.  
  118. /*
  119.  * CMessageFilter::RetryRejectedCall
  120.  *
  121.  * Purpose:
  122.  *
  123.  * Parameters:
  124.  *  hTaskCallee     HTASK of the caller
  125.  *  dwTickCount     DWORD elapsed tick count since the call was made
  126.  *  dwRejectType    DWORD either SERVERCALL_REJECTED or
  127.  *                  SERVERCALL_RETRYLATER as returned by
  128.  *                  HandleInComingCall.
  129.  *
  130.  * Return Value:
  131.  *  DWORD           (DWORD)-1 to cancel the call, any number between
  132.  *                  0 and 100 to try the call again immediately, or
  133.  *                  a value over 100 (but not (DWORD)-1) to instruct
  134.  *                  COM to wait that many milliseconds before trying
  135.  *                  again.
  136.  */
  137.  
  138. STDMETHODIMP_(DWORD) CMessageFilter::RetryRejectedCall
  139.     (HTASK htaskCallee, DWORD dwTickCount, DWORD dwRejectType)
  140.     {
  141.     return 0;
  142.     }
  143.  
  144.  
  145.  
  146. /*
  147.  * CMessageFilter::MessagePending
  148.  *
  149.  * Purpose:
  150.  *
  151.  * Parameters:
  152.  *  hTaskCallee     HTASK of the caller
  153.  *  dwTickCount     DWORD elapsed tick count since the call was made
  154.  *  dwPendingType   DWORD with the type of call made from the
  155.  *                  PENDINGTYPE enumeration.
  156.  *
  157.  * Return Value:
  158.  *  DWORD           One of PENDINGMSG_CANCELCALL (cancels the call
  159.  *                  under extreme conditions), PENDINGMSG_WAITNO-
  160.  *                  PROCESS (continue waiting), or PENDINGMSG_-
  161.  *                  WAITDEFPROCESS (invoke default handling).
  162.  */
  163.  
  164. STDMETHODIMP_(DWORD) CMessageFilter::MessagePending
  165.     (HTASK htaskCallee, DWORD dwTickCount, DWORD dwPendingType)
  166.     {
  167.     return PENDINGMSG_WAITDEFPROCESS;
  168.     }
  169.