CropProperties.h

Go to the documentation of this file.
00001 
00034 #pragma once
00035 
00036 #include <DirectShow/FilterPropertiesBase.h>
00037 
00038 #include "resource.h"
00039 
00040 #define BUFFER_SIZE 256
00041 
00042 class CropProperties : public FilterPropertiesBase
00043 {
00044 public:
00045 
00046         static CUnknown * WINAPI CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr) 
00047         {
00048                 CropProperties *pNewObject = new CropProperties(pUnk);
00049                 if (pNewObject == NULL) 
00050                 {
00051                         *pHr = E_OUTOFMEMORY;
00052                 }
00053                 return pNewObject;
00054         }
00055 
00056         CropProperties::CropProperties(IUnknown *pUnk) : 
00057                 FilterPropertiesBase(NAME("Crop Properties"), pUnk, IDD_CROP_DIALOG, IDS_CROP_CAPTION)
00058         {;}
00059 
00060         HRESULT ReadSettings()
00061         {
00062                 short lower = 0;
00063                 short upper = SHRT_MAX;
00064 
00065                 // Init UI
00066                 long lResult = SendMessage(                     // returns LRESULT in lResult
00067                         GetDlgItem(m_Dlg, IDC_SPIN1),   // handle to destination control
00068                         (UINT) UDM_SETRANGE,                    // message ID
00069                         (WPARAM) 0,                                             // = 0; not used, must be zero
00070                         (LPARAM) MAKELONG ( upper, lower)      // = (LPARAM) MAKELONG ((short) nUpper, (short) nLower)
00071                         );
00072                 lResult = SendMessage(                  // returns LRESULT in lResult
00073                         GetDlgItem(m_Dlg, IDC_SPIN2),   // handle to destination control
00074                         (UINT) UDM_SETRANGE,                    // message ID
00075                         (WPARAM) 0,                                             // = 0; not used, must be zero
00076                         (LPARAM) MAKELONG ( upper, lower)      // = (LPARAM) MAKELONG ((short) nUpper, (short) nLower)
00077                         );
00078                 lResult = SendMessage(                  // returns LRESULT in lResult
00079                         GetDlgItem(m_Dlg, IDC_SPIN3),   // handle to destination control
00080                         (UINT) UDM_SETRANGE,                    // message ID
00081                         (WPARAM) 0,                                             // = 0; not used, must be zero
00082                         (LPARAM) MAKELONG ( upper, lower)      // = (LPARAM) MAKELONG ((short) nUpper, (short) nLower)
00083                         );
00084                 lResult = SendMessage(                  // returns LRESULT in lResult
00085                         GetDlgItem(m_Dlg, IDC_SPIN4),   // handle to destination control
00086                         (UINT) UDM_SETRANGE,                    // message ID
00087                         (WPARAM) 0,                                             // = 0; not used, must be zero
00088                         (LPARAM) MAKELONG ( upper, lower)      // = (LPARAM) MAKELONG ((short) nUpper, (short) nLower)
00089                         );
00090 
00091 
00092                 int nLength = 0;
00093                 char szBuffer[BUFFER_SIZE];
00094                 HRESULT hr = m_pSettingsInterface->GetParameter(TOP_CROP, sizeof(szBuffer), szBuffer, &nLength);
00095                 if (SUCCEEDED(hr))
00096                 {
00097                         SetDlgItemText(m_Dlg, IDC_EDIT_TOP, szBuffer);
00098                         m_topCrop = atoi(szBuffer);
00099                 }
00100                 else
00101                 {
00102                         return E_FAIL;
00103                 }
00104                 hr = m_pSettingsInterface->GetParameter(BOTTOM_CROP, sizeof(szBuffer), szBuffer, &nLength);
00105                 if (SUCCEEDED(hr))
00106                 {
00107                         SetDlgItemText(m_Dlg, IDC_EDIT_BOTTOM, szBuffer);
00108                         m_bottomCrop = atoi(szBuffer);
00109                 }
00110                 else
00111                 {
00112                         return E_FAIL;
00113                 }
00114                 hr = m_pSettingsInterface->GetParameter(LEFT_CROP, sizeof(szBuffer), szBuffer, &nLength);
00115                 if (SUCCEEDED(hr))
00116                 {
00117                         SetDlgItemText(m_Dlg, IDC_EDIT_LEFT, szBuffer);
00118                         m_leftCrop = atoi(szBuffer);
00119                 }
00120                 else
00121                 {
00122                         return E_FAIL;
00123                 }
00124                 hr = m_pSettingsInterface->GetParameter(RIGHT_CROP, sizeof(szBuffer), szBuffer, &nLength);
00125                 if (SUCCEEDED(hr))
00126                 {
00127                         SetDlgItemText(m_Dlg, IDC_EDIT_RIGHT, szBuffer);
00128                         m_rightCrop = atoi(szBuffer);
00129                 }
00130                 else
00131                 {
00132                         return E_FAIL;
00133                 }
00134                 return hr;
00135         }
00136 
00137         HRESULT OnApplyChanges(void)
00138         {
00139                 int nLength = 0;
00140                 char szBuffer[BUFFER_SIZE];
00141                 nLength = GetDlgItemText(m_Dlg, IDC_EDIT_TOP, szBuffer, BUFFER_SIZE);
00142                 m_topCrop = atoi(szBuffer);
00143                 m_pSettingsInterface->SetParameter(TOP_CROP, szBuffer);
00144                 nLength = GetDlgItemText(m_Dlg, IDC_EDIT_BOTTOM, szBuffer, BUFFER_SIZE);
00145                 m_bottomCrop = atoi(szBuffer);
00146                 m_pSettingsInterface->SetParameter(BOTTOM_CROP, szBuffer);
00147                 nLength = GetDlgItemText(m_Dlg, IDC_EDIT_LEFT, szBuffer, BUFFER_SIZE);
00148                 m_leftCrop = atoi(szBuffer);
00149                 m_pSettingsInterface->SetParameter(LEFT_CROP, szBuffer);
00150                 nLength = GetDlgItemText(m_Dlg, IDC_EDIT_RIGHT, szBuffer, BUFFER_SIZE);
00151                 m_rightCrop = atoi(szBuffer);
00152                 m_pSettingsInterface->SetParameter(RIGHT_CROP, szBuffer);
00153                 return S_OK;
00154         } 
00155 
00156 private:
00157 
00158         unsigned m_topCrop;
00159         unsigned m_bottomCrop;
00160         unsigned m_leftCrop;
00161         unsigned m_rightCrop;
00162 };
00163 

Generated on Fri Mar 13 14:12:38 2009 for RTVC by  doxygen 1.5.3