📄 devicelstdlg.cpp
字号:
// DeviceLstDlg.cpp : implementation file
//
#include "stdafx.h"
#include "gtmpeg.h"
#include "DeviceLstDlg.h"
#include "GridCtrl.h"
#include "Chunnel.h"
#include "GtMpegWnd.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
TCHAR *sLstTitle[]={"","位置","设备","防区","输出设备","端口","地址","通道"};
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
CDeviceLstDlg::CDeviceLstDlg(CMapDlg* pParent /*=NULL*/)
: CDialog(CDeviceLstDlg::IDD, (CWnd*)pParent)
{
//{{AFX_DATA_INIT(CDeviceLstDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pGridCtrl=NULL;
m_pParent=pParent;
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CDeviceLstDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDeviceLstDlg)
DDX_Control(pDX, IDC_LST_POS, m_cLstPos);
//}}AFX_DATA_MAP
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CDeviceLstDlg, CDialog)
//{{AFX_MSG_MAP(CDeviceLstDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
BOOL CDeviceLstDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CRect rect;
m_cLstPos.GetWindowRect(rect);
ScreenToClient(rect);
rect.bottom=rect.bottom-16;
m_pGridCtrl=new CGridCtrl;
m_pGridCtrl->SetRowResize(FALSE);
m_pGridCtrl->SetColumnResize(FALSE);
m_pGridCtrl->Create(rect,this,100);
m_pGridCtrl->SetFixedRowCount();
m_pGridCtrl->SetFixedColumnCount();
m_pGridCtrl->SetColumnCount(8);
int nColWidth[]={40,100,80,40,80,40,40,40};
m_pGridCtrl->SetRowHeight(0,15);
for (int col = 0; col < m_pGridCtrl->GetColumnCount(); col++)
{
GV_ITEM Item;
Item.mask = GVIF_TEXT|GVIF_FORMAT;
Item.row = 0;
Item.col = col;
Item.nFormat = DT_CENTER|DT_VCENTER|DT_WORDBREAK;
Item.szText=sLstTitle[col];
m_pGridCtrl->SetItem(&Item);
m_pGridCtrl->SetColumnWidth(col,nColWidth[col]);
}
UpdateGrid();
return TRUE;
}
void CDeviceLstDlg::OnOK()
{
CDialog::OnOK();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CDeviceLstDlg::UpdateGrid()
{
m_pGridCtrl->DeleteNonFixedRows();
CFileStatus Status;
CString sIniFile=GetAppPath()+"GTMap.Ini";
if (!CFile::GetStatus (sIniFile, Status))
{
MessageBox("没有发现"+sIniFile);
return;
}
int nRow=1;
GV_ITEM Item;
int nPosNums=0;
CString sSection,sKey,sIniFileName;
sIniFileName=GetAppPath()+"GTMap.Ini";
sSection="Map";
sKey="MapPoints";
char strRet[MAX_PATH];
for(int i=0;i<MAX_PATH;i++)
strRet[i]=0;
GetPrivateProfileString(sSection,sKey,"",strRet,MAX_PATH,sIniFileName);
CString sTmp=strRet;
nPosNums=StringToInt(sTmp);
int nIndex=0;
CGtMpegWnd *pWnd=(CGtMpegWnd *)theApp.m_pMainWnd;
CString strTmp[4];
strTmp[0]="无";
strTmp[1]="警号";
strTmp[2]="灯光";
strTmp[3]="其他";
for(i=0;i<nPosNums;i++)
{
CUIntArray Zones;
m_pParent->GetPosZones(i,Zones);
for(int m=0;m<Zones.GetSize();m++)
{
CString sCol[8];
sCol[0].Format("%d",nRow);
sCol[1]=m_pParent->GetPosCaption(i);
int nChunnel=m_pParent->GetChunnel(i);
CChunnel *pChunnel=pWnd->GetChunnel(nChunnel);
CZone *pZone=pChunnel->GetZone(Zones.GetAt(m)-1);
sCol[2]=g_sZoneType[pZone->m_nType];//GetZoneTxt();
sCol[3].Format("%d",pZone->GetSort()+1);
CSecondary *pSecondary=NULL;
if(pZone->GetBindSecondary()!=-1)
{
pSecondary=pChunnel->GetSecondary(pZone->GetBindSecondary());
sCol[4]=strTmp[pSecondary->m_nType];
sCol[5].Format("%d",pSecondary->GetSort()+1);
}
else
{
sCol[4]="";
sCol[5]="";
}
sCol[6].Format("%d",pChunnel->m_nSort);
sCol[7].Format("%d",pChunnel->m_nSort+1);
nIndex++;
m_pGridCtrl->InsertRow("", -1);
m_pGridCtrl->SetRowHeight(nRow,15);
for(int j=0;j<m_pGridCtrl->GetColumnCount();j++)
{
Item.mask = GVIF_TEXT|GVIF_FORMAT;
Item.row = nRow;
Item.col = j;
Item.nFormat = DT_LEFT|DT_VCENTER|DT_WORDBREAK;
Item.nEditFormat=0;
Item.szText.Format("%s",sCol[j]);
m_pGridCtrl->SetItem(&Item);
}
nRow++;
}
}
m_pGridCtrl->SetEditable(FALSE);
m_pGridCtrl->Invalidate();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -