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 / chap14 / cosmo / autofig.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-15  |  16.8 KB  |  738 lines

  1. /*
  2.  * AUTOFIG.CPP
  3.  * Cosmo Chapter 14
  4.  *
  5.  * "Figure" object for Cosmo's OLE Automation support, derived
  6.  * from CAutoBase.
  7.  *
  8.  * Copyright (c)1993-1995 Microsoft Corporation, All Right Reserved.
  9.  *
  10.  * Kraig Brockschmidt, Microsoft
  11.  * Internet  :  kraigb@microsoft.com
  12.  * Compuserve:  INTERNET>kraigb@microsoft.com
  13.  */
  14.  
  15.  
  16. #include "cosmo.h"
  17.  
  18.  
  19. /*
  20.  * CAutoFigure::CAutoFigure
  21.  * CAutoFigure::~CAutoFigure
  22.  *
  23.  * Constructor Parameters:
  24.  *  pDoc            PCCosmoDoc to the dpcument object that we
  25.  *                  use to implement much of this interface.
  26.  */
  27.  
  28. CAutoFigure::CAutoFigure(PCCosmoDoc pDoc)
  29.     : CAutoBase(pDoc, pDoc->m_hInst, IID_ICosmoFigure
  30.     , DIID_DICosmoFigure, ObjectDestroyed)
  31.     {
  32.     return;
  33.     }
  34.  
  35.  
  36. /*
  37.  * CAutoFigure::QueryInterface
  38.  * CAutoFigure::AddRef
  39.  * CAutoFigure::Release
  40.  */
  41.  
  42. STDMETHODIMP CAutoFigure::QueryInterface(REFIID riid, PPVOID ppv)
  43.     {
  44.     *ppv=NULL;
  45.  
  46.     if (IID_IUnknown==riid || IID_ICosmoFigure==riid)
  47.         *ppv=(IUnknown *)this;
  48.  
  49.     if (IID_IDispatch==riid || m_diid==riid)
  50.         *ppv=m_pImpIDispatch;
  51.  
  52.     if (IID_IExternalConnection==riid)
  53.         *ppv=m_pImpIExtConn;
  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) CAutoFigure::AddRef(void)
  65.     {
  66.     return ++m_cRef;
  67.     }
  68.  
  69. STDMETHODIMP_(ULONG) CAutoFigure::Release(void)
  70.     {
  71.     /*
  72.      * Since this object might have come from a class factory,
  73.      * we count it's existence (see NewFigure below) for
  74.      * controlling shutdown of the application when we call
  75.      * ObjectDestroyed.  Otherwise we always close the document.
  76.      */
  77.     if (0L!=--m_cRef)
  78.         return m_cRef;
  79.  
  80.     put_Visible(FALSE);
  81.     SendMessage(m_pDoc->Window(), WM_CLOSE, 0, 0L);
  82.  
  83.     if (NULL!=m_pfnDestroy)
  84.         (*m_pfnDestroy)();
  85.  
  86.     return 0L;
  87.     }
  88.  
  89.  
  90. /*
  91.  * CAutoFigure::VTableInterface
  92.  *
  93.  * Purpose:
  94.  *  Returns the right vtable pointer to use when calling
  95.  *  ITypeInfo::Invoke (see CImpIDispatch::Invoke in AUTOBASE.CPP).
  96.  */
  97. void *CAutoFigure::VTableInterface(void)
  98.     {
  99.     return (ICosmoFigure *)this;
  100.     }
  101.  
  102.  
  103.  
  104. //All that follows is the ICosmoFigure implementation
  105.  
  106. /*
  107.  * CAutoFigure::Application
  108.  * CAutoFigure::Parent
  109.  * Properties, read-only
  110.  *
  111.  * The application object (CAutoApp) in which we're contained,
  112.  * which is stored in the frame object
  113.  */
  114.  
  115. STDMETHODIMP_(IDispatch *) CAutoFigure::get_Application(void)
  116.     {
  117.     PCCosmoFrame    pFR;
  118.  
  119.     pFR=(PCCosmoFrame)m_pDoc->m_pFR;
  120.     return pFR->AutoApp()->get_Application();
  121.     }
  122.  
  123. STDMETHODIMP_(IDispatch *) CAutoFigure::get_Parent(void)
  124.     {
  125.     return get_Application();
  126.     }
  127.  
  128.  
  129. /*
  130.  * CAutoFigure::FullName, Name, Path
  131.  * Properties, read-only
  132.  *
  133.  * Retrieve the full pathname of the figure file (FullName),
  134.  * just the file name (Name), or just the path (Path).
  135.  *
  136.  * Note that these functions are very similar to the same
  137.  * ones in CAutoApp, and there is probably some code that could
  138.  * be shared between them, but this sample won't bother with
  139.  * such an optimization.
  140.  */
  141.  
  142. STDMETHODIMP_(BSTR) CAutoFigure::get_FullName(void)
  143.     {
  144.     if ((TCHAR)0==m_pDoc->m_szFile[0])
  145.         return NULL;
  146.  
  147.    #ifdef WIN32ANSI
  148.     OLECHAR     szTemp[512];
  149.  
  150.     MultiByteToWideChar(CP_ACP, 0, m_pDoc->m_szFile, -1, szTemp, 512);
  151.     return SysAllocString(szTemp);
  152.    #else
  153.     return SysAllocString(m_pDoc->m_szFile);
  154.    #endif
  155.     }
  156.  
  157. STDMETHODIMP_(BSTR) CAutoFigure::get_Name(void)
  158.     {
  159.     BSTR        bstrFull=NULL;
  160.     BSTR        bstrName=NULL;
  161.     const int   cch=256;
  162.     TCHAR       szName[256];
  163.  
  164.     //Get the full path
  165.     bstrFull=get_FullName();
  166.  
  167.     if (NULL==bstrFull)
  168.         return NULL;
  169.  
  170.     //Now retrieve just the filename
  171.    #ifdef WIN32ANSI
  172.     char        szTemp[cch];
  173.     OLECHAR     szTempW[cch];
  174.  
  175.     WideCharToMultiByte(CP_ACP, 0, bstrFull, -1, szTemp
  176.         , cch, NULL, NULL);
  177.     if (0==GetFileTitle(szTemp, szName, cch))
  178.         {
  179.         MultiByteToWideChar(CP_ACP, 0, szName, -1, szTempW, cch);
  180.         bstrName=SysAllocString(szTempW);
  181.         }
  182.    #else
  183.     if (0==GetFileTitle(bstrFull, szName, cch))
  184.         bstrName=SysAllocString(szName);
  185.    #endif
  186.  
  187.     SysFreeString(bstrFull);
  188.     return bstrName;
  189.     }
  190.  
  191. STDMETHODIMP_(BSTR) CAutoFigure::get_Path(void)
  192.     {
  193.     BSTR        bstrFull=NULL;
  194.     BSTR        bstrName=NULL;
  195.     BSTR        bstrPath=NULL;
  196.  
  197.     bstrFull=get_FullName();
  198.  
  199.     if (NULL==bstrFull)
  200.         return NULL;
  201.  
  202.     bstrName=get_Name();
  203.  
  204.     if (NULL!=bstrName)
  205.         {
  206.         LPOLESTR    psz;
  207.  
  208.         /*
  209.          * Find the position of bstrName in bstrFull then copy
  210.          * only charaters up to that point into bstrPath.
  211.          */
  212.        #ifdef WIN32ANSI
  213.         psz=wcsstr(bstrFull, bstrName);
  214.        #else
  215.         psz=_tcsstr(bstrFull, bstrName);
  216.        #endif
  217.  
  218.         //The -1 accounts for the \ before the filename
  219.         bstrPath=SysAllocStringLen(bstrFull
  220.             , ((psz-bstrFull)/sizeof(TCHAR))-1);
  221.         SysFreeString(bstrName);
  222.         }
  223.  
  224.     SysFreeString(bstrFull);
  225.     return bstrPath;
  226.     }
  227.  
  228.  
  229. /*
  230.  * CAutoFigure::Saved
  231.  * Property, read-only
  232.  *
  233.  * TRUE if the document is clean, FALSE otherwise.
  234.  */
  235.  
  236. STDMETHODIMP_(VARIANT_BOOL) CAutoFigure::get_Saved(void)
  237.     {
  238.     return !m_pDoc->FDirtyGet();
  239.     }
  240.  
  241.  
  242. /*
  243.  * CAutoFigure::NumberOfPoints
  244.  * Property, read-only
  245.  *
  246.  * Number of points in the current figure.
  247.  */
  248.  
  249. STDMETHODIMP_(short)CAutoFigure::get_NumberOfPoints(void)
  250.     {
  251.     POLYLINEDATA    pl;
  252.  
  253.     m_pDoc->m_pPL->DataGet(&pl, VERSIONCURRENT);
  254.     return pl.cPoints;
  255.     }
  256.  
  257.  
  258. /*
  259.  * CAutoFigure::BackColor
  260.  * CAutoFigure::LineColor
  261.  * Properties, read-write
  262.  *
  263.  * Colors used in the figure.
  264.  */
  265.  
  266. STDMETHODIMP_(long) CAutoFigure::get_BackColor(void)
  267.     {
  268.     return m_pDoc->ColorGet(POLYLINECOLOR_BACKGROUND);
  269.     }
  270.  
  271. STDMETHODIMP_(void) CAutoFigure::put_BackColor(long clrBack)
  272.     {
  273.     m_pDoc->ColorSet(POLYLINECOLOR_BACKGROUND, clrBack);
  274.     return;
  275.     }
  276.  
  277. STDMETHODIMP_(long) CAutoFigure::get_LineColor(void)
  278.     {
  279.     return m_pDoc->ColorGet(POLYLINECOLOR_LINE);
  280.     }
  281.  
  282. STDMETHODIMP_(void) CAutoFigure::put_LineColor(long clrLine)
  283.     {
  284.     m_pDoc->ColorSet(POLYLINECOLOR_LINE, clrLine);
  285.     return;
  286.     }
  287.  
  288.  
  289. /*
  290.  * CAutoFigure::LineStyle
  291.  * Property, read-write
  292.  *
  293.  * Line style used to draw the figure
  294.  */
  295.  
  296. STDMETHODIMP_(short)CAutoFigure::get_LineStyle(void)
  297.     {
  298.     return m_pDoc->LineStyleGet();
  299.     }
  300.  
  301. STDMETHODIMP_(void) CAutoFigure::put_LineStyle(short iStyle)
  302.     {
  303.     m_pDoc->LineStyleSet(iStyle);
  304.     return;
  305.     }
  306.  
  307.  
  308. /*
  309.  * CAutoFigure::Left, Top, Width, Height
  310.  * Properties, read-write
  311.  *
  312.  * Horizontal (Left) and vertical (Top) positions of the frame
  313.  * window from the left and top edges of the application client
  314.  * area; horizontal (Width) and vertical (Height) dimensions of
  315.  * document window.  All of these functions call our private member
  316.  * MoveSize, a helper function.
  317.  */
  318.  
  319. STDMETHODIMP_(long) CAutoFigure::get_Left(void)
  320.     {
  321.     return MoveSize(MOVESIZEACTION_GETLEFT, 0, 0, 0, 0);
  322.     }
  323.  
  324. STDMETHODIMP_(void) CAutoFigure::put_Left(long x)
  325.     {
  326.     MoveSize(MOVESIZEACTION_LEFT, x, 0, 0, 0);
  327.     return;
  328.     }
  329.  
  330. STDMETHODIMP_(long) CAutoFigure::get_Top(void)
  331.     {
  332.     return MoveSize(MOVESIZEACTION_GETTOP, 0, 0, 0, 0);
  333.     }
  334.  
  335. STDMETHODIMP_(void) CAutoFigure::put_Top(long y)
  336.     {
  337.     MoveSize(MOVESIZEACTION_TOP, 0, y, 0, 0);
  338.     return;
  339.     }
  340.  
  341. STDMETHODIMP_(long) CAutoFigure::get_Width(void)
  342.     {
  343.     return MoveSize(MOVESIZEACTION_GETWIDTH, 0, 0, 0, 0);
  344.     }
  345.  
  346. STDMETHODIMP_(void) CAutoFigure::put_Width(long cx)
  347.     {
  348.     MoveSize(MOVESIZEACTION_WIDTH, 0, 0, cx, 0);
  349.     return;
  350.     }
  351.  
  352. STDMETHODIMP_(long) CAutoFigure::get_Height(void)
  353.     {
  354.     return MoveSize(MOVESIZEACTION_GETHEIGHT, 0, 0, 0, 0);
  355.     }
  356.  
  357. STDMETHODIMP_(void) CAutoFigure::put_Height(long cy)
  358.     {
  359.     MoveSize(MOVESIZEACTION_HEIGHT, 0, 0, 0, cy);
  360.     return;
  361.     }
  362.  
  363.  
  364.  
  365. /*
  366.  * CAutoFigure::Visible
  367.  * Properties, read-write
  368.  *
  369.  * Controls visibility of the figure window (which is hidden by
  370.  * default when created through automation).
  371.  */
  372.  
  373. STDMETHODIMP_(VARIANT_BOOL)  CAutoFigure::get_Visible(void)
  374.     {
  375.     return (VARIANT_BOOL)IsWindowVisible(m_pDoc->Window());
  376.     }
  377.  
  378. STDMETHODIMP_(void) CAutoFigure::put_Visible(VARIANT_BOOL fShow)
  379.     {
  380.     ShowWindow(m_pDoc->Window(), fShow ? SW_SHOW : SW_HIDE);
  381.     return;
  382.     }
  383.  
  384.  
  385. /*
  386.  * CAutoFigure::Activate
  387.  * Method
  388.  *
  389.  * Activate this window, that is, bring it to the foreground
  390.  */
  391.  
  392. STDMETHODIMP_(void) CAutoFigure::Activate(void)
  393.     {
  394.     HWND        hWndDoc;
  395.  
  396.     hWndDoc=m_pDoc->Window();
  397.     SendMessage(GetParent(hWndDoc), WM_MDIACTIVATE
  398.         , (WPARAM)hWndDoc, 0L);
  399.     return;
  400.     }
  401.  
  402.  
  403.  
  404. /*
  405.  * CAutoFigure::Close
  406.  * Method
  407.  *
  408.  * Closes this document.
  409.  *
  410.  * Parameters (optional)
  411.  *  fSaveChanges        BOOL that indicates if we're to save
  412.  *                      changes or not.  If not, then we just nuke
  413.  *                      the figure.
  414.  *  bstrPath            BSTR with the filename into which to save
  415.  *                      the figure if fSaveChanges is TRUE.  Note that
  416.  *                      this overrides any other pathname we are
  417.  *                      already using.
  418.  */
  419.  
  420. STDMETHODIMP_(void) CAutoFigure::Close(VARIANT varSave
  421.     , VARIANT varPath)
  422.     {
  423.     //If we got varSave and it's TRUE, then save
  424.     if (VT_ERROR!=varSave.vt && varSave.boolVal)
  425.         {
  426.         /*
  427.          * If we got a filename, call SaveAs.  Otherwise
  428.          * call Save.  If we don't have a filename for
  429.          * Save, then Save just fails and we don't have
  430.          * to care.
  431.          */
  432.         if (VT_ERROR!=varPath.vt)
  433.             SaveAs(varPath.bstrVal);
  434.         else
  435.             Save();
  436.         }
  437.  
  438.     //Hiding the document first suppresses any UI on closure.
  439.     put_Visible(FALSE);
  440.     SendMessage(m_pDoc->Window(), WM_CLOSE, 0, 0L);
  441.     return;
  442.     }
  443.  
  444.  
  445.  
  446. /*
  447.  * CAutoFigure::RevertToSaved
  448.  * Method
  449.  *
  450.  * Reloads the contents of the document from the saved state.
  451.  */
  452.  
  453. STDMETHODIMP_(void) CAutoFigure::RevertToSaved(void)
  454.     {
  455.     //Can't do this if we don't have a file
  456.     if ((TCHAR)0==m_pDoc->m_szFile[0])
  457.         return;
  458.  
  459.     /*
  460.      * Since we "open" a document by loading it and closing
  461.      * it, then we can just "re-open" it with Load again.
  462.      */
  463.     m_pDoc->Load(FALSE, m_pDoc->m_szFile);
  464.  
  465.     /*
  466.      * Load set the document as dirt when loading from a file
  467.      * in this manner (the behavior of Import).  But this actually
  468.      * makes the file clean, so we change the dirty flag here.
  469.      */
  470.     m_pDoc->FDirtySet(FALSE);
  471.     return;
  472.     }
  473.  
  474.  
  475.  
  476. /*
  477.  * CAutoFigure::Save
  478.  * Method
  479.  *
  480.  * Saves the document to a known file if one exists.
  481.  */
  482.  
  483. STDMETHODIMP_(void) CAutoFigure::Save(void)
  484.     {
  485.     if ((TCHAR)0==m_pDoc->m_szFile[0])
  486.         return;
  487.  
  488.     m_pDoc->Save(0, (LPTSTR)NULL);
  489.     return;
  490.     }
  491.  
  492.  
  493.  
  494. /*
  495.  * CAutoFigure::SaveAs
  496.  * Method
  497.  *
  498.  * Saves the current figure to a new file.
  499.  */
  500.  
  501. STDMETHODIMP_(void) CAutoFigure::SaveAs(BSTR bstrPath)
  502.     {
  503.     if (NULL==bstrPath)
  504.         return;
  505.  
  506.     //This also renames the document
  507.    #ifdef WIN32ANSI
  508.     char        szTemp[512];
  509.  
  510.     WideCharToMultiByte(CP_ACP, 0, bstrPath, -1, szTemp
  511.         , 512, NULL, NULL);
  512.     m_pDoc->Save(0, szTemp);
  513.    #else
  514.     m_pDoc->Save(0, bstrPath);
  515.    #endif
  516.     return;
  517.     }
  518.  
  519.  
  520.  
  521. /*
  522.  * CAutoFigure::Import
  523.  * Method
  524.  *
  525.  * Initializes the figure from the contents of a file
  526.  */
  527.  
  528. STDMETHODIMP_(void) CAutoFigure::Import(BSTR bstrImportPath)
  529.     {
  530.     if (NULL==bstrImportPath)
  531.         return;
  532.  
  533.     /*
  534.      * Like we have for RevertToSaved, we can just "open"
  535.      * this file and the new information becomes current.
  536.      */
  537.    #ifdef WIN32ANSI
  538.     char        szTemp[512];
  539.  
  540.     WideCharToMultiByte(CP_ACP, 0, bstrImportPath, -1
  541.         , szTemp, 512, NULL, NULL);
  542.     m_pDoc->Load(FALSE, szTemp);
  543.    #else
  544.     m_pDoc->Load(FALSE, bstrImportPath);
  545.    #endif
  546.     return;
  547.     }
  548.  
  549.  
  550.  
  551. /*
  552.  * CAutoFigure::Copy
  553.  * CAutoFigure::Cut
  554.  * CAutoFigure::Paste
  555.  * Methods
  556.  *
  557.  * Perform clipboard operations
  558.  */
  559.  
  560. STDMETHODIMP_(void) CAutoFigure::Copy(void)
  561.     {
  562.     m_pDoc->Clip(m_pDoc->m_pFR->Window(), FALSE);
  563.     return;
  564.     }
  565.  
  566. STDMETHODIMP_(void) CAutoFigure::Cut(void)
  567.     {
  568.     m_pDoc->Clip(m_pDoc->m_pFR->Window(), TRUE);
  569.     return;
  570.     }
  571.  
  572. STDMETHODIMP_(void) CAutoFigure::Paste(void)
  573.     {
  574.     if (m_pDoc->FQueryPaste())
  575.         m_pDoc->Paste(m_pDoc->m_pFR->Window());
  576.  
  577.     return;
  578.     }
  579.  
  580.  
  581.  
  582.  
  583. /*
  584.  * CAutoFigure::AddPoint
  585.  * Method
  586.  *
  587.  * Adds a new point, expressed on a 0-32767 scale, to the figure.
  588.  */
  589.  
  590. STDMETHODIMP_(VARIANT_BOOL) CAutoFigure::AddPoint(short x, short y)
  591.     {
  592.     RECT        rc;
  593.     POINTS      pt;
  594.     HWND        hWndPL;
  595.  
  596.     /*
  597.      * This is the only semi-tricky method to implement here because
  598.      * normally this processing is done inside the Polyline's
  599.      * WM_LBUTTONDOWN.  In order to get the same behavior, we'll
  600.      * just send the same message to it.  However, we have to
  601.      * convert from a 0-32767 range to a window coordinate range
  602.      * which is nicely handled by CPolyline::PointScale (the only
  603.      * small modification to CPolyline I had to make was to make
  604.      * PointScale public instead of private).
  605.      *
  606.      * This is a non-invasive way to add Automation support.
  607.      * The invasive way would require a change to the CPolyline
  608.      * class and it's window procedure so both this function
  609.      * and the WM_LBUTTONDOWN handling called the same function
  610.      * with 0-32767 scaled points.
  611.      */
  612.  
  613.     //See if we can add any more
  614.     if (CPOLYLINEPOINTS==get_NumberOfPoints())
  615.         return FALSE;
  616.  
  617.     hWndPL=m_pDoc->m_pPL->Window();
  618.     GetClientRect(hWndPL, &rc);
  619.     SETPOINT(pt, x, y);
  620.     m_pDoc->m_pPL->PointScale(&rc, &pt, TRUE);
  621.     SendMessage(hWndPL, WM_LBUTTONDOWN, 0, MAKELPARAM(pt.x, pt.y));
  622.     return TRUE;
  623.     }
  624.  
  625.  
  626.  
  627. /*
  628.  * CAutoFigure::RemovePoint
  629.  * Method
  630.  *
  631.  * Removes the last point added to a figure
  632.  */
  633.  
  634. STDMETHODIMP_(void) CAutoFigure::RemovePoint(void)
  635.     {
  636.     m_pDoc->Undo();
  637.     return;
  638.     }
  639.  
  640.  
  641.  
  642.  
  643. /*
  644.  * CAutoFigure::MoveSize
  645.  *
  646.  * Purpose:
  647.  *  Helper function for the Left, Top, Width, and Height properties
  648.  *  that centralizes calls to GetWindowRect and SetWindowPos,
  649.  *  reducing overall code somewhat.
  650.  *
  651.  * Parameters:
  652.  *  iAction         MOVESIZEACTION enum value to indicate what
  653.  *                  type of moving/sizing to perform
  654.  *  x, y            long position coordinates;  x is only meaningful
  655.  *                  with MOVESIZEACTION_LEFT, y only with _TOP
  656.  *  cx, cy          long extents;  cx is only meaningful
  657.  *                  with MOVESIZEACTION_WIDTH, cy only with _HEIGHT
  658.  *
  659.  * Return Value:
  660.  *  long            The current x, y, cx, or cy value depending on
  661.  *                  iAction being _GETLEFT, _GETTOP, _GETWIDTH, or
  662.  *                  _GETHEIGHT.
  663.  */
  664.  
  665. long CAutoFigure::MoveSize(MOVESIZEACTION iAction, long x, long y
  666.     , long cx, long cy)
  667.     {
  668.     RECT        rc;
  669.     POINT       pt1, pt2;
  670.     long        x1, y1, cx1, cy1;
  671.     UINT        uFlags;
  672.  
  673.     GetWindowRect(m_pDoc->Window(), &rc);
  674.     SETPOINT(pt1, rc.left, rc.top);
  675.     ScreenToClient(GetParent(m_pDoc->Window()), &pt1);
  676.     SETPOINT(pt2, rc.right, rc.bottom);
  677.     ScreenToClient(GetParent(m_pDoc->Window()), &pt2);
  678.  
  679.     //By default we'll do nothing
  680.     x1=pt1.x;
  681.     y1=pt1.y;
  682.     cx1=pt2.x-pt1.x;
  683.     cy1=pt2.y-pt1.y;
  684.     uFlags=0L;
  685.  
  686.     switch (iAction)
  687.         {
  688.         /*
  689.          * Each individual property modifies the appropriate
  690.          * variable x1, y1, cx1, cy1, as well as uFlags to set
  691.          * up SetWindowPos call.
  692.          */
  693.         case MOVESIZEACTION_LEFT:
  694.             x1=x;
  695.             uFlags=SWP_NOSIZE;
  696.             break;
  697.  
  698.         case MOVESIZEACTION_TOP:
  699.             y1=y;
  700.             uFlags=SWP_NOSIZE;
  701.             break;
  702.  
  703.         case MOVESIZEACTION_WIDTH:
  704.             cx1=cx;
  705.             uFlags=SWP_NOMOVE;
  706.             break;
  707.  
  708.         case MOVESIZEACTION_HEIGHT:
  709.             cy1=cy;
  710.             uFlags=SWP_NOMOVE;
  711.             break;
  712.  
  713.  
  714.         case MOVESIZEACTION_GETLEFT:
  715.             return x1;
  716.  
  717.         case MOVESIZEACTION_GETTOP:
  718.             return y1;
  719.  
  720.         case MOVESIZEACTION_GETWIDTH:
  721.             return cx1;
  722.  
  723.         case MOVESIZEACTION_GETHEIGHT:
  724.             return cy1;
  725.  
  726.         default:
  727.             return 0;
  728.         }
  729.  
  730.     //We only get here on propety changes
  731.     SetWindowPos(m_pDoc->Window(), NULL
  732.         , (int)x1, (int)y1, (int)cx1, (int)cy1
  733.         , SWP_NOZORDER | SWP_NOACTIVATE | uFlags);
  734.  
  735.     //Irrelevant for property changes.
  736.     return 0;
  737.     }
  738.