总结前段时间在VC6下使用MFC开发视频监控控件过程中遇到的一些问题.
1.获取控件当前所在路径,用于读取该目录下的INI配置文件
获取配置文件路径
- char m_ConfigIni[512];
- char szApp[512];
-
- GetModuleFileName(AfxGetInstanceHandle(), szApp, MAX_PATH);
-
- memcpy(m_ConfigIni, szApp, sizeof(szApp));
- m_ConfigIni[strrchr(m_ConfigIni, 0x5c) - m_ConfigIni+1] = 0;
- strcat(m_ConfigIni, "Config.ini");
-
- char path[512];
- GetPrivateProfileString("StorePath", "RecordPath", "D:\\DvrData"
- , path, 512, m_ConfigIni);
2.获取当前运行控件的电脑上的固定盘符列表,用于本地录像文件存放
获取固定盘符列表的函数
- char m_cHardDriver[26];
- int m_iDriverNum;
- BOOL F_GetSystemInfo();
-
-
-
- BOOL CWebPlayerApp::F_GetSystemInfo()
- {
- DWORD dw=GetLogicalDriveStrings(0, NULL);
- LPTSTR pAllDrivers=new char[dw];
- ::GetLogicalDriveStrings(dw, pAllDrivers);
- LPTSTR pDriver=pAllDrivers;
- char tempDriver[26];
- DWORD DriverNum=0;
- while(pDriver[0] != 0)
- {
- tempDriver[DriverNum++] = *pDriver;
- pDriver = _tcschr(pDriver,0) + 1;
- }
-
-
- TCHAR lpVolumeNameBuffer[200];
- DWORD dwVolumeSerialNumber, dwMaxComLength;
- DWORD dwFileSystemFlags;
- TCHAR lpFileSystemNameBuffer[50];
-
- DWORD HardNum=0;
- for(DWORD num=0; num < DriverNum; num++)
- {
- CString csRootPath;
- csRootPath.Format("%c%s", tempDriver[num], ":\\");
-
- if(GetDriveType(csRootPath) == DRIVE_FIXED)
- {
- if(GetVolumeInformation(csRootPath,lpVolumeNameBuffer,
- sizeof(lpVolumeNameBuffer), &dwVolumeSerialNumber,
- &dwMaxComLength, &dwFileSystemFlags,
- lpFileSystemNameBuffer, sizeof(lpFileSystemNameBuffer)))
- {
- this->m_cHardDriver[HardNum++]=tempDriver[num];
- }
- }
- }
- m_iDriverNum=HardNum;
- delete[] pAllDrivers;
-
- return TRUE;
- }
3.视频1,4,9,16路画面切换显示
较简单地实现,在窗体上拖16个STATIC控件(定义数组为panels),动态调整它们的位置大小即可,然后定义一个类如CPlayStatic去继承CStatic,每一个STATIC控件就由CPlayStatic管理;因为我们要在Static控件上添加鼠标,键盘事件处理,鼠标单击事件,选中该一播放面板时绘制绿色边框,可以很明显地看出当前是选中那一路视频播放窗体,同时恢复上一路选中边框为默认灰色边框;鼠标双击事件,实现视频浏览窗口的全屏功能(按多路预览-->单屏预览-->全屏-->单路浏览-->多路预览);右击菜单,对当前画面进行操作,如本地录像,语音对讲,抓图等操作;键盘事件处理,如该窗体当前正在预览按F2/F键进入全屏模式,按Esc退出全屏,恢复普通模式(需让该窗体获得焦点,处理KeyDown事件)
1,4,9,16路画面切换
- void CRealPlayDlg::ArrangeWindow()
- {
-
- int i=0, j=0, k=-1;
- switch (channelNum)
- {
- case 1:
-
-
- panels[0]->SetWindowPos(NULL,0,0,640,520,SWP_NOZORDER);
- panels[0]->ShowWindow(SW_SHOW);
-
-
- for (i=1; i<16; i++)
- {
- panels[i]->ShowWindow(SW_HIDE);
- }
- m_Expanded = true;
-
- break;
- case 4:
- panels[0]->MoveWindow(0,0,319,259);
- panels[0]->ShowWindow(SW_SHOW);
-
- panels[1]->MoveWindow(320,0,320,259);
- panels[1]->ShowWindow(SW_SHOW);
-
- panels[2]->MoveWindow(0,260,319,260);
- panels[2]->ShowWindow(SW_SHOW);
-
- panels[3]->MoveWindow(320,260,320,260);
- panels[3]->ShowWindow(SW_SHOW);
-
- for (i=4; i<16; i++)
- {
- panels[i]->ShowWindow(SW_HIDE);
- }
- m_Expanded=false;
-
- break;
- case 9:
- for (i=0; i<10; i++)
- {
- j = i % 3;
- if (j == 0)
- {
- k++;
- }
- panels[i]->SetWindowPos(NULL,j * 214,k * 174,213,173,SWP_NOZORDER);
- panels[i]->ShowWindow(SW_SHOW);
- }
- for (i=9; i<16; i++)
- {
- panels[i]->ShowWindow(SW_HIDE);
- }
- m_Expanded=false;
-
-
(peterzb)
|