Пример #1
0
//TCP接收数据处理函数
LONG CTCPClientDlg::OnRecvTCPData(WPARAM wParam,LPARAM lParam)
{
	CString strOldRecv = L"";
	CString strRecv = L"";
	//接收到的BUF
	CHAR *pBuf = (CHAR*)wParam;
	//接收到的BUF长度
	DWORD dwBufLen = lParam;
	//接收框
	CEdit *pEdtRecvMsg = (CEdit*)GetDlgItem(IDC_EDT_RECV);
	ASSERT(pEdtRecvMsg != NULL);

	//得到接收框中的历史文本
	pEdtRecvMsg->GetWindowTextW(strOldRecv);
	//
	strRecv = CString(pBuf);
	//将新接收到的文本添加到接收框中
	strOldRecv = strOldRecv + strRecv + L"\r\n";
	pEdtRecvMsg->SetWindowTextW(strOldRecv);

	//释放内存
	delete[] pBuf;
	pBuf = NULL;
	return 0;
}
Пример #2
0
//发送数据
void CSerialSampleDlg::OnBnClickedBtnSend()
{
	char * buf  =NULL;  //定义发送缓冲区
	DWORD dwBufLen = 0;   //定义发送缓冲区长度
	CString strSend = L"";

	//得到发送输入框
	CEdit *pEdtSendMsg = (CEdit*)GetDlgItem(IDC_EDT_SEND);
	ASSERT(pEdtSendMsg != NULL);

	//串口如果没有打开,直接返回
	if (m_pSerial == NULL)
	{
		AfxMessageBox(L"串口未打开");
		return;
	}

	//得到待发送的字符串
	pEdtSendMsg->GetWindowTextW(strSend);

	//将待发送的字符串转换成单字节,进行发送
	buf = new char[strSend.GetLength()*2+1];
	ZeroMemory(buf,strSend.GetLength()*2+1);
	//转换成单字节进行发送	
	WideCharToMultiByte(CP_ACP,WC_COMPOSITECHECK,strSend.GetBuffer(strSend.GetLength())
	   ,strSend.GetLength(),buf,strSend.GetLength()*2,NULL,NULL);

	dwBufLen = strlen(buf) + 1;
	//发送字符串
	m_pSerial->WriteSyncPort((BYTE*)buf,dwBufLen);

	//释放内存
	delete[] buf;
	buf = NULL;
}
Пример #3
0
//只允许输入数字 小数点
void CCheckEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	//只接受 数字、小数点、退格
	if( (nChar < '0' || nChar > '9') && nChar != '.' && nChar != VK_BACK )
		return ;

	CString strCheck;
	CEdit *pEdit = (CEdit*)GetFocus();
	pEdit->GetWindowTextW(strCheck);
	DWORD dwSel = pEdit->GetSel();

	//光标在最左边  1.不允许输入小数点	2.除了个位为0外,最高位不能为 0
	if(dwSel == 0){
		if(nChar == '.' || (nChar == '0' && !strCheck.IsEmpty()))
			return ;
	}
	//光标不在最左边  1.只允许输入一个小数点	2.只有一个0的情况下,除了小数点外任何数字均覆盖掉0(这里要做的就是清空)
	else{
		if(nChar == '.' && strCheck.Find(_T('.')) != -1)
			return ;
		if(strCheck.Compare(_T("0")) == 0 && (nChar != '.'&& nChar != VK_BACK))
			pEdit->SetWindowTextW(NULL);
	}

	CEdit::OnChar(nChar, nRepCnt, nFlags);
}
Пример #4
0
void COptionsDlg::ClearCurrentPage ()
{
	CWnd * parentGroupBox = GetDlgItem (IDC_OPTIONGROUP);
	for (size_t i=0;i<m_currentPageControls.size ();i++)
	{
		CWnd *item = parentGroupBox->GetDlgItem  ( ((CWnd*)(m_currentPageControls[i].first))->GetDlgCtrlID ());
		if (item)
		{				
				if (m_currentPageControls[i].second.UIType == avocado::AvocadoOption::CHECKBOX)
				{
					CButton *obj = (CButton*)(m_currentPageControls[i].first);
					
				    bool ischek = (obj->GetCheck () > 0);

					m_currentPageControls[i].second.valueBool = ischek;

					item->DestroyWindow ();
					
					delete obj;
				}
				else if (m_currentPageControls[i].second.UIType == avocado::AvocadoOption::EDITBOX)
				{
					 int labelID = ((CWnd*)(m_currentPageControls[i].first))->GetDlgCtrlID () - 1100 + 2200;

					CWnd *labelitem = parentGroupBox->GetDlgItem  (labelID);
					
					if (labelitem)
					{
						labelitem->DestroyWindow ();
						CStatic *css = (CStatic*) labelitem;
						delete css;
					}
					CEdit *obj = (CEdit*)(m_currentPageControls[i].first);

					wchar_t buf[MAX_PATH];
					obj->GetWindowTextW (buf, MAX_PATH);
					char cbuf [MAX_PATH];
					::wcstombs (cbuf,buf,MAX_PATH);
					
					if (m_currentPageControls[i].second.Type == avocado::AvocadoOption::STRING)
						m_currentPageControls[i].second.valueString = string (cbuf);
					else if (m_currentPageControls[i].second.Type == avocado::AvocadoOption::FLOAT)
					{
						stringstream ss ( cbuf);
						ss >> m_currentPageControls[i].second.valueFloat;
					}
					else if (m_currentPageControls[i].second.Type == avocado::AvocadoOption::BOOL)
					{
						string ss ( cbuf);
						bool bv = false;
						if (ss == "Yes")
							bv = true; else bv = false;
						m_currentPageControls[i].second.valueBool = bv;
					}
					else if (m_currentPageControls[i].second.Type == avocado::AvocadoOption::INT)
					{
						stringstream ss ( cbuf);
						ss >> m_currentPageControls[i].second.valueInt;
					}
Пример #5
0
void CIWinSyncDlg::WriteSettings()
{
	//Get the path to sync and save in registry
	CEdit* pPathEditBox = NULL;
	pPathEditBox = (CEdit*) GetDlgItem(IDC_EDIT_PATH);
	if (pPathEditBox != NULL)
	{
		TCHAR szTempPath[MAX_PATH];
		pPathEditBox->GetWindowTextW(szTempPath,MAX_PATH);
		if(m_pszCurrentSyncPath != NULL)
		{
			free(m_pszCurrentSyncPath);
			m_pszCurrentSyncPath = (TCHAR *) malloc((_tcslen(szTempPath)+1) *sizeof(TCHAR));
		}
		_tcscpy_s(m_pszCurrentSyncPath,(_tcslen(szTempPath)+1),szTempPath);
	}
	pPathEditBox = NULL;
	WriteRegStringValue(_T("Software\\IWinSync"), _T("CurSyncPath"),m_pszCurrentSyncPath);

	//get the sync interval
	CEdit* pIntervalEditBox = NULL;
	pIntervalEditBox = (CEdit*) GetDlgItem(IDC_EDIT_INTERVAL);
	if (pIntervalEditBox != NULL)
	{
		TCHAR szSyncInterval[50];
		pIntervalEditBox->GetWindowTextW(szSyncInterval,50);
		DWORD dwScanInterval = 0;
		_stscanf_s(szSyncInterval,_T("%u"),&dwScanInterval);
		m_nSyncInterval = dwScanInterval * 60000;
	}
	pIntervalEditBox = NULL;
	WriteRegDWordValue(_T("Software\\IWinSync"), _T("SyncInterval"),m_nSyncInterval/60000);

	CListBox * pLoggingLevelList = (CListBox*) GetDlgItem(IDC_LIST_LOGLEVEL);
	if (pLoggingLevelList != NULL)
	{
		m_dwLogLevel = pLoggingLevelList->GetCurSel();
	}
	pLoggingLevelList = NULL;

	if (m_dwLogLevel < 0 || m_dwLogLevel > 2)
	{
		m_dwLogLevel = DEFAULT_LOG_LEVEL;
	}
	WriteRegDWordValue(_T("Software\\IWinSync"), _T("LogLevel"),m_dwLogLevel);
}
Пример #6
0
void CQuoteTesterDlg::OnBnClickedButton1()
{
	// TODO: Add your control notification handler code here
	int  nCode = 0;

	CEdit* pEdit; 
    pEdit = (CEdit*) GetDlgItem(IDC_EDIT_ID); 
	CString strText;
	pEdit->GetWindowTextW(strText);

    pEdit = (CEdit*) GetDlgItem(IDC_EDIT_Pass); 
	CString strPassword;
	pEdit->GetWindowTextW(strPassword);

	CStringA strTempA(strText);
	const CHAR* caText = (LPCSTR)strTempA;
	
	CStringA strTempB(strPassword);
	const CHAR* caPass = (LPCSTR)strTempB;

	nCode = SKQuoteLib_Initialize(caText,caPass);

	if( nCode == 0 )
	{
		//註冊CALLBACK
		nCode = SKQuoteLib_AttachConnectionCallBack( (UINT_PTR) OnConnect);
		nCode = SKQuoteLib_AttachQuoteCallBack( (UINT_PTR) OnNotifyQuote);
		nCode = SKQuoteLib_AttachBest5CallBack( (UINT_PTR) OnNotifyBest5);
		//nCode = SKQuoteLib_AttachTicksCallBack( (UINT_PTR) OnNotifyTicks);
		nCode = SKQuoteLib_AttachTicksGetCallBack( (UINT_PTR) OnNotifyTicksGet);
		nCode = SKQuoteLib_AttachKLineDataCallBack( (UINT_PTR)OnNotifyKLineData );
		nCode = SKQuoteLib_AttachMarketTotCallBack( (UINT_PTR)OnNotifyMarketTot );
		nCode = SKQuoteLib_AttachMarketBuySellCallBack( (UINT_PTR)OnNotifyMarketBuySell );
		nCode = SKQuoteLib_AttachMarketHighLowCallBack( (UINT_PTR)OnNotifyMarketHighLow );
		nCode = SKQuoteLib_AttachStrikePricesCallBack( (UINT_PTR)OnNotifyStrikePrices );
		nCode = SKQuoteLib_AttchServerTimeCallBack( (UINT_PTR)OnNotifyServerTime );
		nCode = SKQuoteLib_AttachHistoryTicksGetCallBack( (UINT_PTR) OnNotifyTicksGet);
		nCode = SKQuoteLib_AttachProductsReadyCallBack( (UINT_PTR) OnNotifyProductsReady);

		AfxMessageBox(_T("初始成功"));
	}
}
Пример #7
0
BOOL CTabpageLend::PreTranslateMessage(MSG* pMsg)
{
	CEdit* pEditId = (CEdit*)GetDlgItem(IDC_EDIT_ID);
	CEdit* pEditGunId = (CEdit*)GetDlgItem(IDC_EDIT_GUN);
	if (pEditId != NULL && pMsg->hwnd == pEditId->GetSafeHwnd()
		&& VK_RETURN == pMsg->wParam)
	{
		CString id;
		pEditId->GetWindowTextW(id);
		DoIDInput(id);
		return TRUE;
	}
	else if (pEditGunId != NULL && pMsg->hwnd == pEditGunId->GetSafeHwnd()
		&& VK_RETURN == pMsg->wParam)
	{
		CString gunId;
		pEditGunId->GetWindowTextW(gunId);
		DoGunIDInput(gunId);
		return TRUE;
	}
	return CDialogEx::PreTranslateMessage(pMsg);
}
Пример #8
0
BOOL CTabpageBorrow::PreTranslateMessage(MSG* pMsg)
{
	// TODO: Add your specialized code here and/or call the base class
	CEdit* pEditId = (CEdit*)GetDlgItem(IDC_EDIT_ID_IN_BORROW);
	CEdit* pEditGunId = (CEdit*)GetDlgItem(IDC_EDIT_GUN);
	if (pEditId != NULL && pMsg->hwnd == pEditId->GetSafeHwnd()
		&& VK_RETURN == pMsg->wParam)
	{
		CString id;
		pEditId->GetWindowTextW(id);
		DoIDInput(id);
		return TRUE;
	}
	else if (pEditGunId != NULL && pMsg->hwnd == pEditGunId->GetSafeHwnd()
		&& VK_RETURN == pMsg->wParam)
	{
		CString gunId;
		pEditGunId->GetWindowTextW(gunId);
		DoGunIDInput(gunId);
		return TRUE;
	}
	return CDialogEx::PreTranslateMessage(pMsg);
}
void CFindItemDlg::OnEnChangeEditKeyword()
{
	// TODO:  If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.

	// TODO:  Add your control notification handler code here
	CEdit* e = (CEdit*)GetDlgItem(IDC_EDIT_KEYWORD);
	if(e)
	{
		e->GetWindowTextW(m_KeywordStringValue);
		std::wstring wstr(m_KeywordStringValue);
		CSettingsSM::GetInstance()->SetUserString(wstr);
	}
}
Пример #10
0
void CCardInfDlg::OnBnClickedSearchId()
{
	GetDlgItem(IDC_Search_ID)->EnableWindow(false);
	GetDlgItem(IDC_getInf)->EnableWindow(false);

	CEdit* edit = (CEdit*)GetDlgItem(IDC_phy_number);
	CString phy_num_str;
	edit->GetWindowTextW(phy_num_str);

	r = -1;
	param.CardNumber = phy_num_str;
	param.row = &r;
	param.progresspointer = &indicator;
	pThread = AfxBeginThread(CExcelUtils::SearchCardNumber, (LPVOID)&param);

	SetTimer(2, 50, NULL);
}
Пример #11
0
void CCardInfDlg::OnBnClickedgetinf()
{
	GetDlgItem(IDC_Search_ID)->EnableWindow(false);
	GetDlgItem(IDC_getInf)->EnableWindow(false);

	// 获取输入框对象
	CEdit* edit = (CEdit*)GetDlgItem(IDC_ID);
	CString ID_str;
	edit->GetWindowTextW(ID_str);

	r_ID = -1;
	param_ID.CardNumber = ID_str;
	param_ID.row = &r_ID;
	param_ID.progresspointer = &indicator_ID;
	pThread_ID = AfxBeginThread(CExcelUtils::SearchInfByID, (LPVOID)&param_ID);

	SetTimer(3, 50, NULL);
}
Пример #12
0
// 显示GPS串口接收的数据
LONG CGPSDemoDlg::OnRecvSerialData(WPARAM wParam,LPARAM lParam)
{
	//得到原始数据
	char * aRecv = (char *)wParam;
	
	CString strRecv = L"";
	CString strRecv1 = L"";
	//
	CEdit *pEdtRecv = (CEdit*)GetDlgItem(IDC_EDT_RECV);

	//得到接收框原来的文本
	pEdtRecv->GetWindowTextW(strRecv1);
	strRecv = CString(aRecv);
	//追加新接收到的文本
	pEdtRecv->SetWindowTextW(strRecv1+strRecv);
	
	//释放内存
	delete[] aRecv;
	aRecv = NULL;
	return 0;

}
Пример #13
0
void CQuoteTesterDlg::OnBnClickedButton5()
{
	// TODO: Add your control notification handler code here

	int		nCode = 0;
	short	sPageNo = 1;

	m_nType = 2;

	CListBox   *pListBox   =   (CListBox *)GetDlgItem(IDC_LIST); 
	pListBox->ResetContent();

	CEdit* pEdit; 
    pEdit = (CEdit*) GetDlgItem(IDC_EDIT_Ticks); 
	CString strText;
	pEdit->GetWindowTextW(strText);
	
	CStringA strTempA(strText);
	char*   caText   =   strTempA.GetBuffer(strTempA.GetLength()); 
	
	SKQuoteLib_RequestTicks(&sPageNo,caText);
}
Пример #14
0
void CCgxDlg::OnBnClickedStart()
{
	CComboBox* gameList = (CComboBox*)GetDlgItem(IDC_GAME_LIST);
	CButton* startBtn = (CButton *)GetDlgItem(IDC_START);
	CEdit* script = (CEdit *)GetDlgItem(IDC_SCRIPT);
	CString strLine;

	int index = gameList->GetCurSel();
	if(gameManager.gameSize == 0 || index > gameManager.gameSize)
		return;
	if(gameManager.games[index]->isAIStart)
	{
		gameManager.games[index]->stopAI();
		startBtn->SetWindowTextW(TEXT("启动"));
	} 
	else
	{
		script->GetWindowTextW(strLine);
		gameManager.games[index]->script.loadScript((LPCWSTR)strLine);
		gameManager.games[index]->startAI();
		startBtn->SetWindowTextW(TEXT("停止"));
	}
}
Пример #15
0
//发送数据
void CTCPClientDlg::OnBnClickedBtnSenddata()
{
	CString strSendData;
	char * sendBuf;
	int sendLen=0;
	CEdit *pEdtSend = (CEdit*)GetDlgItem(IDC_EDT_SEND);
	pEdtSend->GetWindowTextW(strSendData);

	//设置发送缓冲区
	sendLen = strSendData.GetLength()*2 + 2;
	sendBuf = new char[sendLen];
	ZeroMemory(sendBuf,sendLen);
	wcstombs(sendBuf,strSendData,sendLen);
	sendLen = strlen(sendBuf)+1;
	//发送数据
	if (!m_tcpClient.SendData(sendBuf,sendLen))
	{
		AfxMessageBox(_T("发送失败"));
	}
	//释放内存
	delete[] sendBuf;
	sendBuf = NULL;		
}
Пример #16
0
void CQuoteTesterDlg::OnBnClickedButton6()
{
	// TODO: Add your control notification handler code here

	CComboBox   *pComboBox   =   (CComboBox *)GetDlgItem(IDC_COMBO_KLine); 

	int nType = pComboBox->GetCurSel();

	m_nType = 3;

	CListBox   *pListBox   =   (CListBox *)GetDlgItem(IDC_LIST); 
	pListBox->ResetContent();

	CEdit* pEdit; 
    pEdit = (CEdit*) GetDlgItem(IDC_EDIT_KLine); 
	CString strText;
	pEdit->GetWindowTextW(strText);
	
	CStringA strTempA(strText);
	char*   caText   =   strTempA.GetBuffer(strTempA.GetLength()); 

	SKQuoteLib_GetKLine(caText,nType);
}
Пример #17
0
void CDlgPanel::OnBnClickedButtonStart()
{
	if (m_pManager)
	{
		int nType = m_pCmbType->GetCurSel();
		if (nType == 0)
		{
			//采集
			CWnd* pCapWnd = GetDlgVideo();
			BOOL bInCap = m_pManager->IsInCapture();
			if (!bInCap)
			{
				CComboBox* pComboxMediaSource = m_pCmbSourceType;
				CComboBox* pVideoCombo = m_pCmbCamera ;
				CComboBox* pAudioCombo = m_pCmbMic ;
				CEdit* pEdtRtspSource = m_pEdtRtspStream;

				SOURCE_TYPE eType = (SOURCE_TYPE)pComboxMediaSource->GetCurSel();
				int nCamId = 0;
				int nAudioId = 0;
				char szURL[128] = {0,};
				CString strTemp = _T("");

				//视频参数设置
				int nWidth = m_sAVCapParamInfo.nVWidth;
				int nHeight = m_sAVCapParamInfo.nVHeight;
				int nFps = m_sAVCapParamInfo.nFps;
				int nBitrate = m_sAVCapParamInfo.nBitrate;
				char  szDataType[64];
				strcpy_s(szDataType, m_sAVCapParamInfo.strColorFormat )	;
				//音频参数设置
				int nASampleRate = m_sAVCapParamInfo.nASampleRate;
				int nAChannels =m_sAVCapParamInfo.nAChannels;

				if (eType == SOURCE_LOCAL_CAMERA)
				{
					nCamId = pVideoCombo->GetCurSel();
					nAudioId = pAudioCombo->GetCurSel();
					strTemp = _T("本地音视频采集");

				}
				else if ((eType == SOURCE_SCREEN_CAPTURE))
				{
					nCamId = -1;
					nAudioId = pAudioCombo->GetCurSel();
					strTemp = _T("屏幕采集");
					strcpy_s(szDataType , "RGB24");

					int nRet =m_pManager->GetScreenCapSize(nWidth, nHeight);
					if (nRet<1)
					{
						m_pManager->LogErr(_T("屏幕采集获取长宽失败,本地预览失败!"));
						return;
					}
				}
				else
				{
					//Start
					wchar_t wszURL[128] = {0,};
					if (NULL != pEdtRtspSource)
						pEdtRtspSource->GetWindowTextW(wszURL, sizeof(wszURL));
					if (wcslen(wszURL) < 1)		return;

					CString strURL = wszURL;
					CString strRTSP = strURL.Mid(0,4);
					if (strRTSP!=_T("rtsp")&&strRTSP!=_T("RTSP"))
					{
						strURL = _T("rtsp://")+strURL;
					}

					__WCharToMByte(strURL, szURL, sizeof(szURL)/sizeof(szURL[0]));
					strTemp = _T("网络音视频流采集");
				}

				int nRet = m_pManager->StartCapture( eType,  nCamId, nAudioId, pCapWnd->GetSafeHwnd(), szURL, nWidth, nHeight, nFps,nBitrate, szDataType, nASampleRate , nAChannels );
				if (nRet>0)
				{
					strTemp +=_T("成功!"); 
					m_pManager->LogErr(strTemp);
				} 
				else
				{
					strTemp +=_T("失败!"); 
					m_pManager->LogErr(strTemp);
					return;
				}

				//推送
				//获取服务器流地址信息
				ServerURLInfo URLInfo;
				memset(&URLInfo, 0, sizeof(ServerURLInfo));
				if (m_pMainDlg)
				{
					m_pMainDlg->	GetPushServerInfo(&URLInfo);
				}

				bool bPushRtmp = false;
				//流名称格式化
				FormatStreamName(URLInfo.sdpName);
				nRet = m_pManager->StartPush(URLInfo.pushServerAddr, URLInfo.pushServerPort,URLInfo.sdpName, URLInfo.nPushBufferLenth, bPushRtmp);
				CString strMsg = _T("");
				CString strIp;
				CString strName;
				strIp = URLInfo.pushServerAddr;
				strName = URLInfo.sdpName;
				if (nRet>=0)
				{
					strMsg.Format(_T("推送EasyDarwin服务器URL:rtsp://%s:%d/%s 成功!"), strIp , URLInfo.pushServerPort, strName);
					m_pManager->LogErr(strMsg);
					m_btnStart.SetWindowText(TEXT("Stop"));
					if (bPushRtmp)
					{
						strMsg.Format(_T("连接RTMP服务器成功,推送RTMP服务器URL:rtmp://%s:1935/live/%s 成功!"), strIp , strName);
						m_pManager->LogErr(strMsg);
					}
				} 
				else
				{
					strMsg.Format(_T("推送EasyDarwin服务器URL:rtsp://%s:%d/%s 失败!"), strIp, URLInfo.pushServerPort,strName);
					m_pManager->LogErr(strMsg);
					if (bPushRtmp)
					{
						if (nRet == -1)
							strMsg.Format(_T("连接RTMP服务器失败!"), strIp , strName);
						else
							strMsg.Format(_T("推送RTMP服务器URL:rtmp://%s:1935/live/%s 失败!"), strIp , strName);
						m_pManager->LogErr(strMsg);
					}
				}
			}
			else
			{
				m_pManager->LogErr(_T("停止推送!"));
				m_pManager->StopPush();

				m_pManager->StopCapture();
				m_btnStart.SetWindowText(TEXT("Start"));
				m_pManager->LogErr(_T("本地预览停止"));

				pCapWnd->Invalidate();	
			}
		} 
		else //直播
		{
			//RTSP
			CWnd* pPlayWnd = GetDlgVideo();
			BOOL bInPlay = m_pManager->IsInPlaying();
			if (!bInPlay)
			{
				char szIp[128] = {0,};
				wchar_t wszIp[128] = {0,};

				if (NULL != m_pEdtRtspStream)	
					m_pEdtRtspStream->GetWindowTextW(wszIp, sizeof(wszIp));
				if (wcslen(wszIp) < 1)		
					return;
				__WCharToMByte(wszIp, szIp, sizeof(szIp)/sizeof(szIp[0]));

				int nRet = m_pManager->StartPlay(szIp, pPlayWnd->GetSafeHwnd());
				m_btnStart.SetWindowText(TEXT("Stop"));
				CString strMsg = _T("");
				if (nRet>0)
				{
					strMsg.Format(_T("直播预览URL:%s 成功!"), wszIp);
				} 
				else
				{
					strMsg.Format(_T("直播预览URL:%s 失败!"), wszIp);
				}
				m_pManager->LogErr(strMsg);
			}
			else
			{
				m_pManager->StopPlay();
				m_btnStart.SetWindowText(TEXT("Start"));
				pPlayWnd->Invalidate();	
				m_pManager->LogErr(_T("停止直播"));
			}
		}
	}
}
Пример #18
0
void CEasyClientDlg::OnBnClickedBtnCapture()
{
	if (m_pManager)
	{
		CWnd* pCapWnd = easyVideoPanelObj.pDlgLocalPanel->GetDlgVideoHwnd();
		BOOL bInCap = m_pManager->IsInCapture();
		CButton* pBtnStartCapture = (CButton*)GetDlgItem(IDC_BTN_CAPTURE) ;
		if (!bInCap)
		{
			CComboBox* pComboxMediaSource = (CComboBox*)GetDlgItem(IDC_COMBO_SOURCE);
			CComboBox* pVideoCombo = (CComboBox*)GetDlgItem(IDC_COMBO_CAMERA) ;
			CEdit* pEdtRtspSource = (CEdit*)GetDlgItem(IDC_EDIT_SREAM_URL);

			SOURCE_TYPE eType = (SOURCE_TYPE)pComboxMediaSource->GetCurSel();
			int nCamId = 0;
			char szURL[128] = {0,};
			CString strTemp = _T("");
			if (eType == SOURCE_LOCAL_CAMERA)
			{
				nCamId = pVideoCombo->GetCurSel();
				strTemp = _T("±¾µØÒôÊÓƵ²É¼¯");
			} 
			else
			{
				//Start
				wchar_t wszURL[128] = {0,};
				if (NULL != pEdtRtspSource)
					pEdtRtspSource->GetWindowTextW(wszURL, sizeof(wszURL));
				if (wcslen(wszURL) < 1)		return;

				CString strURL = wszURL;
				CString strRTSP = strURL.Mid(0,4);
				if (strRTSP!=_T("rtsp")&&strRTSP!=_T("RTSP"))
				{
					strURL = _T("rtsp://")+strURL;
				}
				
				__WCharToMByte(strURL, szURL, sizeof(szURL)/sizeof(szURL[0]));
				strTemp = _T("ÍøÂçÒôÊÓƵÁ÷²É¼¯");

			}
			int nRet = m_pManager->StartCapture( eType,  nCamId, pCapWnd->GetSafeHwnd(), szURL);
			if (nRet>0)
			{
				strTemp +=_T("³É¹¦£¡"); 
			} 
			else
			{
				strTemp +=_T("ʧ°Ü£¡"); 
			}
			m_pManager->LogErr(strTemp);
			if (NULL != pBtnStartCapture)		pBtnStartCapture->SetWindowText(TEXT("Stop"));

		}
		else
		{
			m_pManager->StopCapture();
			if (NULL != pBtnStartCapture)		pBtnStartCapture->SetWindowText(TEXT("±¾µØÔ¤ÀÀ"));
			m_pManager->LogErr(_T("±¾µØÔ¤ÀÀÍ£Ö¹"));

			pCapWnd->Invalidate();	
		}
	}
}
Пример #19
0
void CEasyClientDlg::OnBnClickedBtnPush()
{
	if (m_pManager)
	{
		BOOL bInPush = m_pManager->IsInPushing();
		CEdit* pIP = (CEdit*)GetDlgItem(IDC_EDIT_SERVER_IP);
		CEdit* pPort = (CEdit*)GetDlgItem(IDC_EDIT_SERVER_PORT);
		CEdit* pName = (CEdit*)GetDlgItem(IDC_EDIT_PUSH_NAME);
		
		CButton* pBtnStartPush = (CButton*)GetDlgItem(IDC_BTN_PUSH) ;
		if (!bInPush)
		{
			char szIp[128] = {0,};
			char szPort[128] = {0,};
			char szName[128] = {0,};
			wchar_t wszIp[128] = {0,};
			wchar_t wszPort[128] = {0,};
			wchar_t wszName[128] = {0,};
			if (NULL != pIP)	
				pIP->GetWindowTextW(wszIp, sizeof(wszIp));
			if (wcslen(wszIp) < 1)		
				return;
			__WCharToMByte(wszIp, szIp, sizeof(szIp)/sizeof(szIp[0]));

			if (NULL != pPort)	
				pPort->GetWindowTextW(wszPort, sizeof(wszPort));
			if (wcslen(wszPort) < 1)		
				return;
			__WCharToMByte(wszPort, szPort, sizeof(szPort)/sizeof(szPort[0]));
			int nPort = atoi(szPort);

			if (NULL != pName)	
				pName->GetWindowTextW(wszName, sizeof(wszName));
			if (wcslen(wszName) < 1)		
				return;
			__WCharToMByte(wszName, szName, sizeof(szName)/sizeof(szName[0]));
			
			int nRet = m_pManager->StartPush(szIp , nPort,  szName);
			CString strMsg = _T("");
			if (nRet>=0)
			{
				strMsg.Format(_T("ÍÆËÍEasyDarwin·þÎñÆ÷URL£ºrtsp://%s:%d/%s ³É¹¦£¡"), wszIp, nPort, wszName);
				if (NULL != pBtnStartPush)		pBtnStartPush->SetWindowText(TEXT("Stop"));
			} 
			else
			{
				strMsg.Format(_T("ÍÆËÍEasyDarwin·þÎñÆ÷URL£ºrtsp://%s:%d/%s ʧ°Ü£¡"), wszIp, nPort, wszName);

			}
			m_pManager->LogErr(strMsg);
	
		}
		else
		{
			m_pManager->LogErr(_T("Í£Ö¹ÍÆËÍ£¡"));
			m_pManager->StopPush();
			if (NULL != pBtnStartPush)		pBtnStartPush->SetWindowText(TEXT("ÍÆËÍ->"));
		}
	}

}
Пример #20
0
void CEasyClientDlg::OnBnClickedBtnPlay()
{
	if (m_pManager)
	{
		CWnd* pPlayWnd = easyVideoPanelObj.pDlgRemotePanel->GetDlgVideo();
		CEdit* pIP = (CEdit*)GetDlgItem(IDC_EDIT_SERVER_IP);
		CEdit* pPort = (CEdit*)GetDlgItem(IDC_EDIT_SERVER_PORT);
		CEdit* pName = (CEdit*)GetDlgItem(IDC_EDIT_PUSH_NAME);
		CWnd* pCapWnd = easyVideoPanelObj.pDlgLocalPanel->GetDlgVideoHwnd();
		BOOL bInPlay = m_pManager->IsInPlaying();
		CButton* pBtnStartPlay= (CButton*)GetDlgItem(IDC_BTN_PLAY) ;
		if (!bInPlay)
		{
			char szIp[128] = {0,};
			char szPort[128] = {0,};
			char szName[128] = {0,};
			wchar_t wszIp[128] = {0,};
			wchar_t wszPort[128] = {0,};
			wchar_t wszName[128] = {0,};
			if (NULL != pIP)	
				pIP->GetWindowTextW(wszIp, sizeof(wszIp));
			if (wcslen(wszIp) < 1)		
				return;
			__WCharToMByte(wszIp, szIp, sizeof(szIp)/sizeof(szIp[0]));

			if (NULL != pPort)	
				pPort->GetWindowTextW(wszPort, sizeof(wszPort));
			if (wcslen(wszPort) < 1)		
				return;
			__WCharToMByte(wszPort, szPort, sizeof(szPort)/sizeof(szPort[0]));
			int nPort = atoi(szPort);

			if (NULL != pName)	
				pName->GetWindowTextW(wszName, sizeof(wszName));
			if (wcslen(wszName) < 1)		
				return;
			__WCharToMByte(wszName, szName, sizeof(szName)/sizeof(szName[0]));

			char szURL[128]= {0,};
			sprintf(szURL, "rtsp://%s:%d/%s", szIp,  nPort, szName );
			int nRet = m_pManager->StartPlay(szURL, pPlayWnd->GetSafeHwnd());
			if (NULL != pBtnStartPlay)		pBtnStartPlay->SetWindowText(TEXT("Stop"));
			CString strMsg = _T("");
			if (nRet>0)
			{
				strMsg.Format(_T("Ö±²¥Ô¤ÀÀURL£ºrtsp://%s:%d/%s ³É¹¦£¡"), wszIp, nPort, wszName);
			} 
			else
			{
				strMsg.Format(_T("Ö±²¥Ô¤ÀÀURL£ºrtsp://%s:%d/%s ʧ°Ü£¡"), wszIp, nPort, wszName);

			}
			m_pManager->LogErr(strMsg);
		}
		else
		{
			m_pManager->StopPlay();
			if (NULL != pBtnStartPlay)		pBtnStartPlay->SetWindowText(TEXT("Ö±²¥Ô¤ÀÀ"));
			pPlayWnd->Invalidate();	
			m_pManager->LogErr(_T("Í£Ö¹Ö±²¥"));
		}
	}
}
Пример #21
0
void CSettingDlg::OnBnClickedOk()
{
	int nWidth = 640;
	int nHeight = 480;
	int nFps = 25;
	int nBitrate = 2048;
	int nSampleRate = 44100;
	int nChannels = 2;

	char szWidth[128] = {0,};
	wchar_t wszWidth[128] = {0,};
	char szHeight[128] = {0,};
	wchar_t wszHeight[128] = {0,};
	char szFPS[128] = {0,};
	wchar_t wszFPS[128] = {0,};
	char szBitrate[128] = {0,};
	wchar_t wszBitrate[128] = {0,};

	char szSampleRate[128] = {0,};
	wchar_t wszSampleRate[128] = {0,};
	char szChannels[128] = {0,};
	wchar_t wszChannels[128] = {0,};

	CEdit* pEdit = NULL;
	pEdit = (CEdit*)GetDlgItem(IDC_EDIT_VWIDTH);
	if (pEdit)
	{
		pEdit->GetWindowTextW(wszWidth, sizeof(wszWidth));
		if (wcslen(wszWidth) < 1)		
			return;
		__WCharToMByte(wszWidth, szWidth, sizeof(szWidth)/sizeof(szWidth[0]));
		nWidth = atoi(szWidth);
	}

	pEdit = (CEdit*)GetDlgItem(IDC_EDIT_VHEIGHT);
	if (pEdit)
	{
		pEdit->GetWindowTextW(wszHeight, sizeof(wszHeight));
		if (wcslen(wszHeight) < 1)		
			return;
		__WCharToMByte(wszHeight, szHeight, sizeof(szHeight)/sizeof(szHeight[0]));
		nHeight = atoi(szHeight);
	}
	pEdit = (CEdit*)GetDlgItem(IDC_EDIT_FPS);
	if (pEdit)
	{
		pEdit->GetWindowTextW(wszFPS, sizeof(wszFPS));
		if (wcslen(wszFPS) < 1)		
			return;
		__WCharToMByte(wszFPS, szFPS, sizeof(szFPS)/sizeof(szFPS[0]));
		nFps = atoi(szFPS);
	}
	pEdit = (CEdit*)GetDlgItem(IDC_EDIT_BITRATE);
	if (pEdit)
	{
		pEdit->GetWindowTextW(wszBitrate, sizeof(wszBitrate));
		if (wcslen(wszBitrate) < 1)		
			return;
		__WCharToMByte(wszBitrate, szBitrate, sizeof(szBitrate)/sizeof(szBitrate[0]));
		nBitrate = atoi(szBitrate);
	}

	pEdit = (CEdit*)GetDlgItem(IDC_EDIT_ASAMPLERATE);
	if (pEdit)
	{
		pEdit->GetWindowTextW(wszSampleRate, sizeof(wszSampleRate));
		if (wcslen(wszSampleRate) < 1)		
			return;
		__WCharToMByte(wszSampleRate, szSampleRate, sizeof(szSampleRate)/sizeof(szSampleRate[0]));
		nSampleRate = atoi(szSampleRate);	
	}

	pEdit = (CEdit*)GetDlgItem(IDC_EDIT_ACHANNELS);
	if (pEdit)
	{
		pEdit->GetWindowTextW(wszChannels, sizeof(wszChannels));
		if (wcslen(wszChannels) < 1)		
			return;
		__WCharToMByte(wszChannels, szChannels, sizeof(szChannels)/sizeof(szChannels[0]));
		nChannels = atoi(szChannels);	
	}

	m_sParamInfo.nVWidth = nWidth;
	m_sParamInfo.nVHeight = nHeight;
	m_sParamInfo.nFps = nFps;
	m_sParamInfo.nBitrate = nBitrate;
	m_sParamInfo.nASampleRate = nSampleRate;
	m_sParamInfo.nAChannels = nChannels;

	CComboBox* pCombo = (CComboBox*) GetDlgItem ( IDC_COMBO_COLORFORMAT );
	if (pCombo)
	{
		int nSel = pCombo->GetCurSel();
		if (nSel == 0)
		{
			strcpy_s(m_sParamInfo.strColorFormat , "YUY2");
		} 
		else
		{
			strcpy_s(m_sParamInfo.strColorFormat , "RGB24");
		}
	}
	OnOK();
}