📄 cvideokeyerprop.cpp
字号:
//
// CVideoKeyerProp.cpp
//
#include <streams.h>
// Eliminate two expected level 4 warnings from the Microsoft compiler.
// The class does not have an assignment or copy operator, and so cannot
// be passed by value. This is normal. This file compiles clean at the
// highest (most picky) warning level (-W4).
#pragma warning(disable: 4511 4512)
#include <windowsx.h>
#include <commctrl.h>
#include <olectl.h>
#include <memory.h>
#include <stdlib.h>
#include <stdio.h>
#include <tchar.h>
#include "Resource.h" // ids used in the dialog
#include "CVideoKeyerProp.h" // our own class
#include "VideoKeyerDefs.h"
//
// CreateInstance
//
// Override CClassFactory method.
// Set lpUnk to point to an IUnknown interface on a new NullIPProperties object
// Part of the COM object instantiation mechanism
//
CUnknown * WINAPI CVideoKeyerProp::CreateInstance(LPUNKNOWN lpunk, HRESULT *phr)
{
CUnknown *punk = new CVideoKeyerProp(lpunk, phr);
if (punk == NULL)
{
*phr = E_OUTOFMEMORY;
}
return punk;
}
// Constructs and initialises a object
CVideoKeyerProp::CVideoKeyerProp(LPUNKNOWN pUnk, HRESULT *phr) :
CBasePropertyPage(NAME("Video Keyer Property Page"),pUnk, IDD_FLT_PROP, IDS_INFO)
{
ASSERT(phr);
mIVideoKeyer = NULL;
} // CGraphInfoProp
// Override CBasePropertyPage method.
// Handles the messages for our property window
BOOL CVideoKeyerProp::OnReceiveMessage(HWND hwnd,
UINT uMsg,
WPARAM wParam,
LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
{
// Get windows' handles
mWndBackR = GetDlgItem(hwnd, IDC_EDIT_BACK_R);
mWndBackG = GetDlgItem(hwnd, IDC_EDIT_BACK_G);
mWndBackB = GetDlgItem(hwnd, IDC_EDIT_BACK_B);
mWndBackDrift = GetDlgItem(hwnd, IDC_EDIT_MAX_DRIFT);
break;
}
case WM_COMMAND:
{
if (HIWORD(wParam) == BN_CLICKED)
{
switch (LOWORD(wParam))
{
case IDC_RADIO_ALWAYS:
mDetectType = DETECT_ALWAYS;
ReflectControlStatus();
break;
case IDC_RADIO_ONCE:
mDetectType = DETECT_ONCE;
ReflectControlStatus();
break;
case IDC_RADIO_SPECIFY:
mDetectType = CUSTOMIZE;
ReflectControlStatus();
break;
}
}
SetDirty();
break;
}
}
return CBasePropertyPage::OnReceiveMessage(hwnd,uMsg,wParam,lParam);
} // OnReceiveMessage
// Override CBasePropertyPage method.
// Notification of which object this property page should display.
// We query the object for the IFltTrace interface.
HRESULT CVideoKeyerProp::OnConnect(IUnknown *pUnknown)
{
HRESULT hr = pUnknown->QueryInterface(IID_IVideoKeyer, (void **) &mIVideoKeyer);
if (FAILED(hr))
{
return E_NOINTERFACE;
}
ASSERT(mIVideoKeyer);
return NOERROR;
} // OnConnect
// Override CBasePropertyPage method.
// Release the private interface, release the upstream pin.
HRESULT CVideoKeyerProp::OnDisconnect()
{
// Release of Interface
if (mIVideoKeyer == NULL)
return E_UNEXPECTED;
mIVideoKeyer->Release();
mIVideoKeyer = NULL;
return NOERROR;
} // OnDisconnect
// We are being activated
HRESULT CVideoKeyerProp::OnActivate()
{
ReflectDetectType();
ReflectBackColor();
ReflectBackDrift();
ReflectControlStatus();
return NOERROR;
} // Activate
// Changes made should be kept
HRESULT CVideoKeyerProp::OnApplyChanges()
{
EnterDetectType();
EnterBackDrift();
if (mDetectType == CUSTOMIZE)
{
EnterBackColor();
}
return NOERROR;
} // OnApplyChanges
//
// Sets m_hrDirtyFlag and notifies the property page site of the change
void CVideoKeyerProp::SetDirty()
{
m_bDirty = TRUE;
if (m_pPageSite)
{
m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
}
} // SetDirty
void CVideoKeyerProp::ReflectDetectType(void)
{
mIVideoKeyer->get_BackgroundDetectType(&mDetectType);
if (mDetectType == DETECT_ONCE)
{
CheckRadioButton(m_hwnd, IDC_RADIO_ALWAYS, IDC_RADIO_SPECIFY, IDC_RADIO_ONCE);
}
else if (mDetectType == DETECT_ALWAYS)
{
CheckRadioButton(m_hwnd, IDC_RADIO_ALWAYS, IDC_RADIO_SPECIFY, IDC_RADIO_ALWAYS);
}
else
{
CheckRadioButton(m_hwnd, IDC_RADIO_ALWAYS, IDC_RADIO_SPECIFY, IDC_RADIO_SPECIFY);
}
}
void CVideoKeyerProp::ReflectBackColor(void)
{
BYTE r, g, b;
char szTemp[100];
mIVideoKeyer->get_BackgroundColor(&r, &g, &b);
sprintf(szTemp, "%d", r);
SetWindowText(mWndBackR, szTemp);
sprintf(szTemp, "%d", g);
SetWindowText(mWndBackG, szTemp);
sprintf(szTemp, "%d", b);
SetWindowText(mWndBackB, szTemp);
}
void CVideoKeyerProp::ReflectBackDrift(void)
{
BYTE temp = 0;
char szTemp[100];
mIVideoKeyer->get_BackgroundDrift(&temp);
sprintf(szTemp, "%d", temp);
SetWindowText(mWndBackDrift, szTemp);
}
void CVideoKeyerProp::ReflectControlStatus(void)
{
int nChecked = IsDlgButtonChecked(m_hwnd, IDC_RADIO_SPECIFY);
EnableWindow(mWndBackR, nChecked);
EnableWindow(mWndBackG, nChecked);
EnableWindow(mWndBackB, nChecked);
}
void CVideoKeyerProp::EnterDetectType(void)
{
mIVideoKeyer->put_BackgroundDetectType(mDetectType);
}
void CVideoKeyerProp::EnterBackColor(void)
{
char r[20], g[20], b[20];
GetWindowText(mWndBackR, r, 20);
GetWindowText(mWndBackG, g, 20);
GetWindowText(mWndBackB, b, 20);
mIVideoKeyer->put_BackgroundColor(atoi(r), atoi(g), atoi(b));
}
void CVideoKeyerProp::EnterBackDrift(void)
{
char szTemp[100];
GetWindowText(mWndBackDrift, szTemp, 100);
mIVideoKeyer->put_BackgroundDrift(atoi(szTemp));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -