急救,写了一个C++程序,显示网络摄像头的实时画面解决办法
急救,写了一个C++程序,显示网络摄像头的实时画面
显示出来以后,想实现监控画面的双击全屏,再双击退出全屏,结果写的东西不对了,因为窗口中除了画面还有一些按钮如登陆和注销等,双击的时候是整个窗口全屏,不是视频全屏,小弟新手,求教怎么修改
void CDvrClientPreviewDlg::OnNMRClickListserver(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
int nSelect = m_listCtrlServer.GetSelectionMark();
if (-1 == nSelect)
{
return;
}
CString csChanInfo;
CMenu popMenu;
if(popMenu.CreatePopupMenu())//创建动态弹出菜单
{
for(int nChanNum = 0; nChanNum < (int)m_userIdSet[nSelect].devInfo.byChanNum;
nChanNum++)//添加子菜单项等于通道数
{
csChanInfo.Format(_T("%d-%s"),nChanNum+1,
(LPTSTR)m_userIdSet[nSelect].devInfo.sChanName[nChanNum]);
popMenu.AppendMenu(MF_STRING, nChanNum + POPMENU_ID, csChanInfo);
}
CPoint pt;
GetCursorPos(&pt);//获取鼠标点击位置
popMenu.TrackPopupMenu(TPM_RIGHTBUTTON, pt.x, pt.y, this);//绘制窗口
popMenu.DestroyMenu();//销毁弹出菜单
}
*pResult = 0;
}
//用户注销DVR
void CDvrClientPreviewDlg::OnBnClickedButtonlogout()
{
// TODO: 在此添加控件通知处理程序代码
int nSelect = m_listCtrlServer.GetSelectionMark();
if (-1 == nSelect)
{
return;
}
CString csWarning;
if (FALSE != m_lRealPlayhandle)//当前有实时视频在播放
{
HB_SDVR_StopRealPlay(m_lRealPlayhandle);
}
if (!HB_SDVR_Logout(m_userIdSet[nSelect].lUserId))//用户注销
{
csWarning.LoadString(IDS_STRINGLOGOUTFAIL);
MessageBox(csWarning);
}
m_lRealPlayhandle = FALSE;
m_listCtrlServer.DeleteItem(m_listCtrlServer.GetSelectionMark());
Invalidate(TRUE);
RedrawWindow();
m_userIdSet.erase(m_userIdSet.begin()+nSelect);//从列表控件删除注销的服务器
}
//列表控件右键菜单的左键单击消息
BOOL CDvrClientPreviewDlg::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
// TODO: 在此添加专用代码和/或调用基类
WPARAM MenuId = GetCurrentMessage()->wParam; //获得当前被单击的菜单的ID号
if(MenuId >= POPMENU_ID) //检查ID是否是动态建立的
{
if(MenuId == nID && nCode == CN_COMMAND) //子菜单项被单击
{
if (FALSE != m_lRealPlayhandle)
{
HB_SDVR_StopRealPlay(m_lRealPlayhandle);
}
HB_SDVR_CLIENTINFO clientInfo;
ZeroMemory(&clientInfo, sizeof(clientInfo));
clientInfo.hPlayWnd = m_cStaticPlayWindow.GetSafeHwnd();
clientInfo.lChannel = nID - POPMENU_ID;
clientInfo.lLinkMode = 0x00000000; //TCP
m_lRealPlayhandle = HB_SDVR_RealPlay(
m_userIdSet[m_listCtrlServer.GetSelectionMark()].lUserId, 0, &clientInfo);//开始播放实时视频
}
}
return CDialog::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
void CDvrClientPreviewDlg::OnClose()
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
CString csWarning;
if (FALSE != m_lRealPlayhandle)
{
OnBnClickedButtonlogout();
}
if (FALSE == HB_SDVR_Cleanup())//回收资源
{
csWarning.LoadString(IDS_STRINGCLEANUPERR);
MessageBox(csWarning);
}
CDialog::OnClose();
}
void CDvrClientPreviewDlg::OnLvnItemchangedListserver(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
// TODO: Add your control notification handler code here
*pResult = 0;
}
void CDvrClientPreviewDlg::OnEnChangeEditip()
{
// 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
}
// void CDvrClientPreviewDlg::OnBnClickedButton1()
// {
// // TODO: Add your control notification handler code here
//
// }
void CDvrClientPreviewDlg::OnBnClickedButton2()
{
// TODO: Add your control notification handler code here
char cFilename[256];
CTime time = CTime::GetCurrentTime();
sprintf(cFilename, "D:\\pic\\%dch%d%d%d%d%d%d%d.bmp", m_lRealPlayhandle ,
time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond(), GetTickCount());
if (m_lRealPlayhandle > -1)
{
HB_SDVR_CapturePicture(m_lRealPlayhandle,cFilename);
}
}
BOOL bClick;// 对话框类的成员变量,初始化为FALSE
CRect rc(0,0,::GetSystemMetrics(SM_CXFRAME),::GetSystemMetrics(SM_CYFRAME)); // 保存对话的屏蔽坐标区域,
void CDvrClientPreviewDlg::OnStnClickedStaticplaywindow()
{
// TODO: 在此添加控件通知处理程序代码
}
// 鼠标左键双击消息WM_LBUTTONDBLCLK消息响应函数
void CDvrClientPreviewDlg::OnLButtonDblClk(UINT nFlags, CPoint point)
显示出来以后,想实现监控画面的双击全屏,再双击退出全屏,结果写的东西不对了,因为窗口中除了画面还有一些按钮如登陆和注销等,双击的时候是整个窗口全屏,不是视频全屏,小弟新手,求教怎么修改
void CDvrClientPreviewDlg::OnNMRClickListserver(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
// TODO: 在此添加控件通知处理程序代码
int nSelect = m_listCtrlServer.GetSelectionMark();
if (-1 == nSelect)
{
return;
}
CString csChanInfo;
CMenu popMenu;
if(popMenu.CreatePopupMenu())//创建动态弹出菜单
{
for(int nChanNum = 0; nChanNum < (int)m_userIdSet[nSelect].devInfo.byChanNum;
nChanNum++)//添加子菜单项等于通道数
{
csChanInfo.Format(_T("%d-%s"),nChanNum+1,
(LPTSTR)m_userIdSet[nSelect].devInfo.sChanName[nChanNum]);
popMenu.AppendMenu(MF_STRING, nChanNum + POPMENU_ID, csChanInfo);
}
CPoint pt;
GetCursorPos(&pt);//获取鼠标点击位置
popMenu.TrackPopupMenu(TPM_RIGHTBUTTON, pt.x, pt.y, this);//绘制窗口
popMenu.DestroyMenu();//销毁弹出菜单
}
*pResult = 0;
}
//用户注销DVR
void CDvrClientPreviewDlg::OnBnClickedButtonlogout()
{
// TODO: 在此添加控件通知处理程序代码
int nSelect = m_listCtrlServer.GetSelectionMark();
if (-1 == nSelect)
{
return;
}
CString csWarning;
if (FALSE != m_lRealPlayhandle)//当前有实时视频在播放
{
HB_SDVR_StopRealPlay(m_lRealPlayhandle);
}
if (!HB_SDVR_Logout(m_userIdSet[nSelect].lUserId))//用户注销
{
csWarning.LoadString(IDS_STRINGLOGOUTFAIL);
MessageBox(csWarning);
}
m_lRealPlayhandle = FALSE;
m_listCtrlServer.DeleteItem(m_listCtrlServer.GetSelectionMark());
Invalidate(TRUE);
RedrawWindow();
m_userIdSet.erase(m_userIdSet.begin()+nSelect);//从列表控件删除注销的服务器
}
//列表控件右键菜单的左键单击消息
BOOL CDvrClientPreviewDlg::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
// TODO: 在此添加专用代码和/或调用基类
WPARAM MenuId = GetCurrentMessage()->wParam; //获得当前被单击的菜单的ID号
if(MenuId >= POPMENU_ID) //检查ID是否是动态建立的
{
if(MenuId == nID && nCode == CN_COMMAND) //子菜单项被单击
{
if (FALSE != m_lRealPlayhandle)
{
HB_SDVR_StopRealPlay(m_lRealPlayhandle);
}
HB_SDVR_CLIENTINFO clientInfo;
ZeroMemory(&clientInfo, sizeof(clientInfo));
clientInfo.hPlayWnd = m_cStaticPlayWindow.GetSafeHwnd();
clientInfo.lChannel = nID - POPMENU_ID;
clientInfo.lLinkMode = 0x00000000; //TCP
m_lRealPlayhandle = HB_SDVR_RealPlay(
m_userIdSet[m_listCtrlServer.GetSelectionMark()].lUserId, 0, &clientInfo);//开始播放实时视频
}
}
return CDialog::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
void CDvrClientPreviewDlg::OnClose()
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
CString csWarning;
if (FALSE != m_lRealPlayhandle)
{
OnBnClickedButtonlogout();
}
if (FALSE == HB_SDVR_Cleanup())//回收资源
{
csWarning.LoadString(IDS_STRINGCLEANUPERR);
MessageBox(csWarning);
}
CDialog::OnClose();
}
void CDvrClientPreviewDlg::OnLvnItemchangedListserver(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);
// TODO: Add your control notification handler code here
*pResult = 0;
}
void CDvrClientPreviewDlg::OnEnChangeEditip()
{
// 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
}
// void CDvrClientPreviewDlg::OnBnClickedButton1()
// {
// // TODO: Add your control notification handler code here
//
// }
void CDvrClientPreviewDlg::OnBnClickedButton2()
{
// TODO: Add your control notification handler code here
char cFilename[256];
CTime time = CTime::GetCurrentTime();
sprintf(cFilename, "D:\\pic\\%dch%d%d%d%d%d%d%d.bmp", m_lRealPlayhandle ,
time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond(), GetTickCount());
if (m_lRealPlayhandle > -1)
{
HB_SDVR_CapturePicture(m_lRealPlayhandle,cFilename);
}
}
BOOL bClick;// 对话框类的成员变量,初始化为FALSE
CRect rc(0,0,::GetSystemMetrics(SM_CXFRAME),::GetSystemMetrics(SM_CYFRAME)); // 保存对话的屏蔽坐标区域,
void CDvrClientPreviewDlg::OnStnClickedStaticplaywindow()
{
// TODO: 在此添加控件通知处理程序代码
}
// 鼠标左键双击消息WM_LBUTTONDBLCLK消息响应函数
void CDvrClientPreviewDlg::OnLButtonDblClk(UINT nFlags, CPoint point)