You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

256 lines
7.7 KiB
C++

#include "stdafx.h"
#include "MyDlgView.h"
#include "GlobalFunction.h"
#include "GlobalDrawMgr.h"
IMPLEMENT_DYNAMIC(CMyDlgView, CDialogEx)
BEGIN_MESSAGE_MAP(CMyDlgView, CDialogEx)
ON_WM_CTLCOLOR()
END_MESSAGE_MAP()
CMyDlgView *gChildPCS = NULL;
CMyDlgView *gChildWorkPrepare = NULL;
CMyDlgView *gChildWorkWaferCnt = NULL;
CMyDlgView *gChildRecipe = NULL;
CMyDlgView *gChildLaserPathState = NULL;
CMyDlgView *gChildLaserDeviceState = NULL;
CMyDlgView *gChildRobot = NULL;
CMyDlgView *gChildIOState = NULL;
CMyDlgView *gChildLaserPowCheck = NULL;
CMyDlgView *gChildDeviceMaintenance = NULL;
CMyDlgView *gChildSysParaSet = NULL;
CMyDlgView *gChildEventLog = NULL;
CMyDlgView *gChildWaferHistory = NULL;
CMyDlgView *gChildCheckHistory = NULL;
CMyDlgView *gDlgChildRealTimeDataHistory = NULL;
CMyDlgView *gDlgChildBeamDataHistory = NULL;
CMyDlgView *gDlgChildConfigHistory = NULL;
CMyDlgView *gDlgChildJobHistory = NULL;
CMyDlgView *gChildParaHistory = NULL;
CMyDlgView *gDlgChildLoginHistory = NULL;
CMyDlgView *gChildDataAnalysis = NULL;
CMyDlgView *gChildAlarmLog = NULL;
CMyDlgView *gChildPCS_WaferInfo = NULL;
CMyDlgView *gChildPCS_WaferTransfer = NULL;
CMyDlgView *gChildPCS_AnnealCh = NULL;
CMyDlgView::CMyDlgView(UINT nIDTemplate, CWnd* pParent /*=NULL*/)
: CDialogEx(nIDTemplate, pParent)
{
m_IDD = nIDTemplate;
m_pCurActiveView = NULL;//当前激活的view
m_bFirstOpen = true;//是否第一次打开
}
CMyDlgView::~CMyDlgView()
{
}
BOOL CMyDlgView::OnInitDialog()
{
CDialogEx::OnInitDialog();
SetTextCtrlItemID();
return TRUE;
}
void CMyDlgView::SetItemText(int ID,CString Str,bool bFillEdit)
{
//变化时才刷新,避免闪烁
if(IsDlgItemStrChange(ID,Str,m_DlgItemStrVec))
{
if(bFillEdit)
Str += " ";//把控件填满
GetDlgItem(ID)->SetWindowText(Str);
}
}
HBRUSH CMyDlgView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if(m_CtrlColorIDSet.count(pWnd->GetDlgCtrlID()))
{
CFont font;
font.CreatePointFont(gDraw->GetEditFontSize(),"Arial");
pDC->SelectObject(&font);
pDC->SetTextColor(gDraw->GetEditTextColor());//设置编辑框字体的颜色
//pDC-> SetBkMode(TRANSPARENT);//设置字体背景为透明
pDC->SetBkColor(gDraw->GetEditBkColor());//设置字体背景颜色
return (HBRUSH)::GetStockObject(RGB_BLACK);//这里必须是RGB_BLACK
}
return hbr;
}
//截获一部分键盘输入
BOOL CMyDlgView::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message==WM_KEYDOWN)
{
char c = pMsg->wParam;
if(c==VK_RETURN || c==VK_ESCAPE)
{
return TRUE;
}
}
//禁用鼠标右键
if( pMsg->message == WM_RBUTTONUP )
return TRUE;
return CDialogEx::PreTranslateMessage(pMsg);
}
CMyDlgView *CMyDlgView::GetChildView(EChildViewType ChildViewType)
{
CMyDlgView *pChildView = NULL;
switch(ChildViewType)
{
case _ChildView_PCS:
pChildView = gChildPCS;
break;
case _ChildView_WorkPrepare:
pChildView = gChildWorkPrepare;
break;
case _ChildView_WorkWaferCnt:
pChildView = gChildWorkWaferCnt;
break;
case _ChildView_Recipe:
pChildView = gChildRecipe;
break;
case _ChildView_LaserPathState:
pChildView = gChildLaserPathState;
break;
case _ChildView_LaserDeviceState:
pChildView = gChildLaserDeviceState;
break;
case _ChildView_Robot:
pChildView = gChildRobot;
break;
case _ChildView_IOState:
pChildView = gChildIOState;
break;
case _ChildView_DeviceMaintenance:
pChildView = gChildDeviceMaintenance;
break;
case _ChildView_LaserPowCheck:
pChildView = gChildLaserPowCheck;
break;
case _ChildView_SysParaSet:
pChildView = gChildSysParaSet;
break;
case _ChildView_EventLog:
pChildView = gChildEventLog;
break;
case _ChildView_WaferHistory:
pChildView = gChildWaferHistory;
break;
case _ChildView_CheckHistory:
pChildView = gChildCheckHistory;
break;
case _ChildView_RealTimeDataHistory:
pChildView = gDlgChildRealTimeDataHistory;
break;
case _ChildView_BeamDataHistory:
pChildView = gDlgChildBeamDataHistory;
break;
case _ChildView_ConfigHistory:
pChildView = gDlgChildConfigHistory;
break;
case _ChildView_JobHistory:
pChildView = gDlgChildJobHistory;
break;
case _ChildView_ParHistory:
pChildView = gChildParaHistory;
break;
case _ChildView_LoginHistory:
pChildView = gDlgChildLoginHistory;
break;
case _ChildView_DataAnalysis:
pChildView = gChildDataAnalysis;
break;
case _ChildView_PCS_WaferInfo:
pChildView = gChildPCS_WaferInfo;
break;
case _ChildView_PCS_WaferTransfer:
pChildView = gChildPCS_WaferTransfer;
break;
case _ChildView_PCS_AnnealCh:
pChildView = gChildPCS_AnnealCh;
break;
case _ChildView_AlarmLog:
pChildView = gChildAlarmLog;
break;
default:
break;
}
return pChildView;
}
//设置当前激活的view
void CMyDlgView::SetActiveView(EChildViewType ChildViewType)
{
//显示当前的view
CMyDlgView *pActiveView = GetChildView(ChildViewType);
if(pActiveView == m_pCurActiveView)
{
if(pActiveView != NULL)
{
//没有变化的时候也要刷新
pActiveView->OnViewOpen();
}
return;
}
//隐藏之前的
if(m_pCurActiveView != NULL)
{
m_pCurActiveView->ShowWindow(SW_HIDE);
}
if(pActiveView != NULL)
{
pActiveView->SetParent(this);
pActiveView->ShowWindow(SW_SHOW);
pActiveView->OnViewOpen();
// 设置位置
pActiveView->MoveWindow(m_rChildRect.left, m_rChildRect.top,m_rChildRect.right - m_rChildRect.left, m_rChildRect.bottom - m_rChildRect.top, TRUE);
}
m_pCurActiveView = pActiveView;
m_CurChildViewType = ChildViewType;
}
//展开树的所有节点
void CMyDlgView::ExpandTree(CTreeCtrl* pTreeCtrl,HTREEITEM hItem)
{
HTREEITEM hChild,hNext,hParent;
if((!hItem)||(!pTreeCtrl))
return;
//存在则展开节点
pTreeCtrl->Expand(hItem,TVE_EXPAND);
hChild = pTreeCtrl->GetNextItem(hItem,TVGN_CHILD);
if(hChild)
{//如果有子节点,展开子节点
ExpandTree(pTreeCtrl,hChild);
}
else
{//没有子节点,寻找其兄弟节点
hNext = pTreeCtrl->GetNextItem(hItem,TVGN_NEXT);
if(hNext)
{//存在兄弟节点
ExpandTree(pTreeCtrl,hNext);
}
else
{//不存在兄弟节点,继续找父节点
hParent = pTreeCtrl->GetParentItem(hItem);
hNext = pTreeCtrl->GetNextItem(hParent,TVGN_NEXT);
if(hNext)
ExpandTree(pTreeCtrl,hNext);
}
}
}