123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- // GetCapture.cpp : implementation file
- //
- #include "stdafx.h"
- #include "StoneU_HC_OCX.h"
- #include "GetCapture.h"
- #include "MyOutput.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CGetCapture dialog
- extern CLIENTPARAM ClientParam;
- extern WORD iActiveWndNumber;
- extern CMyOutput myoutput[MAXVIEWNUM];
- //由于是无模式对话框,所以生成的对象要进行控制,最多一个!!!
- int CGetCapture::m_CaptureCount = 0;
- CGetCapture::CGetCapture(CWnd* pParent /*=NULL*/)
- : CDialog(CGetCapture::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CGetCapture)
- //}}AFX_DATA_INIT
- }
- CGetCapture::~CGetCapture()
- {
-
- }
- void CGetCapture::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CGetCapture)
- DDX_Control(pDX, IDC_JPEGSIZECOMBO, m_JpegSize);
- DDX_Control(pDX, IDC_JPEGQUALCOMBO, m_JpegQual);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CGetCapture, CDialog)
- //{{AFX_MSG_MAP(CGetCapture)
- ON_BN_CLICKED(IDC_CAPTURE, OnCapture)
- ON_BN_CLICKED(IDC_BMPRADIO, OnBmpradio)
- ON_BN_CLICKED(IDC_JPEGRADIO, OnJpegradio)
- ON_WM_CREATE()
- ON_WM_DESTROY()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CGetCapture message handlers
- BOOL CGetCapture::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: Add extra initialization here
- m_JpegSize.SetCurSel(0);
- m_JpegQual.SetCurSel(2);
- m_RadioState = FALSE;
- CheckRadioButton(IDC_BMPRADIO, IDC_JPEGRADIO, IDC_BMPRADIO);
- GetDlgItem(IDC_JPEGQUALCOMBO)->EnableWindow(FALSE);
- GetDlgItem(IDC_JPEGSIZECOMBO)->EnableWindow(FALSE);
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }
- void CGetCapture::OnCapture()
- {
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
- int i = iActiveWndNumber;
- if (myoutput[i].m_iPlayhandle < 0)
- {
- return;
- }
- if (m_RadioState) //JPEG
- {
- char cFilename[256];
- CString sTemp;
-
- CTime time = CTime::GetCurrentTime();
- sTemp.Format("%s\\", ClientParam.m_csPictureSavePath);
- if (GetFileAttributes(sTemp) != FILE_ATTRIBUTE_DIRECTORY)
- {
- CreateDirectory(sTemp, NULL);
- }
- long m_lServerID = myoutput[i].m_lServerID;
- int m_nChanNum = myoutput[i].m_iChannel;
- sprintf(cFilename, "%s\\JPEG_%02d_%4d%02d%02d_%02d%02d%02d_%d.jpg", ClientParam.m_csPictureSavePath, m_nChanNum, \
- time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond(), GetTickCount());
- TRACE("Picture save file name : %s", cFilename);
-
- NET_DVR_JPEGPARA JpegPara;
- JpegPara.wPicQuality = m_JpegQual.GetCurSel();
- JpegPara.wPicSize = m_JpegSize.GetCurSel();
- if (!ClientParam.m_bUseCard)
- {
- if (NET_DVR_CaptureJPEGPicture(m_lServerID, m_nChanNum, &JpegPara, cFilename))
- {
- CString sTemp;
- sTemp.Format("JPEG抓图成功 %s!", cFilename);
- MessageBox(sTemp, "温馨提示", MB_ICONINFORMATION);
- return;
- }
- else
- {
- MessageBox("JPEG抓图失败!", "温馨提示", MB_ICONINFORMATION);
- }
- }
- }
- else //BMP
- {
- char cFilename[256];
- CString sTemp;
- CTime time = CTime::GetCurrentTime();
- sTemp.Format("%s\\", ClientParam.m_csPictureSavePath);
- if(GetFileAttributes(sTemp) != FILE_ATTRIBUTE_DIRECTORY)
- {
- CreateDirectory(sTemp, NULL);
- }
- sprintf(cFilename, "%s\\Picture_%s_%02d_%4d%02d%02d_%02d%02d%02d_%d.bmp", ClientParam.m_csPictureSavePath, myoutput[i].m_csIP, myoutput[i].m_iChannel, \
- time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute(), time.GetSecond(), GetTickCount());
- TRACE("Picture save file name : %s", cFilename);
- if(ClientParam.m_bUseCard)
- {
- if(NET_DVR_CapturePicture_Card(myoutput[i].m_iPlayhandle, cFilename))
- {
- CString sTemp;
- sTemp.Format("Capture picture succeed %s!", cFilename);
- MessageBox(sTemp, "温馨提示", MB_ICONINFORMATION);
- return;
- }
- else
- {
- MessageBox("Failed to capture picture!", "温馨提示", MB_ICONINFORMATION);
- }
- }
- else
- {
- if(NET_DVR_CapturePicture(myoutput[i].m_iPlayhandle, cFilename))
- {
- CString sTemp;
- sTemp.Format("抓图成功 %s!",cFilename);
- MessageBox(sTemp, "温馨提示", MB_ICONINFORMATION);
- return;
- }
- else
- {
- MessageBox("抓图失败!", "温馨提示", MB_ICONINFORMATION);
- }
- }
- }
- }
- void CGetCapture::OnBmpradio()
- {
- // TODO: Add your control notification handler code here
- m_RadioState = FALSE;
- CheckRadioButton(IDC_BMPRADIO, IDC_JPEGRADIO, IDC_BMPRADIO);
- GetDlgItem(IDC_JPEGQUALCOMBO)->EnableWindow(FALSE);
- GetDlgItem(IDC_JPEGSIZECOMBO)->EnableWindow(FALSE);
- }
- void CGetCapture::OnJpegradio()
- {
- // TODO: Add your control notification handler code here
- m_RadioState = TRUE;
- CheckRadioButton(IDC_BMPRADIO, IDC_JPEGRADIO, IDC_JPEGRADIO);
- GetDlgItem(IDC_JPEGQUALCOMBO)->EnableWindow(TRUE);
- GetDlgItem(IDC_JPEGSIZECOMBO)->EnableWindow(TRUE);
- }
- int CGetCapture::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (CDialog::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- // TODO: Add your specialized creation code here
- m_CaptureCount ++;
- return 0;
- }
- void CGetCapture::OnCancel()
- {
- // TODO: Add extra cleanup here
- CDialog::OnCancel();
- DestroyWindow();
- }
- void CGetCapture::OnDestroy()
- {
- CDialog::OnDestroy();
-
- // TODO: Add your message handler code here
- m_CaptureCount --;
- }
- BOOL CGetCapture::IsExisted()
- {
- return m_CaptureCount;
- }
|