MyOutput.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  1. // MyOutput.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "StoneU_HC_OCX.h"
  5. #include "MyOutput.h"
  6. #include "CurWin.h"
  7. #include "newclientDlg.h"
  8. #include "DecodeCardSDK.h"
  9. #include "MyOutput.h"
  10. #include "Global.h"
  11. #include "mdlProject.h"
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17. WORD m_iSubWndCreated = 0;
  18. extern void F_AddEvent(CString csEvent);
  19. extern HBRUSH hBrush;
  20. extern BOOL g_bShareSound;
  21. extern int g_nNetDelay;
  22. extern CNewclientDlg * g_pDlgMain[OCX_NUM_MAX];
  23. /////////////////////////////////////////////////////////////////////////////
  24. // CMyOutput dialog
  25. RECT g_ShowRect3;
  26. RECT g_MouseRect3;
  27. void CALLBACK DrawFun3(long nPort,HDC hDc,DWORD nUser)
  28. {
  29. ::DrawEdge(hDc, &g_ShowRect3, BDR_SUNKENOUTER, BF_RECT);
  30. SetBkMode(hDc, TRANSPARENT);
  31. }
  32. void CALLBACK RealDataCallBack(LONG lRealHandle, DWORD dwDataType, BYTE *pBuffer,DWORD dwBufSize,DWORD dwUser)
  33. {
  34. // TRACE("lRealHandle = %d dwUser = %d dwDataType = %d dwBufSize = %d", lRealHandle, dwUser, dwDataType, dwBufSize);
  35. }
  36. CMyOutput::CMyOutput(CWnd* pParent /*=NULL*/)
  37. : CDialog(CMyOutput::IDD, pParent)
  38. {
  39. //{{AFX_DATA_INIT(CMyOutput)
  40. // NOTE: the ClassWizard will add member initialization here
  41. //}}AFX_DATA_INIT
  42. m_bIsAutoSave = FALSE;
  43. }
  44. void CMyOutput::DoDataExchange(CDataExchange* pDX)
  45. {
  46. CDialog::DoDataExchange(pDX);
  47. //{{AFX_DATA_MAP(CMyOutput)
  48. // NOTE: the ClassWizard will add DDX and DDV calls here
  49. //}}AFX_DATA_MAP
  50. }
  51. BEGIN_MESSAGE_MAP(CMyOutput, CDialog)
  52. //{{AFX_MSG_MAP(CMyOutput)
  53. ON_WM_CREATE()
  54. ON_WM_CTLCOLOR()
  55. ON_WM_DESTROY()
  56. ON_WM_LBUTTONDBLCLK()
  57. ON_WM_LBUTTONDOWN()
  58. ON_WM_MOUSEMOVE()
  59. ON_WM_PAINT()
  60. ON_WM_RBUTTONDOWN()
  61. ON_WM_TIMER()
  62. ON_COMMAND(IDC_MENU_FRONTPAGE, OnMenuFrontpage)
  63. ON_COMMAND(IDC_MENU_NEXTPAGE, OnMenuNextpage)
  64. ON_COMMAND(IDC_MENU_PAUSECYCLE, OnMenuPausecycle)
  65. ON_COMMAND(IDC_MENU_SOUND, OnMenuSound)
  66. ON_COMMAND(IDC_MENU_MULTISCREEN, OnMenuMultiscreen)
  67. ON_WM_LBUTTONUP()
  68. //}}AFX_MSG_MAP
  69. ON_WM_ERASEBKGND()
  70. END_MESSAGE_MAP()
  71. /////////////////////////////////////////////////////////////////////////////
  72. // CMyOutput message handlers
  73. BOOL CMyOutput::OnInitDialog()
  74. {
  75. CDialog::OnInitDialog();
  76. // TODO: Add extra initialization here
  77. // m_iSubWndCreated = 0;
  78. m_dwDVRIP = 0;
  79. return TRUE; // return TRUE unless you set the focus to a control
  80. // EXCEPTION: OCX Property Pages should return FALSE
  81. }
  82. void CMyOutput::StartNet(PIP_INFO ipinfo)
  83. {
  84. //int nIndex = g_FunGetRecordIndex( m_csIP,m_iSubWndNumber );
  85. CNewclientDlg *pDlg = (CNewclientDlg *)this->GetParent();//g_pOCXCtrl[nIndex]->m_pDlgMain;//
  86. NET_DVR_CLIENTINFO playstru;
  87. char ipaddress[256];
  88. char multiipaddress[256];
  89. char user[100];
  90. char password[100];
  91. WORD iServerPort;
  92. CString sTemp;
  93. ZeroMemory(user,100);
  94. ZeroMemory(password,100);
  95. if(m_iPlayhandle != -1)
  96. {
  97. TRACE("NET_DVR_StopRealPlay m_iPlayhandle = %d", m_iPlayhandle);
  98. if(g_bShareSound)
  99. {
  100. NET_DVR_CloseSoundShare(m_iPlayhandle);
  101. }
  102. if(!NET_DVR_StopRealPlay(m_iPlayhandle))
  103. {
  104. TRACE("NET_DVR_StopRealPlay 失败 m_iPlayhandle = %d", m_iPlayhandle);
  105. }
  106. }
  107. m_bNeedjudge = FALSE;
  108. playstru.hPlayWnd = GetSafeHwnd();
  109. playstru.lChannel = ipinfo->m_iChannel;
  110. playstru.lLinkMode = ipinfo->m_dwProtocol;
  111. if(ipinfo->m_dwMultiIPvalue == 0)
  112. strcpy(multiipaddress,"");
  113. else
  114. sprintf(multiipaddress,"%s",ipinfo->m_csMultiIP);
  115. playstru.sMultiCastIP = multiipaddress;
  116. iServerPort = ipinfo->m_wServerport;
  117. //TRACE("StartNet");
  118. m_iPlayhandle = NET_DVR_RealPlay(ipinfo->m_lServerID, &playstru);
  119. if(m_iPlayhandle == -1)
  120. {
  121. DWORD dwErr = NET_DVR_GetLastError();
  122. sprintf(ipaddress,"%s",ipinfo->m_csIP);
  123. sTemp.Format("访问IP:%s 通道%d 连接启动失败 dwErr = %d",ipaddress,playstru.lChannel, dwErr);
  124. F_AddEvent(sTemp);
  125. TRACE(sTemp);
  126. }
  127. else
  128. {
  129. //TRACE("StartNet m_iPlayhandle = %d", m_iPlayhandle);
  130. switch(g_nNetDelay) {
  131. case 0:
  132. NET_DVR_SetPlayerBufNumber(m_iPlayhandle, 1);
  133. break;
  134. case 1:
  135. NET_DVR_SetPlayerBufNumber(m_iPlayhandle, 6);
  136. break;
  137. case 2:
  138. NET_DVR_SetPlayerBufNumber(m_iPlayhandle, 15);
  139. break;
  140. case 3:
  141. NET_DVR_SetPlayerBufNumber(m_iPlayhandle, 30);
  142. break;
  143. case 4:
  144. NET_DVR_SetPlayerBufNumber(m_iPlayhandle, 45);
  145. break;
  146. default:
  147. NET_DVR_SetPlayerBufNumber(m_iPlayhandle, 15);
  148. break;
  149. }
  150. //NET_DVR_SetPlayerBufNumber(m_iPlayhandle, 15);
  151. NET_DVR_ThrowBFrame(m_iPlayhandle,1);
  152. NET_DVR_SetRealDataCallBack(m_iPlayhandle, RealDataCallBack, m_iPlayhandle);
  153. m_csIP = ipinfo->m_csIP;
  154. m_dwDVRIP = ipinfo->m_dwIPvalue;
  155. m_lServerID = ipinfo->m_lServerID;
  156. m_iChannel = playstru.lChannel;
  157. m_bNeedjudge = TRUE;
  158. }
  159. //CNewclientDlg* mainwnd =(CNewclientDlg*) AfxGetMainWnd();
  160. m_iWindowNum = pDlg->WINDOWNUM;
  161. }
  162. void CMyOutput::StopNet()
  163. {
  164. //int nIndex = g_FunGetRecordIndex( m_csIP,m_iSubWndNumber );
  165. CNewclientDlg *pDlg = (CNewclientDlg *)this->GetParent();//g_pOCXCtrl[nIndex]->m_pDlgMain;//
  166. if(m_iPlayhandle != -1)
  167. {
  168. if(m_bFileSave)
  169. NET_DVR_StopSaveRealData(m_iPlayhandle);
  170. m_bFileSave = FALSE;
  171. if(!NET_DVR_StopRealPlay(m_iPlayhandle))
  172. {
  173. TRACE("NET_DVR_StopRealPlay 失败 m_iPlayhandle = %d", m_iPlayhandle);
  174. }
  175. //TRACE("NET_DVR_StopRealPlay");
  176. m_bNeedjudge = FALSE;
  177. invateframe();
  178. m_iPlayhandle = -1;
  179. pDlg->m_ClientParam.m_bPlaySound[m_iSubWndNumber] = FALSE;
  180. //CNewclientDlg* mainwnd = (CNewclientDlg*) AfxGetMainWnd();
  181. }
  182. }
  183. void CMyOutput::StartCard(PIP_INFO ipinfo)
  184. {
  185. NET_DVR_CARDINFO playstru;
  186. char ipaddress[256];
  187. char multiipaddress[256];
  188. char user[100];
  189. char password[100];
  190. WORD iServerPort;
  191. CString sTemp;
  192. ULONG ulMode = 0;
  193. ZeroMemory(user,100);
  194. ZeroMemory(password,100);
  195. if(m_iPlayhandle != -1)
  196. {
  197. if(!NET_DVR_StopRealPlay(m_iPlayhandle))
  198. {
  199. TRACE("NET_DVR_StopRealPlay 失败 m_iPlayhandle = %d", m_iPlayhandle);
  200. }
  201. }
  202. m_bNeedjudge = FALSE;
  203. playstru.lChannel = ipinfo->m_iChannel;
  204. playstru.lLinkMode = ipinfo->m_dwProtocol;
  205. if(ipinfo->m_dwMultiIPvalue == 0)
  206. strcpy(multiipaddress,"");
  207. else
  208. sprintf(multiipaddress,"%s",ipinfo->m_csMultiIP);
  209. playstru.sMultiCastIP = multiipaddress;
  210. iServerPort = ipinfo->m_wServerport;
  211. playstru.struDisplayPara.nLeft = m_display_para.nLeft;
  212. playstru.struDisplayPara.nTop = m_display_para.nTop;
  213. playstru.struDisplayPara.nWidth = m_display_para.nWidth;
  214. playstru.struDisplayPara.nHeight = m_display_para.nHeight;
  215. playstru.struDisplayPara.bToScreen = 1;
  216. playstru.struDisplayPara.bToVideoOut = 1;
  217. TRACE("使用解码卡");
  218. m_iPlayhandle = NET_DVR_RealPlay_Card(ipinfo->m_lServerID,&playstru,m_iSubWndNumber);
  219. if(m_iPlayhandle == -1)
  220. {
  221. sprintf(ipaddress,"%s",ipinfo->m_csIP);
  222. sTemp.Format("访问IP:%s 通道%d 连接启动失败",ipaddress,playstru.lChannel);
  223. F_AddEvent(sTemp);
  224. TRACE(sTemp);
  225. }
  226. else
  227. {
  228. switch(g_nNetDelay) {
  229. case 0:
  230. ulMode = 1;
  231. break;
  232. case 1:
  233. ulMode = 2;
  234. break;
  235. case 2:
  236. ulMode = 3;
  237. break;
  238. case 3:
  239. ulMode = 4;
  240. break;
  241. case 4:
  242. ulMode = 5;
  243. break;
  244. default:
  245. ulMode = 3;
  246. break;
  247. }
  248. HW_SetStreamOpenMode((HANDLE)m_iSubWndNumber, ulMode);
  249. NET_DVR_ThrowBFrame(m_iPlayhandle,1);
  250. m_csIP = ipinfo->m_csIP;
  251. m_dwDVRIP = ipinfo->m_dwIPvalue;
  252. m_lServerID = ipinfo->m_lServerID;
  253. m_iChannel = playstru.lChannel;
  254. m_bNeedjudge = TRUE;
  255. }
  256. }
  257. BOOL CMyOutput::DestroyWindow()
  258. {
  259. // TODO: Add your specialized code here and/or call the base class
  260. return CDialog::DestroyWindow();
  261. }
  262. BOOL CMyOutput::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
  263. {
  264. // TODO: Add your specialized code here and/or call the base class
  265. if ((nID == 2) || (nID == 1))
  266. return TRUE;
  267. return CDialog::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
  268. }
  269. int CMyOutput::OnCreate(LPCREATESTRUCT lpCreateStruct)
  270. {
  271. if (CDialog::OnCreate(lpCreateStruct) == -1 )
  272. return -1;
  273. // TODO: Add your specialized creation code here
  274. m_iSubWndNumber = m_iSubWndCreated++;
  275. m_iPlayhandle = -1;
  276. m_bPlaying = FALSE;
  277. m_bNeedjudge = FALSE;
  278. m_bFileSave = FALSE;
  279. return 0;
  280. }
  281. HBRUSH CMyOutput::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
  282. {
  283. HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
  284. //int nIndex = g_FunGetRecordIndex( m_csIP,m_iSubWndNumber );
  285. CNewclientDlg *pDlg = (CNewclientDlg *)this->GetParent();//g_pOCXCtrl[nIndex]->m_pDlgMain;//
  286. // TODO: Change any attributes of the DC here
  287. if(pDlg->m_ClientParam.m_bUseCard)
  288. {
  289. NET_DVR_RestoreSurface_Card();
  290. return hBrush;
  291. }
  292. // TODO: Return a different brush if the default is not desired
  293. return hbr;
  294. }
  295. void CMyOutput::OnDestroy()
  296. {
  297. CDialog::OnDestroy();
  298. // TODO: Add your message handler code here
  299. }
  300. void CMyOutput::OnLButtonDblClk(UINT nFlags, CPoint point)
  301. {
  302. // TODO: Add your message handler code here and/or call default
  303. //int nIndex = g_FunGetRecordIndex( m_csIP,m_iSubWndNumber );
  304. CNewclientDlg *pDlg = (CNewclientDlg *)this->GetParent();//g_pOCXCtrl[nIndex]->m_pDlgMain;//
  305. pDlg->m_nActiveWndNumber = m_iSubWndNumber;
  306. if(m_iPlayhandle < 0)
  307. return;
  308. //CNewclientDlg* mainwnd =(CNewclientDlg*) AfxGetMainWnd();
  309. m_iWindowNum = pDlg->WINDOWNUM;
  310. if(pDlg->m_ClientParam.m_bFullScreen || pDlg->m_ClientParam.m_bMultiScreen)
  311. {
  312. pDlg->m_ClientParam.m_bFullScreen = FALSE;
  313. pDlg->m_ClientParam.m_bEnlarged = FALSE;
  314. pDlg->m_ClientParam.m_bMultiScreen = FALSE;
  315. NET_DVR_ThrowBFrame(m_iPlayhandle, 1);
  316. //pDlg->F_EndFullScreen();
  317. pDlg->ArrayWindow(pDlg->m_nActiveWndNumber,m_iWindowNum);
  318. pDlg->m_Mycurwin.ShowWindow(SW_SHOW);
  319. pDlg->MoveCurWin(m_iWindowNum,pDlg->m_nActiveWndNumber);
  320. return;
  321. }
  322. if( (pDlg->m_ClientParam.m_bEnlarged) || (m_iWindowNum == 1) )
  323. { //一个窗口或者窗口放大
  324. //pDlg->F_FullScreen();
  325. //MoveWindow(0, 0, 1024, 768, TRUE);
  326. //NET_DVR_ThrowBFrame(m_iPlayhandle, 0);
  327. //ShowWindow(SW_SHOW);
  328. //pDlg->m_ClientParam.m_bFullScreen = TRUE;
  329. }
  330. else
  331. { //多窗口
  332. NET_DVR_ThrowBFrame(m_iPlayhandle,0);
  333. m_iWindowNum = 1;
  334. pDlg->m_ClientParam.m_bEnlarged = TRUE;
  335. pDlg->ArrayWindow(pDlg->m_nActiveWndNumber,m_iWindowNum);
  336. pDlg->MoveCurWin(m_iWindowNum,pDlg->m_nActiveWndNumber);
  337. pDlg->m_ClientParam.m_bFullScreen = true;
  338. }
  339. if(!pDlg->m_ClientParam.m_bUseCard)
  340. {
  341. DWORD dwBright,dwContrast, dwSaturation, dwHue;
  342. dwBright = dwContrast = dwContrast = dwHue = 0;
  343. NET_DVR_ClientGetVideoEffect(m_iPlayhandle, &dwBright,&dwContrast, &dwSaturation, &dwHue);
  344. pDlg->m_ClientParam.m_VideoInfo[pDlg->m_nActiveWndNumber].m_iBrightness = dwBright;
  345. pDlg->m_ClientParam.m_VideoInfo[pDlg->m_nActiveWndNumber].m_iContrast = dwContrast;
  346. pDlg->m_ClientParam.m_VideoInfo[pDlg->m_nActiveWndNumber].m_iSaturation = dwSaturation;
  347. pDlg->m_ClientParam.m_VideoInfo[pDlg->m_nActiveWndNumber].m_iHue = dwHue;
  348. }
  349. CDialog::OnLButtonDblClk(nFlags, point);
  350. }
  351. void CMyOutput::OnLButtonDown(UINT nFlags, CPoint point)
  352. {
  353. // TODO: Add your message handler code here and/or call default
  354. //int nIndex = g_FunGetRecordIndex( m_csIP,m_iSubWndNumber );
  355. CNewclientDlg *pDlg = (CNewclientDlg *)this->GetParent();//g_pOCXCtrl[nIndex]->m_pDlgMain;//
  356. if(pDlg->m_nActiveWndNumber != m_iSubWndNumber)
  357. {
  358. pDlg->m_nActiveWndNumber = m_iSubWndNumber;
  359. pDlg->MoveCurWin(pDlg->WINDOWNUM, pDlg->m_nActiveWndNumber);
  360. pDlg->F_ShowVideoParams();
  361. if(!pDlg->m_ClientParam.m_bUseCard)
  362. {
  363. DWORD dwBright,dwContrast, dwSaturation, dwHue;
  364. dwBright = dwContrast = dwSaturation = dwHue = 0;
  365. NET_DVR_ClientGetVideoEffect(m_iPlayhandle, &dwBright,&dwContrast, &dwSaturation, &dwHue);
  366. pDlg->m_ClientParam.m_VideoInfo[pDlg->m_nActiveWndNumber].m_iBrightness = dwBright;
  367. pDlg->m_ClientParam.m_VideoInfo[pDlg->m_nActiveWndNumber].m_iContrast = dwContrast;
  368. pDlg->m_ClientParam.m_VideoInfo[pDlg->m_nActiveWndNumber].m_iSaturation = dwSaturation;
  369. pDlg->m_ClientParam.m_VideoInfo[pDlg->m_nActiveWndNumber].m_iHue = dwHue;
  370. }
  371. }
  372. if (MK_CONTROL&nFlags&&(m_iPlayhandle != -1))
  373. {
  374. NET_DVR_RigisterDrawFun(m_iPlayhandle, DrawFun3, 0);
  375. if (point.x < 0)
  376. point.x = 0;
  377. g_MouseRect3.left=point.x/16*16;
  378. if (point.y < 0)
  379. point.y = 0;
  380. g_MouseRect3.top=point.y/16*16;
  381. g_MouseRect3.right=g_MouseRect3.left;
  382. g_MouseRect3.bottom=g_MouseRect3.top;
  383. POINT tPoint=point;
  384. g_ShowRect3.left=tPoint.x/16*16;
  385. g_ShowRect3.top=tPoint.y/16*16;
  386. g_ShowRect3.right=tPoint.x/16*16+1;
  387. g_ShowRect3.bottom=tPoint.y/16*16+1;
  388. }
  389. CDialog::OnLButtonDown(nFlags, point);
  390. }
  391. void CMyOutput::OnMouseMove(UINT nFlags, CPoint point)
  392. {
  393. // TODO: Add your message handler code here and/or call default
  394. if ((MK_CONTROL&nFlags) && (MK_LBUTTON&nFlags) && (m_iPlayhandle != -1))
  395. {
  396. POINT tPoint=point;
  397. g_ShowRect3.right=tPoint.x/16*16;
  398. g_ShowRect3.bottom=tPoint.y/16*16;
  399. }
  400. CDialog::OnMouseMove(nFlags, point);
  401. }
  402. void CMyOutput::OnPaint()
  403. {
  404. CPaintDC dc(this); // device context for painting
  405. //int nIndex = g_FunGetRecordIndex( m_csIP,m_iSubWndNumber );
  406. CNewclientDlg *pDlg = (CNewclientDlg *)this->GetParent();//g_pOCXCtrl[nIndex]->m_pDlgMain;//
  407. // TODO: Add your message handler code here
  408. if(pDlg->m_ClientParam.m_bUseCard)
  409. NET_DVR_RestoreSurface_Card();
  410. // Do not call CDialog::OnPaint() for painting messages
  411. }
  412. void CMyOutput::OnRButtonDown(UINT nFlags, CPoint point)
  413. {
  414. return;
  415. CancelSelectZoom();
  416. // TODO: Add your message handler code here and/or call default
  417. CMenu m_PopMenu;
  418. //int nIndex = g_FunGetRecordIndex( m_csIP,m_iSubWndNumber );
  419. CNewclientDlg *pDlg = (CNewclientDlg *)this->GetParent();//g_pOCXCtrl[nIndex]->m_pDlgMain;//
  420. if(pDlg->m_nActiveWndNumber != m_iSubWndNumber)
  421. {
  422. pDlg->m_nActiveWndNumber = m_iSubWndNumber;
  423. pDlg->MoveCurWin(pDlg->WINDOWNUM, pDlg->m_nActiveWndNumber);
  424. pDlg->F_ShowVideoParams();
  425. if(!pDlg->m_ClientParam.m_bUseCard)
  426. {
  427. DWORD dwBright,dwContrast, dwSaturation, dwHue;
  428. dwBright = dwContrast = dwSaturation = dwHue = 0;
  429. NET_DVR_ClientGetVideoEffect(m_iPlayhandle, &dwBright,&dwContrast, &dwSaturation, &dwHue);
  430. pDlg->m_ClientParam.m_VideoInfo[pDlg->m_nActiveWndNumber].m_iBrightness = dwBright;
  431. pDlg->m_ClientParam.m_VideoInfo[pDlg->m_nActiveWndNumber].m_iContrast = dwContrast;
  432. pDlg->m_ClientParam.m_VideoInfo[pDlg->m_nActiveWndNumber].m_iSaturation = dwSaturation;
  433. pDlg->m_ClientParam.m_VideoInfo[pDlg->m_nActiveWndNumber].m_iHue = dwHue;
  434. }
  435. }
  436. if(pDlg->m_ClientParam.m_bFullScreen || pDlg->m_ClientParam.m_bMultiScreen)
  437. return;
  438. if(!m_PopMenu.LoadMenu(IDR_MENU1))
  439. return;
  440. ClientToScreen(&point);
  441. CMenu *psub = (CMenu *)m_PopMenu.GetSubMenu(0);
  442. psub->EnableMenuItem(0, MF_BYPOSITION | MF_DISABLED | MF_GRAYED);
  443. psub->EnableMenuItem(1, MF_BYPOSITION | MF_DISABLED | MF_GRAYED);
  444. psub->EnableMenuItem(2, MF_BYPOSITION | MF_DISABLED | MF_GRAYED);
  445. psub->EnableMenuItem(3, MF_BYPOSITION | MF_DISABLED | MF_GRAYED);
  446. if(pDlg->m_ClientParam.m_bCycling)
  447. {
  448. if(pDlg->m_ClientParam.m_bPaused)
  449. psub->ModifyMenu(0, MF_BYPOSITION, IDC_MENU_PAUSECYCLE, "开始循环");
  450. else
  451. psub->ModifyMenu(0, MF_BYPOSITION, IDC_MENU_PAUSECYCLE, "暂停循环");
  452. psub->EnableMenuItem(0, MF_BYPOSITION | MF_ENABLED);
  453. psub->EnableMenuItem(1, MF_BYPOSITION | MF_DISABLED | MF_GRAYED);
  454. psub->EnableMenuItem(2, MF_BYPOSITION | MF_DISABLED | MF_GRAYED);
  455. }
  456. else
  457. {
  458. if(pDlg->m_ClientParam.m_bNextPage)
  459. {
  460. psub->EnableMenuItem(0, MF_BYPOSITION | MF_DISABLED | MF_GRAYED);
  461. psub->EnableMenuItem(1, MF_BYPOSITION | MF_ENABLED);
  462. }
  463. if(pDlg->m_ClientParam.m_bFrontPage)
  464. {
  465. psub->EnableMenuItem(0, MF_BYPOSITION | MF_DISABLED | MF_GRAYED);
  466. psub->EnableMenuItem(2, MF_BYPOSITION | MF_ENABLED);
  467. }
  468. }
  469. //
  470. {
  471. if(pDlg->m_ClientParam.m_bPlaySound[pDlg->m_nActiveWndNumber])
  472. psub->ModifyMenu(3, MF_BYPOSITION, IDC_MENU_SOUND, "关闭声音");
  473. else
  474. psub->ModifyMenu(3, MF_BYPOSITION, IDC_MENU_SOUND, "打开声音");
  475. psub->EnableMenuItem(3, MF_BYPOSITION | MF_ENABLED);
  476. }
  477. psub->EnableMenuItem(4, MF_BYPOSITION | MF_ENABLED);
  478. psub->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,point.x,point.y,this);
  479. m_PopMenu.DestroyMenu();
  480. CDialog::OnRButtonDown(nFlags, point);
  481. }
  482. void CMyOutput::OnTimer(UINT nIDEvent)
  483. {
  484. // TODO: Add your message handler code here and/or call default
  485. CDialog::OnTimer(nIDEvent);
  486. }
  487. void CMyOutput::OnMenuFrontpage()
  488. {
  489. // TODO: Add your command handler code here
  490. //int nIndex = g_FunGetRecordIndex( m_csIP,m_iSubWndNumber );
  491. CNewclientDlg *pDlg = (CNewclientDlg *)this->GetParent();//g_pOCXCtrl[nIndex]->m_pDlgMain;//
  492. pDlg->F_FrontPage();
  493. }
  494. void CMyOutput::OnMenuNextpage()
  495. {
  496. // TODO: Add your command handler code here
  497. //int nIndex = g_FunGetRecordIndex( m_csIP,m_iSubWndNumber );
  498. CNewclientDlg *pDlg = (CNewclientDlg *)this->GetParent();//g_pOCXCtrl[nIndex]->m_pDlgMain;//
  499. pDlg->F_NextPage();
  500. }
  501. void CMyOutput::OnMenuPausecycle()
  502. {
  503. // TODO: Add your command handler code here
  504. //int nIndex = g_FunGetRecordIndex( m_csIP,m_iSubWndNumber );
  505. CNewclientDlg *pDlg = (CNewclientDlg *)this->GetParent();//g_pOCXCtrl[nIndex]->m_pDlgMain;//
  506. pDlg->F_CyclePause();
  507. }
  508. void CMyOutput::OnMenuSound()
  509. {
  510. // TODO: Add your command handler code here
  511. //int nIndex = g_FunGetRecordIndex( m_csIP,m_iSubWndNumber );
  512. CNewclientDlg *pDlg = (CNewclientDlg *)this->GetParent();//g_pOCXCtrl[nIndex]->m_pDlgMain;//
  513. int i;
  514. WORD wTemp;
  515. WORD wVolumevalue;
  516. wTemp = (0xFFFF) / 100;
  517. wVolumevalue = 50 * wTemp;
  518. if(pDlg->m_MyOutput[pDlg->m_nActiveWndNumber].m_iPlayhandle >= 0)
  519. {
  520. if(pDlg->m_ClientParam.m_bUseCard)
  521. {
  522. if(pDlg->m_ClientParam.m_bPlaySound[pDlg->m_nActiveWndNumber])
  523. {
  524. NET_DVR_CloseSound_Card(pDlg->m_MyOutput[pDlg->m_nActiveWndNumber].m_iPlayhandle);
  525. pDlg->m_ClientParam.m_bPlaySound[pDlg->m_nActiveWndNumber] = FALSE;
  526. }
  527. else
  528. {
  529. NET_DVR_OpenSound_Card(pDlg->m_MyOutput[pDlg->m_nActiveWndNumber].m_iPlayhandle);
  530. NET_DVR_AudioPreview_Card(pDlg->m_MyOutput[pDlg->m_nActiveWndNumber].m_iPlayhandle, TRUE);
  531. NET_DVR_SetVolume_Card(pDlg->m_MyOutput[pDlg->m_nActiveWndNumber].m_iPlayhandle, wVolumevalue);
  532. pDlg->m_ClientParam.m_bPlaySound[pDlg->m_nActiveWndNumber] = TRUE;
  533. }
  534. }
  535. else
  536. {
  537. TRACE("Close Audio");
  538. if(!g_bShareSound)
  539. {
  540. NET_DVR_CloseSound();
  541. }
  542. if(pDlg->m_ClientParam.m_bPlaySound[pDlg->m_nActiveWndNumber])
  543. {
  544. TRACE("Close m_bPlaySound[%d] Sound", pDlg->m_nActiveWndNumber);
  545. pDlg->m_ClientParam.m_bPlaySound[pDlg->m_nActiveWndNumber] = FALSE;
  546. if(g_bShareSound)
  547. {
  548. NET_DVR_CloseSoundShare(pDlg->m_MyOutput[pDlg->m_nActiveWndNumber].m_iPlayhandle);
  549. }
  550. }
  551. else
  552. {
  553. TRACE("Open m_bPlaySound[%d] = TRUE Sound", pDlg->m_nActiveWndNumber);
  554. pDlg->m_ClientParam.m_bPlaySound[pDlg->m_nActiveWndNumber] = TRUE;
  555. if(g_bShareSound)
  556. {
  557. if(!NET_DVR_OpenSoundShare(pDlg->m_MyOutput[pDlg->m_nActiveWndNumber].m_iPlayhandle))
  558. TRACE("Client Play Audio error");
  559. }
  560. else
  561. {
  562. if(!NET_DVR_OpenSound(pDlg->m_MyOutput[pDlg->m_nActiveWndNumber].m_iPlayhandle))
  563. TRACE("Client Play Audio error");
  564. }
  565. if(!NET_DVR_Volume(pDlg->m_MyOutput[pDlg->m_nActiveWndNumber].m_iPlayhandle, wVolumevalue))
  566. TRACE("Client Audio Volume error");
  567. }
  568. }
  569. if(!g_bShareSound)
  570. {
  571. for(i = 0; i < MAXVIEWNUM; i++)
  572. { //关闭别的窗口声音标志
  573. if(i == (int)pDlg->m_nActiveWndNumber)
  574. continue;
  575. pDlg->m_ClientParam.m_bPlaySound[i] = FALSE;
  576. }
  577. }
  578. }
  579. }
  580. void CMyOutput::OnMenuMultiscreen()
  581. {
  582. // TODO: Add your command handler code here
  583. if(m_iPlayhandle < 0)
  584. return;
  585. //int nIndex = g_FunGetRecordIndex( m_csIP,m_iSubWndNumber );
  586. CNewclientDlg *pDlg = (CNewclientDlg *)this->GetParent();//g_pOCXCtrl[nIndex]->m_pDlgMain;//
  587. //CNewclientDlg* mainwnd = (CNewclientDlg*) AfxGetMainWnd();
  588. pDlg->m_ClientParam.m_bMultiScreen = TRUE;
  589. pDlg->F_FullScreen();
  590. pDlg->ArrayWindow(pDlg->m_nActiveWndNumber,pDlg->WINDOWNUM);
  591. pDlg->MoveCurWin(pDlg->WINDOWNUM,pDlg->m_nActiveWndNumber);
  592. // StopNet();
  593. }
  594. void CMyOutput::invateframe()
  595. {
  596. //int nIndex = g_FunGetRecordIndex( m_csIP,m_iSubWndNumber );
  597. CNewclientDlg *pDlg = (CNewclientDlg *)this->GetParent();//g_pOCXCtrl[nIndex]->m_pDlgMain;//
  598. UpdateData(FALSE);
  599. if(pDlg->m_ClientParam.m_bUseCard)
  600. NET_DVR_RefreshSurface_Card();
  601. }
  602. void CMyOutput::OnLButtonUp(UINT nFlags, CPoint point)
  603. {
  604. // TODO: Add your message handler code here and/or call default
  605. //int nIndex = g_FunGetRecordIndex( m_csIP,m_iSubWndNumber );
  606. CNewclientDlg *pDlg = (CNewclientDlg *)this->GetParent();//g_pOCXCtrl[nIndex]->m_pDlgMain;//
  607. if ((MK_CONTROL&nFlags) && (m_iPlayhandle != -1))
  608. {
  609. POINT tPoint=point;
  610. g_ShowRect3.right=tPoint.x/16*16;
  611. g_ShowRect3.bottom=tPoint.y/16*16;
  612. NET_DVR_POINT_FRAME ptFrame;
  613. double scale = 1;
  614. if (pDlg->m_ClientParam.m_bFullScreen)
  615. {
  616. scale = 0.32;
  617. }
  618. else if (m_iWindowNum == 1)
  619. {
  620. scale = 0.5;
  621. }
  622. else if (m_iWindowNum == 9)
  623. {
  624. scale = 1.5;
  625. }
  626. else if (m_iWindowNum == 16)
  627. {
  628. scale = 2;
  629. }
  630. ptFrame.xTop = (int)(g_MouseRect3.left*2*scale);
  631. ptFrame.yTop = (int)(g_MouseRect3.top*2*scale);
  632. ptFrame.xBottom = (int)(g_ShowRect3.right*2*scale);
  633. ptFrame.yBottom = (int)(g_ShowRect3.bottom*2*scale);
  634. if (g_MouseRect3.left < g_ShowRect3.right)
  635. {
  636. if (g_MouseRect3.top < g_ShowRect3.bottom)
  637. {
  638. ptFrame.bCounter = 4;
  639. }
  640. else
  641. {
  642. ptFrame.bCounter = 2;
  643. }
  644. }
  645. else
  646. {
  647. if (g_MouseRect3.top < g_ShowRect3.bottom)
  648. {
  649. ptFrame.bCounter = 3;
  650. }
  651. else
  652. {
  653. ptFrame.bCounter = 1;
  654. }
  655. }
  656. if (!NET_DVR_PTZSelZoomIn(m_iPlayhandle, &ptFrame))
  657. {
  658. CString tmp;
  659. tmp.Format("Error: NET_DVR_PTZSelZoomIn = %d", NET_DVR_GetLastError());
  660. MessageBox(tmp, "温馨提示", MB_ICONINFORMATION);
  661. }
  662. CancelSelectZoom();
  663. }
  664. else
  665. {
  666. CancelSelectZoom();
  667. }
  668. CDialog::OnLButtonUp(nFlags, point);
  669. }
  670. void CMyOutput::CancelSelectZoom()
  671. {
  672. if (m_iPlayhandle != -1)
  673. {
  674. g_MouseRect3.top = 0;
  675. g_MouseRect3.left = 0;
  676. g_MouseRect3.right = 0;
  677. g_MouseRect3.bottom = 0;
  678. g_ShowRect3.top = 0;
  679. g_ShowRect3.left = 0;
  680. g_ShowRect3.right = 0;
  681. g_ShowRect3.bottom = 0;
  682. NET_DVR_RigisterDrawFun(m_iPlayhandle, NULL, 0);
  683. }
  684. }
  685. BOOL CMyOutput::OnEraseBkgnd(CDC* pDC)
  686. {
  687. // TODO: 在此添加消息处理程序代码和/或调用默认值
  688. CBrush brush;
  689. CRect rect, rect2;
  690. COLORREF rgbBackGnd = RGB( 0,0,0 ); // RGB( 59,61,63 );
  691. GetWindowRect(&rect);
  692. ScreenToClient(&rect);
  693. brush.CreateSolidBrush(rgbBackGnd);
  694. pDC->FillRect(rect,&brush);
  695. DeleteObject( brush );
  696. return true;
  697. //return CDialog::OnEraseBkgnd(pDC);
  698. }