home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / mac / SiteBldr / AMOVIE / SDK / _SETUP / COMMON.Z / ezprop.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-17  |  4.2 KB  |  191 lines

  1. //==========================================================================;
  2. //
  3. //  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  4. //  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  5. //  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  6. //  PURPOSE.
  7. //
  8. //  Copyright (c) 1992 - 1996  Microsoft Corporation.  All Rights Reserved.
  9. //
  10. //--------------------------------------------------------------------------;
  11. //
  12. //contprop.cpp
  13. //
  14.  
  15. #include <windows.h>
  16. #include <windowsx.h>
  17. #include <streams.h>
  18. #include <commctrl.h>
  19. #include <olectl.h>
  20. #include <memory.h>
  21. #include <stdlib.h>
  22. #include <stdio.h>
  23. #include <tchar.h>
  24.  
  25. #include "resource.h"
  26. #include "EZuids.h"
  27. #include "iEZ.h"
  28. #include "EZrgb24.h"
  29. #include "EZprop.h"
  30.  
  31. // *
  32. // * CEZrgb24Properties
  33. // *
  34.  
  35.  
  36. //
  37. // CreateInstance
  38. //
  39. // The only allowed way to create Bouncing ball's!
  40. CUnknown *CEZrgb24Properties::CreateInstance(LPUNKNOWN lpunk, HRESULT *phr) {
  41.  
  42.     CUnknown *punk = new CEZrgb24Properties(lpunk, phr);
  43.     if (punk == NULL) {
  44.     *phr = E_OUTOFMEMORY;
  45.     }
  46.  
  47.     return punk;
  48. }
  49.  
  50.  
  51. //
  52. // CEZrgb24Properties::Constructor
  53. //
  54. CEZrgb24Properties::CEZrgb24Properties(LPUNKNOWN pUnk, HRESULT *phr)
  55.     : CBasePropertyPage(NAME("EZrgb24 Property Page"),pUnk,phr,
  56.         IDD_EZrgb24PROP, IDS_TITLE)
  57.     , m_pIPEffect(NULL)
  58.     , m_bIsInitialized(FALSE)
  59. {
  60. }
  61.  
  62. // Handles the messages for our property window
  63.  
  64. BOOL CEZrgb24Properties::OnReceiveMessage(HWND hwnd,
  65.                                         UINT uMsg,
  66.                                         WPARAM wParam,
  67.                                         LPARAM lParam)
  68. {
  69.     switch (uMsg)
  70.     {
  71.  
  72.         case WM_COMMAND:
  73.         {
  74.             if (m_bIsInitialized)
  75.             {
  76.                 m_bDirty = TRUE;
  77.                 if (m_pPageSite)
  78.                 {
  79.                     m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
  80.                 }
  81.             }
  82.             return (LRESULT) 1;
  83.         }
  84.  
  85.     }
  86.     return CBasePropertyPage::OnReceiveMessage(hwnd,uMsg,wParam,lParam);
  87. }
  88.  
  89.  
  90. HRESULT CEZrgb24Properties::OnConnect(IUnknown *pUnknown)
  91. {
  92.  
  93.     ASSERT(m_pIPEffect == NULL);
  94.  
  95.     HRESULT hr = pUnknown->QueryInterface(IID_IIPEffect, (void **) &m_pIPEffect);
  96.     if (FAILED(hr))
  97.     {
  98.         return E_NOINTERFACE;
  99.     }
  100.  
  101.     ASSERT(m_pIPEffect);
  102.  
  103.     // Get the initial image FX property
  104.     m_pIPEffect->get_IPEffect(&m_effect, &m_start, &m_length);
  105.     m_bIsInitialized = FALSE ;
  106.     return NOERROR;
  107. }
  108.  
  109. HRESULT CEZrgb24Properties::OnDisconnect()
  110. {
  111.     // Release of Interface after setting the appropriate old effect value
  112.  
  113.     if (m_pIPEffect == NULL)
  114.     {
  115.         return E_UNEXPECTED;
  116.     }
  117.  
  118.     m_pIPEffect->Release();
  119.     m_pIPEffect = NULL;
  120.     return NOERROR;
  121. }
  122.  
  123.  
  124. // We are being activated
  125.  
  126. HRESULT CEZrgb24Properties::OnActivate()
  127. {
  128.     TCHAR   sz[60];
  129.  
  130.     _stprintf(sz, TEXT("%f"), m_length);
  131.     Edit_SetText(GetDlgItem(m_Dlg, IDC_LENGTH), sz);
  132.     _stprintf(sz, TEXT("%f"), m_start);
  133.     Edit_SetText(GetDlgItem(m_Dlg, IDC_START), sz);
  134.  
  135.     CheckRadioButton(m_Dlg, IDC_EMBOSS, IDC_NONE, m_effect);
  136.     m_bIsInitialized = TRUE;
  137.     return NOERROR;
  138. }
  139.  
  140. // We are being deactivated
  141.  
  142. HRESULT CEZrgb24Properties::OnDeactivate(void)
  143. {
  144.     ASSERT(m_pIPEffect);
  145.     m_pIPEffect->get_IPEffect(&m_effect, &m_start, &m_length);
  146.     return NOERROR;
  147. }
  148.  
  149.  
  150. //
  151. // Apply
  152. //
  153. // Changes made should be kept.
  154. //
  155.  
  156. // Apply any changes so far made
  157.  
  158. HRESULT CEZrgb24Properties::OnApplyChanges()
  159. {
  160.  
  161.     ASSERT(m_pIPEffect);
  162.  
  163.     TCHAR sz[STR_MAX_LENGTH];
  164.     REFTIME tmp1, tmp2 ;
  165.  
  166.  
  167.     // Get the start and effect times
  168.  
  169.     Edit_GetText(GetDlgItem(m_Dlg, IDC_LENGTH), sz, STR_MAX_LENGTH);
  170.     tmp2 = COARefTime(atof(sz));
  171.  
  172.     Edit_GetText(GetDlgItem(m_Dlg, IDC_START), sz, STR_MAX_LENGTH);
  173.     tmp1 = COARefTime(atof(sz));
  174.  
  175.     // validate.
  176.     if (tmp1 >= 0 && tmp2 >= 0)
  177.     {
  178.         m_start = tmp1 ;
  179.         m_length = tmp2 ;
  180.     }
  181.  
  182.     for (int i = IDC_EMBOSS; i <= IDC_NONE; i++)
  183.         if (IsDlgButtonChecked(m_Dlg, i))
  184.         {
  185.              m_pIPEffect->put_IPEffect(i, m_start, m_length);
  186.             m_effect = i ;
  187.         }
  188.     return(NOERROR);
  189.  
  190. }
  191.