www.pudn.com > VirtualVCR-src-v2.6.9.zip > HistogramProp.cpp
/*
Virtual VCR
Copyright (C) 2002 Shaun Faulds
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Acknowledgments:
This application and associated filters are based on the examples
from the Microsoft DirectX DirectShow SDK.
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "resource.h"
#include "HistogramUIDs.h"
#include "iHistogram.h"
#include "Histogram.h"
#include "HistogramProp.h"
#include "Histogram.version"
//
// CreateInstance
//
// Used by the DirectShow base classes to create instances
//
CUnknown *CHistogramProperties::CreateInstance(LPUNKNOWN lpunk, HRESULT *phr)
{
CUnknown *punk = new CHistogramProperties(lpunk, phr);
if (punk == NULL)
{
*phr = E_OUTOFMEMORY;
}
return punk;
} // CreateInstance
//
// Constructor
//
CHistogramProperties::CHistogramProperties(LPUNKNOWN pUnk, HRESULT *phr) :
CBasePropertyPage(NAME("Colour Histogram Property Page"),
pUnk,IDD_HistogramPropDlg,IDS_TITLE),
m_pIPEffect(NULL)
{
} // (Constructor)
//
// OnReceiveMessage
//
// Handles the messages for our property window
//
BOOL CHistogramProperties::OnReceiveMessage(HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
{
ASSERT(m_pIPEffect);
char buffer[32];
sprintf(buffer, "Version: %s", MAIN_VERSION);
SetDlgItemText( hwnd, IDC_VERSION, buffer );
BOOL data = false;
m_pIPEffect->get_Channel(&data);
int mask = 0;
m_pIPEffect->get_RGBmask(&mask);
if(data)
CheckDlgButton(hwnd, IDC_RGBChannels, BST_CHECKED);
else
CheckDlgButton(hwnd, IDC_Luminosity, BST_CHECKED);
if((mask & 1) == 1)
CheckDlgButton(hwnd, IDC_CHECK_RED, BST_CHECKED);
if((mask & 2) == 2)
CheckDlgButton(hwnd, IDC_CHECK_GREEN, BST_CHECKED);
if((mask & 4) == 4)
CheckDlgButton(hwnd, IDC_CHECK_BLUE, BST_CHECKED);
return (LRESULT) 1;
}
case WM_COMMAND:
{
return (LRESULT) 1;
}
case WM_DESTROY:
{
BOOL Channels = false;
Channels = !!IsDlgButtonChecked(hwnd, IDC_RGBChannels);
m_pIPEffect->set_Channel(Channels);
int RGBmask = 0;
if(!!IsDlgButtonChecked(hwnd, IDC_CHECK_RED))
RGBmask = RGBmask | 1;
if(!!IsDlgButtonChecked(hwnd, IDC_CHECK_GREEN))
RGBmask = RGBmask | 2;
if(!!IsDlgButtonChecked(hwnd, IDC_CHECK_BLUE))
RGBmask = RGBmask | 4;
m_pIPEffect->set_RGBmask(RGBmask);
return (LRESULT) 1;
}
}
return CBasePropertyPage::OnReceiveMessage(hwnd,uMsg,wParam,lParam);
} // OnReceiveMessage
//
// OnConnect
//
// Called when we connect to a transform filter
//
HRESULT CHistogramProperties::OnConnect(IUnknown *pUnknown)
{
ASSERT(m_pIPEffect == NULL);
HRESULT hr = pUnknown->QueryInterface(IID_IHistogram, (void **) &m_pIPEffect);
if (FAILED(hr))
{
return E_NOINTERFACE;
}
ASSERT(m_pIPEffect);
return NOERROR;
} // OnConnect
//
// OnDisconnect
//
// Likewise called when we disconnect from a filter
//
HRESULT CHistogramProperties::OnDisconnect()
{
// Release of Interface after setting the appropriate old effect value
if (m_pIPEffect == NULL) {
return E_UNEXPECTED;
}
m_pIPEffect->Release();
m_pIPEffect = NULL;
return NOERROR;
} // OnDisconnect
//
// OnActivate
//
// We are being activated
//
HRESULT CHistogramProperties::OnActivate()
{
return NOERROR;
} // OnActivate
//
// OnDeactivate
//
// We are being deactivated
//
HRESULT CHistogramProperties::OnDeactivate(void)
{
return NOERROR;
} // OnDeactivate
//
// OnApplyChanges
//
// Apply any changes so far made
//
HRESULT CHistogramProperties::OnApplyChanges()
{
return NOERROR;
} // OnApplyChanges
void CHistogramProperties::GetControlValues()
{
ASSERT(m_pIPEffect);
}