ScaleProperties.h

Go to the documentation of this file.
00001 
00034 #pragma once
00035 
00036 #include <DirectShow/FilterPropertiesBase.h>
00037 
00038 #include <climits>
00039 #include "resource.h"
00040 
00041 #define BUFFER_SIZE 256
00042 
00043 class ScaleProperties : public FilterPropertiesBase
00044 {
00045 public:
00046 
00047         static CUnknown * WINAPI CreateInstance(LPUNKNOWN pUnk, HRESULT *pHr) 
00048         {
00049                 ScaleProperties *pNewObject = new ScaleProperties(pUnk);
00050                 if (pNewObject == NULL) 
00051                 {
00052                         *pHr = E_OUTOFMEMORY;
00053                 }
00054                 return pNewObject;
00055         }
00056 
00057         ScaleProperties::ScaleProperties(IUnknown *pUnk) : 
00058         FilterPropertiesBase(NAME("Scale Properties"), pUnk, IDD_SCALE_DIALOG, IDS_SCALE_CAPTION)
00059         {;}
00060 
00061         BOOL OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00062         {
00063                 /*switch (uMsg)
00064                 {
00065                 case WM_NOTIFY:
00066                         short q = UDN_DELTAPOS;
00067 
00068                         unsigned short s = LOWORD(lParam);
00069                         short s1 = LOWORD(lParam);
00070                         short s2 = HIWORD(lParam);
00071                         if (s == UDN_DELTAPOS)
00072                         {
00073                                 SetDirty();
00074                                 return (LRESULT) 1;
00075                         }
00076                         if (lParam == UDN_DELTAPOS)
00077                         {
00078                                 SetDirty();
00079                                 return (LRESULT) 1;
00080                         }
00081 
00082                         break;
00083                 }*/
00084                 // Let the parent class handle the message.
00085                 return FilterPropertiesBase::OnReceiveMessage(hwnd,uMsg,wParam,lParam);
00086         }
00087 
00088         HRESULT ReadSettings()
00089         {
00090                 short lower = 0;
00091                 short upper = SHRT_MAX;
00092 
00093                 // Init UI
00094                 long lResult = SendMessage(                     // returns LRESULT in lResult
00095                         GetDlgItem(m_Dlg, IDC_SPIN1),   // handle to destination control
00096                         (UINT) UDM_SETRANGE,                    // message ID
00097                         (WPARAM) 0,                                             // = 0; not used, must be zero
00098                         (LPARAM) MAKELONG ( upper, lower)      // = (LPARAM) MAKELONG ((short) nUpper, (short) nLower)
00099                         );
00100                 lResult = SendMessage(                  // returns LRESULT in lResult
00101                         GetDlgItem(m_Dlg, IDC_SPIN2),   // handle to destination control
00102                         (UINT) UDM_SETRANGE,                    // message ID
00103                         (WPARAM) 0,                                             // = 0; not used, must be zero
00104                         (LPARAM) MAKELONG ( upper, lower)      // = (LPARAM) MAKELONG ((short) nUpper, (short) nLower)
00105                         );
00106 
00107                 int nLength = 0;
00108                 char szBuffer[BUFFER_SIZE];
00109                 HRESULT hr = m_pSettingsInterface->GetParameter(TARGET_HEIGHT, sizeof(szBuffer), szBuffer, &nLength);
00110                 if (SUCCEEDED(hr))
00111                 {
00112                         SetDlgItemText(m_Dlg, IDC_EDIT_TARGET_HEIGHT, szBuffer);
00113                         m_targetHeight = atoi(szBuffer);
00114                 }
00115                 else
00116                 {
00117                         return E_FAIL;
00118                 }
00119                 hr = m_pSettingsInterface->GetParameter(TARGET_WIDTH, sizeof(szBuffer), szBuffer, &nLength);
00120                 if (SUCCEEDED(hr))
00121                 {
00122                         SetDlgItemText(m_Dlg, IDC_EDIT_TARGET_WIDTH, szBuffer);
00123                         m_targetWidth = atoi(szBuffer);
00124                 }
00125                 else
00126                 {
00127                         return E_FAIL;
00128                 }
00129                 return hr;
00130         }
00131  
00132         HRESULT OnApplyChanges(void)
00133         {
00134                 int nLength = 0;
00135                 char szBuffer[BUFFER_SIZE];
00136                 nLength = GetDlgItemText(m_Dlg, IDC_EDIT_TARGET_WIDTH, szBuffer, BUFFER_SIZE);
00137                 m_targetWidth = atoi(szBuffer);
00138                 m_pSettingsInterface->SetParameter(TARGET_WIDTH, szBuffer);
00139                 nLength = GetDlgItemText(m_Dlg, IDC_EDIT_TARGET_HEIGHT, szBuffer, BUFFER_SIZE);
00140                 m_targetHeight = atoi(szBuffer);
00141                 m_pSettingsInterface->SetParameter(TARGET_HEIGHT, szBuffer);
00142                 return S_OK;
00143         } 
00144 
00145 private:
00146 
00147         unsigned m_targetWidth;
00148         unsigned m_targetHeight;
00149 };
00150 

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