📄 pictureshow.cpp
字号:
// PictureShow.cpp : implementation file
//
#include "stdafx.h"
#include "../resource.h"
#include "PictureShow.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPictureShow dialog
CPictureShow* CPictureShow::picshow = NULL;
CPictureShow::CPictureShow(CWnd* pParent /*=NULL*/)
: CDialog(CPictureShow::IDD, pParent)
{
//{{AFX_DATA_INIT(CPictureShow)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
picshow = this;
movNo = -1 ;
}
CPictureShow::~CPictureShow()
{
for (int i=0;i<x;i++)
{
if (pPicS[i] != NULL)
{
// pPicS[i]->DestroyWindow() ;
delete pPicS[i] ;
pPicS[i] = NULL ;
}
} // TODO: Add your message handler code here
}
void CPictureShow::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPictureShow)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPictureShow, CDialog)
//{{AFX_MSG_MAP(CPictureShow)
ON_WM_PAINT()
ON_WM_RBUTTONDOWN()
ON_COMMAND(ID_INSERTMENU_THANSDUCER, OnInsertmenuThansducer)
ON_COMMAND(ID_INSERTMENU_VIDICON, OnInsertmenuVidicon)
ON_COMMAND(ID_INSERTMENU_PC, OnInsertmenuPc)
ON_COMMAND(ID_INSERTMENU_CHOSE, OnInsertmenuChose)
ON_MESSAGE(WM_MY_MAPDELETE,OnDeleteAll)
ON_MESSAGE(WM_MY_SAVE,OnSave)
ON_MESSAGE(WM_MY_SHOWALL,OnShowAll)
ON_MESSAGE(WM_MY_DELETE,OnDelete)
ON_MESSAGE(WM_MY_MOVE,OnMove)
ON_MESSAGE(ELE_MAP_MSG_SENSOR_ALARM,OnAlarmSENSOR)
ON_MESSAGE(ELE_MAP_MSG_MOTION_ALARM,OnAlarmMOTION)
ON_MESSAGE(ELE_MAP_MSG_VLOST_ALARM,OnAlarmVLOST)
ON_MESSAGE(ELE_MAP_MSG_RECORD_ALARM,OnAlarmRECORD)
ON_WM_MOUSEMOVE()
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPictureShow message handlers
BOOL CPictureShow::Create(CWnd* pParentWnd)
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::Create(IDD, pParentWnd);
}
void CPictureShow::PostNcDestroy()
{
// TODO: Add your specialized code here and/or call the base class
CDialog::PostNcDestroy();
// delete this ;
}
void CPictureShow::OnPaint()
{
CPaintDC dc(this); // device context for painting
if(ShowPic(lpstrFile,(HWND)m_hWnd ,622,525))
{
strcpy(lpstrFile,strFile) ;
strcat(lpstrFile,"\\res\\background.jpg") ;
return ;
}
SendMessageToDescendants(WM_PAINT,0,0,TRUE,FALSE) ;
// TODO: Add your message handler code here
// Do not call CDialog::OnPaint() for painting messages
}
void CPictureShow::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call defaul
SetFocus();
ClientToScreen(&point);
CPoint pt(0, 0);
::GetCursorPos(&pt);
ScreenToClient (&pt);
px = pt.x-8 ;
py = pt.y-8 ;
CMenu Menu;
if (Menu.LoadMenu(IDM_INSERT_MENU))
{
CMenu* pSubMenu = Menu.GetSubMenu(0);
if (pSubMenu!=NULL)
{
pSubMenu->TrackPopupMenu(
TPM_LEFTALIGN | TPM_RIGHTBUTTON,
point.x, point.y, this);
}
}
}
void CPictureShow::OnInsertmenuPc()
{
char str1[250] ;
strcpy(str1,strFile) ;
strcat(str1,"\\res\\background.jpg") ;
CString str = str1 ;
if(lpstrFile == str)
return ;
// TODO: Add your command handler code here
CPcAddDlg dlg ;
jmp: if (dlg.DoModal() == IDOK)
{
for (int i=0;i<x;i++)
{
if (pPicS[i]->ip == dlg.ip &&
pPicS[i]->type == 1 )
{
AfxMessageBox(afx_box_7) ;
goto jmp ;
}
}
pPicS[x] = new CPicSmall(this) ;
pPicS[x]->Create(this) ;
pPicS[x]->no = x ;
pPicS[x]->ip = dlg.ip ;
pPicS[x]->port = dlg.m_port ;
pPicS[x]->channel = 0 ;
pPicS[x]->type = 1 ;
pPicS[x]->strFile = strFile ;
pPicS[x]->name = dlg.m_strName ;
strcpy(pPicS[x]->pPicString,strFile) ;
strcat(pPicS[x]->pPicString,"\\res\\pc.bmp") ;
pPicS[x]->MoveWindow(px,py,19,19) ;
pPicS[x]->ShowWindow(SW_SHOW) ;
DlgStr[x].picnum = 1 ;
DlgStr[x].pointx = px ;
DlgStr[x].pointy = py ;
DlgStr[x].ipAddr = dlg.ip ;
DlgStr[x].channelNo = 0;
DlgStr[x].portNo = dlg.m_port ;
memcpy(DlgStr[x].name,dlg.m_strName.GetBuffer(50),50) ;
memcpy(DlgStr[x].mapaddr,lpstrFile,200) ;
x++ ;
}
// pFixDlg->DestroyWindow() ;
// delete pFixDlg ;
// pFixDlg = NULL ;
}
void CPictureShow::OnInsertmenuVidicon()
{
// TODO: Add your command handler code here
char str1[250] ;
strcpy(str1,strFile) ;
strcat(str1,"\\res\\background.jpg") ;
CString str = str1 ;
if(lpstrFile == str)
return ;
CFixtureAddDlg dlg ;
jmp1: if (dlg.DoModal() == IDOK)
{
for (int i=0;i<x;i++)
{
if (pPicS[i]->ip == dlg.ip &&
pPicS[i]->channel == dlg.m_channelNum + 1 &&
pPicS[i]->type == 2 )
{
AfxMessageBox(afx_box_8) ;
goto jmp1 ;
}
}
pPicS[x] = new CPicSmall(this) ;
pPicS[x]->Create(this) ;
pPicS[x]->no = x ;
pPicS[x]->ip = dlg.ip ;
pPicS[x]->channel = dlg.m_channelNum + 1;
pPicS[x]->port = dlg.m_port ;
pPicS[x]->type = 2 ;
pPicS[x]->strFile = strFile ;
pPicS[x]->name = dlg.m_strName ;
strcpy(pPicS[x]->pPicString,strFile) ;
strcat(pPicS[x]->pPicString,"\\res\\photo1.bmp") ;
pPicS[x]->MoveWindow(px,py,19,19) ;
pPicS[x]->ShowWindow(SW_SHOW) ;
DlgStr[x].picnum = 2 ;
DlgStr[x].pointx = px ;
DlgStr[x].pointy = py ;
DlgStr[x].ipAddr = dlg.ip ;
DlgStr[x].portNo = dlg.m_port ;
DlgStr[x].channelNo = dlg.m_channelNum + 1;
memcpy(DlgStr[x].name,dlg.m_strName.GetBuffer(50),50) ;
memcpy(DlgStr[x].mapaddr,lpstrFile,200) ;
x++ ;
}
}
void CPictureShow::OnInsertmenuThansducer()
{
char str1[250] ;
strcpy(str1,strFile) ;
strcat(str1,"\\res\\background.jpg") ;
CString str = str1 ;
if(lpstrFile == str )
return ;
// TODO: Add your command handler code here
CFixtureAddDlg dlg ;
jmp2: if (dlg.DoModal() == IDOK)
{
for (int i=0;i<x;i++)
{
if (pPicS[i]->ip == dlg.ip &&
pPicS[i]->channel == dlg.m_channelNum + 1 &&
pPicS[i]->type == 3 )
{
AfxMessageBox(afx_box_9) ;
goto jmp2 ;
}
}
pPicS[x] = new CPicSmall(this) ;
pPicS[x]->Create(this) ;
pPicS[x]->no = x ;
pPicS[x]->ip = dlg.ip ;
pPicS[x]->port = dlg.m_port ;
pPicS[x]->channel = dlg.m_channelNum + 1;
pPicS[x]->type = 3 ;
pPicS[x]->strFile = strFile ;
pPicS[x]->name = dlg.m_strName ;
strcpy(pPicS[x]->pPicString,strFile) ;
strcat(pPicS[x]->pPicString,"\\res\\tantou.bmp") ;
pPicS[x]->MoveWindow(px,py,19,19) ;
pPicS[x]->ShowWindow(SW_SHOW) ;
DlgStr[x].picnum = 3 ;
DlgStr[x].pointx = px ;
DlgStr[x].pointy = py ;
DlgStr[x].ipAddr = dlg.ip ; ;
DlgStr[x].portNo = dlg.m_port ;
DlgStr[x].channelNo = dlg.m_channelNum + 1;
memcpy(DlgStr[x].name,dlg.m_strName.GetBuffer(50),50) ;
memcpy(DlgStr[x].mapaddr,lpstrFile,200) ;
x++ ;
}
}
void CPictureShow::OnInsertmenuChose()
{
// TODO: Add your command handler code here
}
void CPictureShow::OnDelete(WPARAM wParam, LPARAM lParam)
{
if((int)wParam > x-1)
{
return ;
}
DlgStr[wParam].picnum = DlgStr[x-1].picnum;
DlgStr[wParam].pointx = DlgStr[x-1].pointx ;
DlgStr[wParam].pointy = DlgStr[x-1].pointy ;
DlgStr[wParam].ipAddr = DlgStr[x-1].ipAddr ;
DlgStr[wParam].portNo = DlgStr[x-1].portNo ;
DlgStr[wParam].channelNo = DlgStr[x-1].channelNo ;
memset(DlgStr[wParam].name,0,50) ;
memcpy(DlgStr[wParam].name,DlgStr[x-1].name,50) ;
memset(DlgStr[wParam].mapaddr,0,200) ;
memcpy(DlgStr[wParam].mapaddr,DlgStr[x-1].mapaddr,200) ;
DlgStr[x-1].picnum = NULL ;
DlgStr[x-1].pointx = NULL ;
DlgStr[x-1].pointy = NULL ;
DlgStr[x-1].channelNo = NULL ;
DlgStr[x-1].portNo = NULL ;
DlgStr[x-1].ipAddr = NULL ;
memset(DlgStr[x-1].mapaddr,0,200) ;
memset(DlgStr[x-1].name,0,50) ;
// pPicS[wParam]->DestroyWindow() ;
// delete pPicS[wParam] ;
// pPicS[wParam] = NULL ;
pPicS[wParam] = pPicS[x-1] ;
pPicS[x-1]->no = wParam ;
x-- ;
}
void CPictureShow::OnSave(WPARAM wParam, LPARAM lParam)
{
FILE *fp ;
strcpy(str0,strFile) ;
strcat(str0,"\\data\\fixture.dat") ;
fp = fopen(str0,"wb") ;
fwrite(&DlgStr,sizeof(CDlgStruct),x,fp) ;
fclose(fp) ;
}
void CPictureShow::OnShowAll(WPARAM wParam, LPARAM lParam)
{
CString strmid ;
strmid = lpstrFile ;
for(int i=0;i<x;i++)
{
if (DlgStr[i].mapaddr == strmid)
{
pPicS[i]->ShowWindow(SW_SHOW) ;
}
else
{
pPicS[i]->ShowWindow(SW_HIDE) ;
}
}
}
BOOL CPictureShow::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
FILE *fp ;
strcpy(str0,strFile) ;
strcat(str0,"\\data\\fixture.dat") ;
fp = fopen(str0,"rb") ;
if (fp == NULL)
{
x = 0 ;
return TRUE ;
}
for (int i=0;i<400;i++)
{
fread(&DlgStr[i],sizeof(CDlgStruct),1,fp) ;
if (DlgStr[i].picnum<1 || DlgStr[i].picnum>3)
break ;
}
addrstr1 = strFile ;
addrstr1 += "\\res\\pc.bmp" ;
addrstr2 = strFile ;
addrstr2 += "\\res\\photo1.bmp" ;
addrstr3 = strFile ;
addrstr3 += "\\res\\tantou.bmp" ;
addrstr4 = strFile ;
addrstr4 += "\\res\\photo2.bmp" ;
addrstr5 = strFile ;
addrstr5 += "\\res\\alarm.bmp" ;
addrstr6 = strFile ;
addrstr6 += "\\res\\alarm.bmp" ;
addrstr7 = strFile ;
addrstr7 += "\\res\\motion.bmp" ;
addrstr8 = strFile ;
addrstr8 += "\\res\\vlost.bmp" ;
////////////////////////////
x = i ;
for (i=0;i<x;i++)
{
pPicS[i] = new CPicSmall(this) ;
pPicS[i]->Create(this) ;
pPicS[i]->no = i ;
pPicS[i]->ip = DlgStr[i].ipAddr ;
pPicS[i]->channel = DlgStr[i].channelNo ;
pPicS[i]->type = DlgStr[i].picnum ;
pPicS[i]->port = DlgStr[i].portNo ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -