296 lines
7.5 KiB
C++
296 lines
7.5 KiB
C++
// opcreatedmsdlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "geomative.h"
|
|
#include "opcreatedmsdlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
extern CGeoMativeApp theApp;
|
|
extern HHOOK hHook;
|
|
extern LRESULT __stdcall CBTHookProc(long nCode, WPARAM wParam, LPARAM lParam);
|
|
extern int g_iUILanguage;
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COpCreateDmsDlg dialog
|
|
|
|
|
|
COpCreateDmsDlg::COpCreateDmsDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(COpCreateDmsDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(COpCreateDmsDlg)
|
|
// NOTE: the ClassWizard will add member initialization here
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
|
|
COpCreateDmsDlg::COpCreateDmsDlg(INT_PTR* pRet, CWnd* pParent /*=NULL*/)
|
|
: CDialog(COpCreateDmsDlg::IDD, pParent)
|
|
{
|
|
m_pRet = pRet;
|
|
m_pParentWnd = NULL;
|
|
}
|
|
|
|
void COpCreateDmsDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(COpCreateDmsDlg)
|
|
DDX_Control(pDX, IDC_TREE_OP_DMS, m_dmsTree);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(COpCreateDmsDlg, CDialog)
|
|
//{{AFX_MSG_MAP(COpCreateDmsDlg)
|
|
ON_NOTIFY(TVN_SELCHANGING, IDC_TREE_OP_DMS, OnSelchangingTreeOpDms)
|
|
ON_NOTIFY(NM_CLICK, IDC_TREE_OP_DMS, OnClickTreeOpDms)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COpCreateDmsDlg message handlers
|
|
|
|
void COpCreateDmsDlg::OnSelchangingTreeOpDms(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
|
|
// TODO: Add your control notification handler code here
|
|
|
|
*pResult = 1;
|
|
}
|
|
|
|
void COpCreateDmsDlg::OnClickTreeOpDms(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
// TODO: Add your control notification handler code here
|
|
HTREEITEM hHitItem = NULL;
|
|
HTREEITEM hCurItem = NULL;
|
|
HTREEITEM hPreItem = NULL;
|
|
|
|
int iItemState = (int)VAL_ZERO;
|
|
int iSelItemState = (int)VAL_ZERO;
|
|
UINT uFlags = (UINT)VAL_ZERO;
|
|
POINT treePoint;
|
|
|
|
GetCursorPos(&treePoint);
|
|
treePoint = GetCurrentMessage()->pt;
|
|
|
|
m_dmsTree.ScreenToClient(&treePoint);
|
|
hHitItem = m_dmsTree.HitTest(treePoint, &uFlags);
|
|
m_dmsTree.ClientToScreen(&treePoint);
|
|
|
|
if (hHitItem != NULL)
|
|
{
|
|
|
|
if(uFlags & TVHT_ONITEMSTATEICON)
|
|
{
|
|
hCurItem = hHitItem;
|
|
|
|
//获取当前节点的最上层节点,并将上层节点信息存储在hPreItem
|
|
while (NULL != hCurItem)
|
|
{
|
|
hPreItem = hCurItem;
|
|
hCurItem = m_dmsTree.GetParentItem(hCurItem);
|
|
}
|
|
|
|
//如果hPreItem != hHitItem 则说明还有上层节点,GetCheck只能获取点击之前的状态
|
|
//如果下层节点的点击了,则需要将上层节点也设置为点击的状态
|
|
if ((hPreItem != hHitItem) && (m_dmsTree.GetCheck(hHitItem) == FALSE))
|
|
{
|
|
m_dmsTree.SetCheck(hPreItem, TRUE);
|
|
|
|
*pResult = 0;
|
|
return;
|
|
}
|
|
//如果下层节点取消点击,则需要遍历该层所有的兄弟节点,如果其它的也都是未点击状态
|
|
//则将上层节点取消点击,如果有其他兄弟节点是点击状态,则不取消上层节点的点击状态
|
|
else if ((hPreItem != hHitItem) && (m_dmsTree.GetCheck(hHitItem) == TRUE))
|
|
{
|
|
hCurItem = m_dmsTree.GetChildItem(hPreItem);
|
|
// MessageBox(m_dmsTree.GetItemText(hCurItem));
|
|
m_dmsTree.GetItemText(hCurItem);
|
|
while (NULL != hCurItem)
|
|
{
|
|
if ((m_dmsTree.GetCheck(hCurItem) == TRUE) && (hHitItem != hCurItem))
|
|
{
|
|
*pResult = 0;
|
|
return;
|
|
}
|
|
|
|
hCurItem = m_dmsTree.GetNextSiblingItem(hCurItem);
|
|
}
|
|
m_dmsTree.SetCheck(hPreItem, FALSE);
|
|
|
|
}
|
|
hCurItem = NULL;
|
|
//hPreItem == hHitItem则说明此时点击的是工程节点
|
|
if (hPreItem == hHitItem)
|
|
{
|
|
/*
|
|
m_dmsTree.GetItemImage(hHitItem, iItemState, iSelItemState);
|
|
|
|
if (PZ_STATE_LOC == iItemState)
|
|
{
|
|
if (m_dmsTree.GetCheck(hHitItem) == TRUE)
|
|
{
|
|
m_dmsTree.SetCheck(hHitItem, FALSE); //如果工程已经和设备关联,则不可取消
|
|
}
|
|
*pResult = 0;
|
|
return;
|
|
}
|
|
*/
|
|
//如果取消工程节点的点击,则将测区节点的点击状态也取消
|
|
if (m_dmsTree.GetCheck(hHitItem) == TRUE)
|
|
{
|
|
// m_dmsTree.SetCheck(hHitItem, FALSE);
|
|
hCurItem = m_dmsTree.GetChildItem(hHitItem);
|
|
while (hCurItem)
|
|
{
|
|
m_dmsTree.SetCheck(hCurItem, FALSE);
|
|
hCurItem = m_dmsTree.GetNextSiblingItem(hCurItem);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//此时将所有的子节点设置为点击状态
|
|
hCurItem = m_dmsTree.GetChildItem(hHitItem);
|
|
while (hCurItem)
|
|
{
|
|
m_dmsTree.SetCheck(hCurItem, TRUE);
|
|
hCurItem = m_dmsTree.GetNextSiblingItem(hCurItem);
|
|
}
|
|
|
|
// if (m_dmsTree.GetCheck(hHitItem) == FALSE)
|
|
// {
|
|
// m_dmsTree.SetCheck(hHitItem, TRUE);
|
|
// }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
*pResult = 0;
|
|
}
|
|
|
|
BOOL COpCreateDmsDlg::Create(UINT nID, CWnd* pParentWnd)
|
|
{
|
|
// TODO: Add your specialized code here and/or call the base class
|
|
this->m_pParentWnd = pParentWnd;
|
|
m_pParentWnd->EnableWindow(FALSE);
|
|
return CDialog::Create(IDD, m_pParentWnd);
|
|
}
|
|
|
|
void COpCreateDmsDlg::OnOK()
|
|
{
|
|
// TODO: Add extra validation here
|
|
//log
|
|
CString szLog = _T("");
|
|
FILE *pFile = NULL;
|
|
pFile = fopen("log\\AddTzInDev.txt", "ab");
|
|
szLog = "\r\nclick add test zone------------------------------------------\r\n";
|
|
fwrite(szLog.GetBuffer(0), 1, szLog.GetLength(),pFile);
|
|
fclose(pFile);
|
|
//log
|
|
|
|
HTREEITEM hProItem = NULL;
|
|
HTREEITEM hTzItem = NULL;
|
|
|
|
int iItemState = (int)VAL_ZERO;
|
|
int iSelItemState = (int)VAL_ZERO;
|
|
CString szCaption;
|
|
|
|
AfxGetMainWnd()->EnableWindow();
|
|
UpdateData(TRUE);
|
|
|
|
hProItem = this->m_dmsTree.GetRootItem();
|
|
while (NULL != hProItem)
|
|
{
|
|
m_dmsTree.GetItemImage(hProItem, iItemState, iSelItemState);
|
|
|
|
if ((m_dmsTree.GetCheck(hProItem) == TRUE) && (PZ_STATE_LOC != iItemState))
|
|
{
|
|
*m_pRet = 1;
|
|
EndModalLoop(*m_pRet);
|
|
return;
|
|
// CDialog::OnOK();
|
|
}
|
|
|
|
hTzItem = m_dmsTree.GetChildItem(hProItem);
|
|
while (NULL != hTzItem)
|
|
{
|
|
if (m_dmsTree.GetCheck(hTzItem) == TRUE)
|
|
{
|
|
*m_pRet = 1;
|
|
EndModalLoop(*m_pRet);
|
|
return;
|
|
// CDialog::OnOK();
|
|
}
|
|
hTzItem = m_dmsTree.GetNextSiblingItem(hTzItem);
|
|
}
|
|
|
|
hProItem = m_dmsTree.GetNextSiblingItem(hProItem);
|
|
}
|
|
|
|
szCaption.Empty();
|
|
szCaption.LoadString(IDS_OP_LC_DMS_NULL);
|
|
hHook = SetWindowsHookEx(WH_CBT,(HOOKPROC)CBTHookProc,AfxGetInstanceHandle(),NULL);
|
|
MessageBox(szCaption, NULL, MB_ICONEXCLAMATION);
|
|
|
|
//CDialog::OnOK();
|
|
}
|
|
|
|
void COpCreateDmsDlg::OnCancel()
|
|
{
|
|
// TODO: Add extra cleanup here
|
|
m_pParentWnd->EnableWindow();
|
|
*m_pRet = 2;
|
|
EndModalLoop(*m_pRet);
|
|
CDialog::OnCancel();
|
|
}
|
|
|
|
BOOL COpCreateDmsDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
// TODO: Add extra initialization here
|
|
m_dmsTree.ModifyStyle(0, TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | TVS_SHOWSELALWAYS | TVS_NOHSCROLL);
|
|
if (LANG_ZHCN == g_iUILanguage)
|
|
{
|
|
SetWindowText(_T("工程"));
|
|
GetDlgItem(IDC_STATIC_SEL_PRO_TO_DEV)->SetWindowText(_T("请选择需要下发到主机设备的工程"));
|
|
|
|
GetDlgItem(IDOK)->SetWindowText(_T("下发"));
|
|
GetDlgItem(IDCANCEL)->SetWindowText(_T("取消"));
|
|
}
|
|
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
BOOL COpCreateDmsDlg::DestroyWindow()
|
|
{
|
|
// TODO: Add your specialized code here and/or call the base class
|
|
OnCancel();
|
|
return CDialog::DestroyWindow();
|
|
}
|
|
|
|
BOOL COpCreateDmsDlg::PreTranslateMessage(MSG* pMsg)
|
|
{
|
|
// TODO: Add your specialized code here and/or call the base class
|
|
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_RETURN)
|
|
{
|
|
return TRUE;
|
|
}
|
|
|
|
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_ESCAPE)
|
|
{
|
|
return TRUE;
|
|
}
|
|
return CDialog::PreTranslateMessage(pMsg);
|
|
}
|