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 / iipframe.cpp < prev    next >
C/C++ Source or Header  |  1995-05-03  |  8KB  |  349 lines

  1. /*
  2.  * IIPFRAME.CPP
  3.  *
  4.  * Template IOleInPlaceFrame interface implementation.
  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 "iipframe.h"
  15.  
  16.  
  17. /*
  18.  * CImpIOleInPlaceFrame::CImpIOleInPlaceFrame
  19.  * CImpIOleInPlaceFrame::~CImpIOleInPlaceFrame
  20.  *
  21.  * Parameters (Constructor):
  22.  *  pObj            LPVOID of the object we're in.
  23.  *  pUnkOuter       LPUNKNOWN to which we delegate.
  24.  */
  25.  
  26. CImpIOleInPlaceFrame::CImpIOleInPlaceFrame(LPVOID pObj
  27.     , LPUNKNOWN pUnkOuter)
  28.     {
  29.     m_cRef=0;
  30.     m_pObj=pObj;
  31.     m_pUnkOuter=pUnkOuter;
  32.     return;
  33.     }
  34.  
  35. CImpIOleInPlaceFrame::~CImpIOleInPlaceFrame(void)
  36.     {
  37.     return;
  38.     }
  39.  
  40.  
  41.  
  42. /*
  43.  * CImpIOleInPlaceFrame::QueryInterface
  44.  * CImpIOleInPlaceFrame::AddRef
  45.  * CImpIOleInPlaceFrame::Release
  46.  *
  47.  * Purpose:
  48.  *  Delegating IUnknown members for CImpIOleInPlaceFrame.
  49.  */
  50.  
  51. STDMETHODIMP CImpIOleInPlaceFrame::QueryInterface(REFIID riid
  52.     , LPVOID *ppv)
  53.     {
  54.     return m_pUnkOuter->QueryInterface(riid, ppv);
  55.     }
  56.  
  57. STDMETHODIMP_(ULONG) CImpIOleInPlaceFrame::AddRef(void)
  58.     {
  59.     ++m_cRef;
  60.     return m_pUnkOuter->AddRef();
  61.     }
  62.  
  63. STDMETHODIMP_(ULONG) CImpIOleInPlaceFrame::Release(void)
  64.     {
  65.     --m_cRef;
  66.     return m_pUnkOuter->Release();
  67.     }
  68.  
  69.  
  70.  
  71.  
  72. /*
  73.  * CImpIOleInPlaceFrame::GetWindow
  74.  *
  75.  * Purpose:
  76.  *  Retrieves the handle of the window associated with the object
  77.  *  on which this interface is implemented.
  78.  *
  79.  * Parameters:
  80.  *  phWnd           HWND * in which to store the window handle.
  81.  *
  82.  * Return Value:
  83.  *  HRESULT         NOERROR if successful, E_FAIL if no window.
  84.  */
  85.  
  86. STDMETHODIMP CImpIOleInPlaceFrame::GetWindow(HWND *phWnd)
  87.     {
  88.     return ResultFromScode(E_FAIL);
  89.     }
  90.  
  91.  
  92.  
  93.  
  94. /*
  95.  * CImpIOleInPlaceFrame::ContextSensitiveHelp
  96.  *
  97.  * Purpose:
  98.  *  Instructs the object on which this interface is implemented to
  99.  *  enter or leave a context-sensitive help mode.
  100.  *
  101.  * Parameters:
  102.  *  fEnterMode      BOOL TRUE to enter the mode, FALSE otherwise.
  103.  */
  104.  
  105. STDMETHODIMP CImpIOleInPlaceFrame::ContextSensitiveHelp(
  106.     BOOL fEnterMode)
  107.     {
  108.     return NOERROR;
  109.     }
  110.  
  111.  
  112.  
  113.  
  114. /*
  115.  * CImpIOleInPlaceFrame::GetBorder
  116.  *
  117.  * Purpose:
  118.  *  Returns the rectangle in which the container is willing to
  119.  *  negotiate about an object's adornments.
  120.  *
  121.  * Parameters:
  122.  *  prcBorder       LPRECT in which to store the rectangle.
  123.  *
  124.  * Return Value:
  125.  *  HRESULT         NOERROR if all is well, INPLACE_E_NOTOOLSPACE
  126.  *                  if there is no negotiable space.
  127.  */
  128.  
  129. STDMETHODIMP CImpIOleInPlaceFrame::GetBorder(LPRECT prcBorder)
  130.     {
  131.     return NOERROR;
  132.     }
  133.  
  134.  
  135.  
  136.  
  137. /*
  138.  * CImpIOleInPlaceFrame::RequestBorderSpace
  139.  *
  140.  * Purpose:
  141.  *  Asks the container if it can surrender the amount of space
  142.  *  in pBW that the object would like for it's adornments.  The
  143.  *  container does nothing but validate the spaces on this call.
  144.  *
  145.  * Parameters:
  146.  *  pBW             LPCBORDERWIDTHS containing the requested space.
  147.  *                  The values are the amount of space requested
  148.  *                  from each side of the relevant window.
  149.  *
  150.  * Return Value:
  151.  *  HRESULT         NOERROR if we can give up space,
  152.  *                  INPLACE_E_NOTOOLSPACE otherwise.
  153.  */
  154.  
  155. STDMETHODIMP CImpIOleInPlaceFrame::RequestBorderSpace(
  156.     LPCBORDERWIDTHS pBW)
  157.     {
  158.     return NOERROR;
  159.     }
  160.  
  161.  
  162.  
  163.  
  164. /*
  165.  * CImpIOleInPlaceFrame::SetBorderSpace
  166.  *
  167.  * Purpose:
  168.  *  Called when the object now officially requests that the
  169.  *  container surrender border space it previously allowed
  170.  *  in RequestBorderSpace.  The container should resize windows
  171.  *  appropriately to surrender this space.
  172.  *
  173.  * Parameters:
  174.  *  pBW             LPCBORDERWIDTHS containing the amount of space
  175.  *                  from each side of the relevant window that the
  176.  *                  object is now reserving.
  177.  */
  178.  
  179. STDMETHODIMP CImpIOleInPlaceFrame::SetBorderSpace(
  180.     LPCBORDERWIDTHS pBW)
  181.     {
  182.     return NOERROR;
  183.     }
  184.  
  185.  
  186.  
  187.  
  188. /*
  189.  * CImpIOleInPlaceFrame::SetActiveObject
  190.  *
  191.  * Purpose:
  192.  *  Provides the container with the object's IOleInPlaceActiveObject
  193.  *  pointer and a name of the object to show in the container's
  194.  *  caption.
  195.  *
  196.  * Parameters:
  197.  *  pIIPActiveObj   LPOLEINPLACEACTIVEOBJECT of interest.
  198.  *  pszObj          LPCOLESTR to use in the container's caption bar.
  199.  */
  200.  
  201. STDMETHODIMP CImpIOleInPlaceFrame::SetActiveObject(
  202.     LPOLEINPLACEACTIVEOBJECT pIIPActiveObj, LPCOLESTR pszObj)
  203.     {
  204.     return NOERROR;
  205.     }
  206.  
  207.  
  208.  
  209.  
  210. /*
  211.  * CImpIOleInPlaceFrame::InsertMenus
  212.  *
  213.  * Purpose:
  214.  *  Instructs the container to place its in-place menu items where
  215.  *  necessary in the given menu and to fill in elements 0, 2, and 4
  216.  *  of the OLEMENUGROUPWIDTHS array to indicate how many top-level
  217.  *  items are in each group.
  218.  *
  219.  * Parameters:
  220.  *  hMenu           HMENU in which to add popups.
  221.  *  pMGW            LPOLEMENUGROUPWIDTHS in which to store the
  222.  *                  width of each container menu group.
  223.  */
  224.  
  225. STDMETHODIMP CImpIOleInPlaceFrame::InsertMenus(HMENU hMenu
  226.     , LPOLEMENUGROUPWIDTHS pMGW)
  227.     {
  228.     return NOERROR;
  229.     }
  230.  
  231.  
  232.  
  233.  
  234. /*
  235.  * CImpIOleInPlaceFrame::SetMenu
  236.  *
  237.  * Purpose:
  238.  *  Instructs the container to replace whatever menu it's currently
  239.  *  using with the given menu and to call OleSetMenuDescritor so
  240.  *  OLE knows to whom to dispatch messages.
  241.  *
  242.  * Parameters:
  243.  *  hMenu           HMENU to show.
  244.  *  hOLEMenu        HOLEMENU to the menu descriptor.
  245.  *  hWndObj         HWND of the active object to which messages
  246.  *                  are dispatched.  Usually a frame window.
  247.  */
  248.  
  249. STDMETHODIMP CImpIOleInPlaceFrame::SetMenu(HMENU hMenu
  250.     , HOLEMENU hOLEMenu, HWND hWndObj)
  251.     {
  252.     return NOERROR;
  253.     }
  254.  
  255.  
  256.  
  257.  
  258. /*
  259.  * CImpIOleInPlaceFrame::RemoveMenus
  260.  *
  261.  * Purpose:
  262.  *  Asks the container to remove any menus it put into hMenu in
  263.  *  InsertMenus.
  264.  *
  265.  * Parameters:
  266.  *  hMenu           HMENU from which to remove the container's
  267.  *                  items.
  268.  */
  269.  
  270. STDMETHODIMP CImpIOleInPlaceFrame::RemoveMenus(HMENU hMenu)
  271.     {
  272.     return NOERROR;
  273.     }
  274.  
  275.  
  276.  
  277.  
  278. /*
  279.  * CImpIOleInPlaceFrame::SetStatusText
  280.  *
  281.  * Purpose:
  282.  *  Asks the container to place some text in a status line, if
  283.  *  one exists.  If the container does not have a status line it
  284.  *  should return E_FAIL here in which case the object could
  285.  *  display its own.
  286.  *
  287.  * Parameters:
  288.  *  pszText         LPCOLESTR to display.
  289.  *
  290.  * Return Value:
  291.  *  HRESULT         NOERROR if successful, S_TRUNCATED if not all
  292.  *                  of the text could be displayed, or E_FAIL if
  293.  *                  the container has no status line.
  294.  */
  295.  
  296. STDMETHODIMP CImpIOleInPlaceFrame::SetStatusText(LPCOLESTR pszText)
  297.     {
  298.     return ResultFromScode(E_FAIL);
  299.     }
  300.  
  301.  
  302.  
  303.  
  304. /*
  305.  * CImpIOleInPlaceFrame::EnableModeless
  306.  *
  307.  * Purpose:
  308.  *  Instructs the container to show or hide any modeless popup
  309.  *  windows that it may be using.
  310.  *
  311.  * Parameters:
  312.  *  fEnable         BOOL indicating to enable/show the windows
  313.  *                  (TRUE) or to hide them (FALSE).
  314.  */
  315.  
  316. STDMETHODIMP CImpIOleInPlaceFrame::EnableModeless(BOOL fEnable)
  317.     {
  318.     return NOERROR;
  319.     }
  320.  
  321.  
  322.  
  323.  
  324. /*
  325.  * CImpIOleInPlaceFrame::TranslateAccelerator
  326.  *
  327.  * Purpose:
  328.  *  When dealing with an in-place object from an EXE server, this
  329.  *  is called to give the container a chance to process accelerators
  330.  *  after the server has looked at the message.
  331.  *
  332.  * Parameters:
  333.  *  pMSG            LPMSG for the container to examine.
  334.  *  wID             WORD identifier in the container's accelerator
  335.  *                  table (from IOleInPlaceSite::GetWindowContext)
  336.  *                  for this message (OLE does some translation
  337.  *                  before calling).
  338.  *
  339.  * Return Value:
  340.  *  HRESULT         NOERROR if the keystroke was used,
  341.  *                  S_FALSE otherwise.
  342.  */
  343.  
  344. STDMETHODIMP CImpIOleInPlaceFrame::TranslateAccelerator(LPMSG pMSG
  345.     , WORD wID)
  346.     {
  347.     return ResultFromScode(S_FALSE);
  348.     }
  349.