📄 pushsourceprop.cpp
字号:
// PushSourceProp.cpp: implementation of the CiFlyNetSourceProp class.
//////////////////////////////////////////////////////////////////////
#include "Resource.h"
#include "PushSourceProp.h"
//////////////////////////////////////////////////////////////////////
// Constructs and initialises a object
CiFlyNetSourceProp::CiFlyNetSourceProp(LPUNKNOWN pUnk, HRESULT *phr):
CBasePropertyPage(NAME("Net Params Page"), pUnk, IDD_FILTER_PROP, IDS_INFO)
, m_pINetParams(NULL)
{
ASSERT(phr);
}
HRESULT CiFlyNetSourceProp::OnConnect(IUnknown *pUnknown)
{
HRESULT hr=pUnknown->QueryInterface(IID_IiFlyNetParams, (void**)&m_pINetParams);
if(FAILED(hr)){
return E_NOINTERFACE;
}
ASSERT(m_pINetParams);
return NOERROR;
}
HRESULT CiFlyNetSourceProp::OnDisconnect()
{
if(m_pINetParams){
m_pINetParams->Release();
m_pINetParams=NULL;
}
return NOERROR;
}
HRESULT CiFlyNetSourceProp::OnActivate()
{
UINT BufLen=0;
HRESULT hr=m_pINetParams->get_RtpPort(NULL, &BufLen);
if(hr==S_OK && BufLen>0){
TCHAR* pch=new TCHAR[BufLen];
if(pch){
hr=m_pINetParams->get_RtpPort(pch, &BufLen);
if(hr==S_OK){
HWND hWnd=GetDlgItem(m_hwnd, IDC_RtpPort);
if(hWnd!=0){
SetWindowText(hWnd, pch);
}
}
delete[] pch;
}
}
hr=m_pINetParams->get_VideoHeight(&BufLen);
if(hr==S_OK){
TCHAR* pch=new TCHAR[21];
if(pch){
#ifdef UNICODE
_ltow
#else
ltoa
#endif
(BufLen, pch, 10);
HWND hWnd=GetDlgItem(m_hwnd, IDC_VideoH);
if(hWnd!=0){
SetWindowText(hWnd, pch);
}
delete[] pch;
}
}
hr=m_pINetParams->get_VideoWidth(&BufLen);
if(hr==S_OK){
TCHAR* pch=new TCHAR[21];
if(pch){
#ifdef UNICODE
_ltow
#else
ltoa
#endif
(BufLen, pch, 10);
HWND hWnd=GetDlgItem(m_hwnd, IDC_VideoW);
if(hWnd!=0){
SetWindowText(hWnd, pch);
}
delete[] pch;
}
}
return NOERROR;
}
HRESULT CiFlyNetSourceProp::OnApplyChanges()
{
//设置Rtp端口:
HWND hWnd=GetDlgItem(m_hwnd, IDC_RtpPort);
int iBufLen=GetWindowTextLength(hWnd)+1;
if(iBufLen<2)
return E_FAIL;
TCHAR* psVal=new TCHAR[iBufLen];
if(!psVal)
return E_OUTOFMEMORY;
if(GetWindowText(hWnd, psVal, iBufLen)<=0){
delete[] psVal;
return E_FAIL;
}
HRESULT hr=m_pINetParams->put_RtpPort(psVal, iBufLen-1);
delete[] psVal;
if(hr==S_OK){
EnableWindow(hWnd, FALSE);
}
//设置图像高、宽:
hWnd=GetDlgItem(m_hwnd, IDC_VideoH);
iBufLen=GetWindowTextLength(hWnd)+1;
if(iBufLen<2)
return E_FAIL;
psVal=new TCHAR[iBufLen];
if(!psVal)
return E_OUTOFMEMORY;
if(GetWindowText(hWnd, psVal, iBufLen)<=0){
delete[] psVal;
return E_FAIL;
}
long lVal=
#ifdef UNICODE
_wtol
#else
atol
#endif
(psVal);
if(lVal>0){
hr=m_pINetParams->put_VideoHeight((UINT)lVal);
}else{
hr=E_FAIL;
}
delete[] psVal;
if(hr==S_OK){
EnableWindow(hWnd, FALSE);
}
hWnd=GetDlgItem(m_hwnd, IDC_VideoW);
iBufLen=GetWindowTextLength(hWnd)+1;
if(iBufLen<2)
return E_FAIL;
psVal=new TCHAR[iBufLen];
if(!psVal)
return E_OUTOFMEMORY;
if(GetWindowText(hWnd, psVal, iBufLen)<=0){
delete[] psVal;
return E_FAIL;
}
lVal=
#ifdef UNICODE
_wtol
#else
atol
#endif
(psVal);
if(lVal>0){
hr=m_pINetParams->put_VideoWidth((UINT)lVal);
}else{
hr=E_FAIL;
}
delete[] psVal;
if(hr==S_OK){
EnableWindow(hWnd, FALSE);
}
hWnd=GetDlgItem(m_hwnd, IDC_InputBtn);
if(hWnd)
EnableWindow(hWnd, TRUE);
return hr;
}
void CiFlyNetSourceProp::SetDirty()
{
m_bDirty = TRUE;
if(m_pPageSite)
{
m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
}
}
BOOL CiFlyNetSourceProp::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
HWND hEdit1=GetDlgItem(m_hwnd, IDC_RtpPort);
HWND hEdit2=GetDlgItem(m_hwnd, IDC_VideoH);
HWND hEdit3=GetDlgItem(m_hwnd, IDC_VideoW);
switch (uMsg)
{
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED)
{
switch (LOWORD(wParam))
{
case IDC_InputBtn://按钮事件处理
EnableWindow(hEdit1, !IsWindowEnabled(hEdit1));
EnableWindow(hEdit2, !IsWindowEnabled(hEdit2));
EnableWindow(hEdit3, !IsWindowEnabled(hEdit3));
if(IsWindowEnabled(hEdit1)||IsWindowEnabled(hEdit2)||IsWindowEnabled(hEdit3)){
EnableWindow(GetDlgItem(m_hwnd, IDC_InputBtn), FALSE);
SetDirty();
}
}
}
break;
case WM_INITDIALOG:
break;
}
return CBasePropertyPage::OnReceiveMessage(hwnd,uMsg,wParam,lParam);
}
CUnknown * WINAPI CiFlyNetSourceProp::CreateInstance(LPUNKNOWN lpunk, HRESULT *phr)
{
CUnknown *punk = new CiFlyNetSourceProp(lpunk, phr);
if (punk == NULL)
{
*phr = E_OUTOFMEMORY;
}
return punk;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -