// MiscPage.cpp : implementation file // #include "stdafx.h" #include "afxpriv.h" // afxpriv.h has WM_COMMANDHELP id //#include "CDP5Cfg.h" #include "MiscPageRes.h" #include "MiscPage.h" #include ".\MiscPage.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMiscPage property page IMPLEMENT_DYNCREATE(CMiscPage, CCfgPropPage) //#define IDD_MISC_PAGE 110 //CMiscPage::CMiscPage() : CCfgPropPage(CMiscPage::IDD) CMiscPage::CMiscPage() : CCfgPropPage("IDD_MISC_PAGE") { //{{AFX_DATA_INIT(CMiscPage) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT } CMiscPage::~CMiscPage() { } void CMiscPage::DoDataExchange(CDataExchange* pDX) { CCfgPropPage::DoDataExchange(pDX); //{{AFX_DATA_MAP(CMiscPage) //}}AFX_DATA_MAP DDX_Control(pDX, IDC_STATIC_MISC_PAGE, m_MiscPageLabel); DDX_Control(pDX, IDC_STATIC_MISC_ADVANCED, m_MiscAdvancedLabel); DDX_Control(pDX, IDC_STATIC_MISC_QUICKSET, m_MiscQuicksetLabel); } BEGIN_MESSAGE_MAP(CMiscPage, CCfgPropPage) //{{AFX_MSG_MAP(CMiscPage) //}}AFX_MSG_MAP ON_CBN_SELCHANGE(IDC_OPT_COMBO_DACO, OnCbnSelchangeOptComboDaco) ON_EN_CHANGE(IDC_OPT_TEXT_DACF, OnEnChangeOptTextDacf) ON_CBN_SELCHANGE(IDC_OPT_COMBO_SCOE, OnCbnSelchangeOptComboScoe) ON_CBN_SELCHANGE(IDC_OPT_COMBO_AUO1, OnCbnSelchangeOptComboAuo1) ON_CBN_SELCHANGE(IDC_OPT_COMBO_AUO2, OnCbnSelchangeOptComboAuo2) ON_CBN_SELCHANGE(IDC_OPT_COMBO_SCOT, OnCbnSelchangeOptComboScot) ON_CBN_SELCHANGE(IDC_OPT_COMBO_GPED, OnCbnSelchangeOptComboGped) ON_CBN_SELCHANGE(IDC_OPT_COMBO_GPIN, OnCbnSelchangeOptComboGpin) ON_CBN_SELCHANGE(IDC_OPT_COMBO_TPMO, OnCbnSelchangeOptComboTpmo) ON_CBN_SELCHANGE(IDC_OPT_COMBO_GPME, OnCbnSelchangeOptComboGpme) ON_CBN_SELCHANGE(IDC_OPT_COMBO_GPGA, OnCbnSelchangeOptComboGpga) ON_CBN_SELCHANGE(IDC_OPT_COMBO_GPMC, OnCbnSelchangeOptComboGpmc) ON_EN_CHANGE(IDC_OPT_TEXT_DACO, OnEnChangeOptTextDaco) ON_EN_CHANGE(IDC_OPT_TEXT_AUO1, OnEnChangeOptTextAuo1) ON_EN_CHANGE(IDC_OPT_TEXT_GPIN, OnEnChangeOptTextGpin) ON_MESSAGE(WM_SETPAGEFOCUS, OnSetPageFocus) ON_EN_CHANGE(IDC_OPT_TEXT_AUO2, OnEnChangeOptTextAuo2) ON_CBN_SELCHANGE(IDC_OPT_COMBO_SCOG, OnCbnSelchangeOptComboScog) ON_CBN_SELCHANGE(IDC_OPT_COMBO_VOLU, OnCbnSelchangeOptComboVolu) ON_CBN_SELCHANGE(IDC_OPT_COMBO_CON1, OnCbnSelchangeOptComboCon1) ON_CBN_SELCHANGE(IDC_OPT_COMBO_CON2, OnCbnSelchangeOptComboCon2) ON_BN_CLICKED(IDC_BUTTON_OUTPUT_QUICKSET1, OnBnClickedButtonOutputQuickset1) ON_BN_CLICKED(IDC_BUTTON_OUTPUT_QUICKSET2, OnBnClickedButtonOutputQuickset2) ON_BN_CLICKED(IDC_BUTTON_OUTPUT_QUICKSET3, OnBnClickedButtonOutputQuickset3) // SCA Editor ON_BN_CLICKED(IDC_CHECK_ENABLE_SCA, OnBnClickedCheckEnableSca) ON_CBN_SELCHANGE(IDC_COMBO_SCA_INDEX, OnCbnSelchangeComboScaIndex) ON_EN_CHANGE(IDC_EDIT_LOW_THRESHOLD, OnEnChangeEditLowThreshold) ON_EN_CHANGE(IDC_EDIT_HIGH_THRESHOLD, OnEnChangeEditHighThreshold) ON_CBN_SELCHANGE(IDC_COMBO_OUTPUT_LEVEL, OnCbnSelchangeComboOutputLevel) ON_BN_CLICKED(IDC_BUTTON_SCA_DEFAULTS, OnBnClickedButtonScaDefaults) ON_CBN_SELCHANGE(IDC_COMBO_SCA_PULSE_WIDTH, OnCbnSelchangeComboScaPulseWidth) ON_BN_CLICKED(IDC_BUTTON_PREVIEW_SCA, OnBnClickedButtonPreviewSca) ON_COMMAND(ID_HELP, OnHelp) ON_WM_HELPINFO() END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CMiscPage message handlers BOOL CMiscPage::OnSetActive() { // TODO: Add your specialized code here and/or call the base class if (s.ReloadCfg) { InitControls(); } if (s.FindCommand) { PostMessage(WM_SETPAGEFOCUS, 0, 0L); s.FindCommand = FALSE; } return CCfgPropPage::OnSetActive(); } LONG CMiscPage::OnSetPageFocus(UINT wParam, LONG lParam) { GetDlgItem(s.FindCtrlID)->SetFocus(); return 0; } BOOL CMiscPage::OnInitDialog() { CCfgPropPage::OnInitDialog(); BuildToolTips(); m_MiscPageLabel .SetFontName("Arial") .SetFontSize(24) .SetTextColor(RGB(0,0,255)) .SetBkColor(RGB(244, 243, 238)) .SetFontItalic(TRUE) .SetFontBold(TRUE); m_MiscAdvancedLabel .SetFontName("Arial") .SetFontSize(18) .SetTextColor(RGB(0, 70, 213)) .SetBkColor(RGB(250, 251, 251)) .SetFontItalic(TRUE) .SetFontBold(FALSE); m_MiscQuicksetLabel .SetFontName("Arial") .SetFontSize(18) .SetTextColor(RGB(0, 70, 213)) .SetBkColor(RGB(252, 252, 253)) .SetFontItalic(TRUE) .SetFontBold(FALSE); InitControls(); // TODO: Add extra initialization here return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } //dciDACF DACF 0 IDC_OPT_TEXT_DACF dctTxt dcgMisc DAC Offset mV //dciDACO DACO IDC_OPT_COMBO_DACO IDC_OPT_TEXT_DACO dctCboTxt dcgMisc DAC Output //dciSCOE SCOE IDC_OPT_COMBO_SCOE 0 dctCbo dcgMisc Scope Trigger Edge //dciAUO1 AUO1 IDC_OPT_COMBO_AUO1 IDC_OPT_TEXT_AUO1 dctCboTxt dcgMisc AUX_OUT Selection //dciSCOT SCOT IDC_OPT_COMBO_SCOT 0 dctCbo dcgMisc Scope Trigger Position //dciGPED GPED IDC_OPT_COMBO_GPED 0 dctCbo dcgMisc G.P. Counter Edge //dciGPIN GPIN IDC_OPT_COMBO_GPIN IDC_OPT_TEXT_GPIN dctCboTxt dcgMisc G.P. Counter Input //dciTPMO TPMO IDC_OPT_COMBO_TPMO 0 dctCbo dcgMisc Test Pulser On/Off //dciGPME GPME IDC_OPT_COMBO_GPME 0 dctCbo dcgMisc G.P. Counter Uses MCA_EN? //dciGPGA GPGA IDC_OPT_COMBO_GPGA 0 dctCbo dcgMisc G.P. Counter Uses GATE? //dciGPMC GPMC IDC_OPT_COMBO_GPMC 0 dctCbo dcgMisc G.P. counter Cleared With MCA Counters? //dciAUO2 AUO2 IDC_OPT_COMBO_AUO2 IDC_OPT_TEXT_AUO2 dctCboTxt dcgMisc AUX_2 Selection //dciVOLU, VOLU IDC_OPT_COMBO_VOLU 0 dctCbo dcgMisc Speaker On/Off void CMiscPage::SetAuxList(int nAuxID, BOOL bNeedsNewAux) { CComboBox &cbAUOX = *(CComboBox *) GetDlgItem(nAuxID); // Test if the controls are already set // OLD Parameters //AUX1 #;ICR;PILEUP;MCSTB;ONESH;DETRES;MCAEN;PEAKH;SCA8; //AUX2 #;ICR;DIAG;PEAKH;ONESH;RTDOS;RTDREJ;LIVE;VETO; // NEW Parameters //AUX1 ICR;PILEUP;MCSTB;ONESH;DETRES;MCAEN;PEAKH;SCA8;RTDOS;RTDREJ;VETO;LIVE; //AUX2 ICR;PILEUP;MCSTB;ONESH;DETRES;MCAEN;PEAKH;SCA8;RTDOS;RTDREJ;VETO;LIVE;STREAM; if (bNeedsNewAux) { // AUX1 and AUX2 new controls cbAUOX.ResetContent(); cbAUOX.AddString("ICR"); cbAUOX.AddString("PILEUP"); cbAUOX.AddString("MCSTB"); cbAUOX.AddString("ONESH"); cbAUOX.AddString("DETRES"); cbAUOX.AddString("MCAEN"); cbAUOX.AddString("PEAKH"); cbAUOX.AddString("SCA8"); cbAUOX.AddString("RTDOS"); cbAUOX.AddString("RTDREJ"); cbAUOX.AddString("VETO"); cbAUOX.AddString("LIVE"); if (nAuxID == IDC_OPT_COMBO_AUO2) { cbAUOX.AddString("STREAM"); } cbAUOX.Clear(); } else { if (nAuxID == IDC_OPT_COMBO_AUO2) { //AUX2 old controls cbAUOX.ResetContent(); cbAUOX.AddString("#"); cbAUOX.AddString("ICR"); cbAUOX.AddString("DIAG"); cbAUOX.AddString("PEAKH"); cbAUOX.AddString("ONESH"); cbAUOX.AddString("RTDOS"); cbAUOX.AddString("RTDREJ"); cbAUOX.AddString("LIVE"); cbAUOX.AddString("VETO"); if (((s.DppConfig.Firmware == 0x66) && (s.DppConfig.Build >= 6)) || (s.DppConfig.Firmware > 0x66)) { cbAUOX.AddString("STREAM"); // STREAM for 6.06.06 and later } cbAUOX.Clear(); } else { //AUX1 old controls cbAUOX.ResetContent(); cbAUOX.AddString("#"); cbAUOX.AddString("ICR"); cbAUOX.AddString("PILEUP"); cbAUOX.AddString("MCSTB"); cbAUOX.AddString("ONESH"); cbAUOX.AddString("DETRES"); cbAUOX.AddString("MCAEN"); cbAUOX.AddString("PEAKH"); cbAUOX.AddString("SCA8"); cbAUOX.Clear(); } } } void CMiscPage::InitAuxControls() { BOOL bNeedsNewAux=FALSE; BOOL bHasNewAux=FALSE; BOOL bNeedsUpdate=FALSE; CString strRTDOS("RTDOS"); int nIndex=0; CComboBox &cbAUO1 = *(CComboBox *) GetDlgItem(IDC_OPT_COMBO_AUO1); //CComboBox &cbAUO2 = *(CComboBox *) GetDlgItem(IDC_OPT_COMBO_AUO2); if (((s.DppConfig.Firmware == 0x68) && (s.DppConfig.Build >= 2)) || (s.DppConfig.Firmware > 0x68)) { bNeedsNewAux=TRUE; // Needs new AUX controls } // Test if the controls are already set // OLD Parameters //AUX1 #;ICR;PILEUP;MCSTB;ONESH;DETRES;MCAEN;PEAKH;SCA8; //AUX2 #;ICR;DIAG;PEAKH;ONESH;RTDOS;RTDREJ;LIVE;VETO; // NEW Parameters //AUX1 ICR;PILEUP;MCSTB;ONESH;DETRES;MCAEN;PEAKH;SCA8;RTDOS;RTDREJ;VETO;LIVE; //AUX2 ICR;PILEUP;MCSTB;ONESH;DETRES;MCAEN;PEAKH;SCA8;RTDOS;RTDREJ;VETO;LIVE;STREAM; nIndex = cbAUO1.FindStringExact(nIndex, strRTDOS); if (nIndex != CB_ERR) { bHasNewAux=TRUE; } if (bNeedsNewAux != bHasNewAux) { bNeedsUpdate=TRUE; } if (bNeedsUpdate) { SetAuxList(IDC_OPT_COMBO_AUO1, bNeedsNewAux); SetAuxList(IDC_OPT_COMBO_AUO2, bNeedsNewAux); } } void CMiscPage::InitControls() { HWND hPage = this->GetSafeHwnd(); BOOL bEnableVOLU; BOOL bEnableCON1; BOOL bEnableCON2; InitAuxControls(); bEnableVOLU = (s.profile->device_type == dppPX5); GetDlgItem(IDC_OPT_COMBO_VOLU)->EnableWindow(bEnableVOLU); GetDlgItem(IDC_OPT_FRAME_VOLU)->EnableWindow(bEnableVOLU); bEnableCON1 = ((s.profile->device_type != dppDP5) && (s.profile->device_type != dppDP5X)); GetDlgItem(IDC_OPT_COMBO_CON1)->EnableWindow(bEnableCON1); GetDlgItem(IDC_OPT_FRAME_CON1)->EnableWindow(bEnableCON1); bEnableCON2 = ((s.profile->device_type != dppDP5) && (s.profile->device_type != dppDP5X)); GetDlgItem(IDC_OPT_COMBO_CON2)->EnableWindow(bEnableCON2); GetDlgItem(IDC_OPT_FRAME_CON2)->EnableWindow(bEnableCON2); InitDlgItem(hPage,s.m_DP5Cfg[dciDACF]); InitDlgItem(hPage,s.m_DP5Cfg[dciDACO]); InitDlgItem(hPage,s.m_DP5Cfg[dciSCOE]); InitDlgItem(hPage,s.m_DP5Cfg[dciAUO1]); InitDlgItem(hPage,s.m_DP5Cfg[dciAUO2]); InitDlgItem(hPage,s.m_DP5Cfg[dciSCOT]); InitDlgItem(hPage,s.m_DP5Cfg[dciGPED]); InitDlgItem(hPage,s.m_DP5Cfg[dciGPIN]); InitDlgItem(hPage,s.m_DP5Cfg[dciTPMO]); InitDlgItem(hPage,s.m_DP5Cfg[dciGPME]); InitDlgItem(hPage,s.m_DP5Cfg[dciGPGA]); InitDlgItem(hPage,s.m_DP5Cfg[dciGPMC]); InitDlgItem(hPage,s.m_DP5Cfg[dciSCOG]); InitDlgItem(hPage,s.m_DP5Cfg[dciVOLU]); InitDlgItem(hPage,s.m_DP5Cfg[dciCON1]); InitDlgItem(hPage,s.m_DP5Cfg[dciCON2]); CboUpdate(dciDACO); CboUpdate(dciSCOE); CboUpdate(dciAUO1); CboUpdate(dciAUO2); CboUpdate(dciSCOT); CboUpdate(dciGPED); CboUpdate(dciGPIN); CboUpdate(dciTPMO); CboUpdate(dciGPME); CboUpdate(dciGPGA); CboUpdate(dciGPMC); CboUpdate(dciSCOG); CboUpdate(dciVOLU); CboUpdate(dciCON1); CboUpdate(dciCON2); if (!s.SCAEnabled) { s.scafn.InitSCA(&s.sca, 8192); } SetCheckBOOL(IDC_CHECK_ENABLE_SCA, s.SCAEnabled); EnableScaControls(s.SCAEnabled); s.sca.CurIndex.Format("%d",1); // set to sca 1 on init 20110908 UpdateSCAControls(); //if (s.profile->device_type == dppMCA8000D) { // ShowMCA8000D_Controls(SW_HIDE); //} else { // ShowMCA8000D_Controls(SW_SHOW); //} } void CMiscPage::ShowMCA8000D_Controls(int iShowWin) { GetDlgItem(IDC_OPT_COMBO_DACO)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_COMBO_TPMO)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_FRAME_DACF)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_FRAME_DACO)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_FRAME_TPMO)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_LIMITS_DACF)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_LIMITS_DACO)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_TEXT_DACF)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_TEXT_DACO)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_UNITS_DACF)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_UNITS_DACO)->ShowWindow(iShowWin); GetDlgItem(IDC_STATIC_DAC_FRAME)->ShowWindow(iShowWin); GetDlgItem(IDC_BUTTON_OUTPUT_QUICKSET1)->ShowWindow(iShowWin); GetDlgItem(IDC_BUTTON_OUTPUT_QUICKSET2)->ShowWindow(iShowWin); GetDlgItem(IDC_BUTTON_OUTPUT_QUICKSET3)->ShowWindow(iShowWin); } void CMiscPage::InitDlgItem(HWND hDlg, DP5_CONFIGURATION cfg) { int cboDP5CtrlID = cfg.ListCtrlID; int txtDP5CtrlID = cfg.TextCtrlID; CString strVal = cfg.Setting; int idxList; CString strUnits; CString strLimits; if ((cfg.CtrlType & dctCbo) > 0) { // try to find list index for any combo CComboBox &cb = *(CComboBox *) GetDlgItem(cboDP5CtrlID); //idxList = s.CtrlUtil.FindCboIdx(hDlg,cboDP5CtrlID,strVal); idxList = s.CtrlUtil.FindCboIdxExact(hDlg,cboDP5CtrlID,strVal); // try exact first if (idxList == LB_ERR) { idxList = s.CtrlUtil.FindCboIdx(hDlg,cboDP5CtrlID,strVal); } if (idxList == LB_ERR) { // if (idxList != LB_ERR) we already found the value if ((cfg.CtrlType & dctTxt) > 0) { // if cbotxt must find mask, else set to 0 cfg.TextValue = cfg.Setting; // overwrite if currently editing idxList = s.CtrlUtil.FindCboIdx(hDlg,cboDP5CtrlID,"#"); if (idxList == LB_ERR) { // mask begins with + idxList = s.CtrlUtil.FindCboIdx(hDlg,cboDP5CtrlID,"+"); } if (idxList == LB_ERR) { // mask begins with - idxList = s.CtrlUtil.FindCboIdx(hDlg,cboDP5CtrlID,"-"); } if (idxList == LB_ERR) { // not found default to 0 idxList = 0; } } else { idxList = 0; // set to first item } } cb.SetCurSel(idxList); } if ((cfg.CtrlType & dctTxt) > 0) { if ((cfg.CtrlType & dctCbo) == 0) { // cbo update above if (cfg.Setting.GetLength() > 0) { cfg.TextValue = cfg.Setting; } } GetDlgItem(txtDP5CtrlID)->SetWindowText(cfg.TextValue); strUnits = cfg.Units; strLimits = cfg.Limits; switch (txtDP5CtrlID) { case IDC_OPT_TEXT_DACF: UNIT_INIT(DACF, strUnits); LIMIT_INIT(DACF, strLimits); break; case IDC_OPT_TEXT_DACO: UNIT_INIT(DACO, strUnits); LIMIT_INIT(DACO, strLimits); break; case IDC_OPT_TEXT_AUO1: UNIT_INIT(AUO1, strUnits); LIMIT_INIT(AUO1, strLimits); break; case IDC_OPT_TEXT_AUO2: UNIT_INIT(AUO2, strUnits); LIMIT_INIT(AUO2, strLimits); break; case IDC_OPT_TEXT_GPIN: UNIT_INIT(GPIN, strUnits); LIMIT_INIT(GPIN, strLimits); break; } } } // pass dci id to update combo control and display edit controls if any void CMiscPage::CboUpdate(int nID_dci) { CString strCboText; int nID; int CmdShow; nID = s.m_DP5Cfg[nID_dci].ListCtrlID; if (nID == NULL) { return; } CComboBox &cb = *(CComboBox *) GetDlgItem(nID); int idx = cb.GetCurSel(); if (idx > LB_ERR) { cb.GetLBText(idx,strCboText); s.m_DP5Cfg[nID_dci].ComboIndex = idx; s.m_DP5Cfg[nID_dci].ComboValue = strCboText; } else { return; } if (s.m_DP5Cfg[nID_dci].CtrlType == dctCboTxt) { if (strCboText.Find('#') >= 0) { CmdShow = SW_SHOW; } else { CmdShow = SW_HIDE; } switch (nID) { case IDC_OPT_COMBO_DACO: ALL_VIS(DACO, CmdShow); CBO_TEXT_VIS(DACO, (CmdShow!=0)); break; case IDC_OPT_COMBO_AUO1: ALL_VIS(AUO1, CmdShow); CBO_TEXT_VIS(AUO1, (CmdShow!=0)); break; case IDC_OPT_COMBO_AUO2: ALL_VIS(AUO2, CmdShow); CBO_TEXT_VIS(AUO2, (CmdShow!=0)); break; case IDC_OPT_COMBO_GPIN: ALL_VIS(GPIN, CmdShow); CBO_TEXT_VIS(GPIN, (CmdShow!=0)); break; } } SetModified(TRUE); } //CBO_TEXT_VIS(RESL, (CmdShow!=0)); //CboTextVis(IDC_OPT_COMBO_RESL,IDC_OPT_TEXT_RESL,(CmdShow!=0)); //void CboTextVis(int nIdCbox, int nIdEdit, BOOL isText); void CMiscPage::CboTextVis(int nIdCbox, int nIdEdit, BOOL isText) { UINT ddSize; RECT lpRect; CEdit* pEdit; CComboBox* pCombo; int btnSize = 20; pEdit = (CEdit*)GetDlgItem(nIdEdit); // cast to edit for rect pEdit->GetRect(&lpRect); // get rect ddSize = lpRect.right - lpRect.left; // save width if (isText) { GetDlgItem(nIdEdit)->ShowWindow(SW_SHOW); pCombo = (CComboBox*)GetDlgItem(nIdCbox); pCombo->GetWindowRect(&lpRect); ScreenToClient(&lpRect); //int ddSize1 = lpRect.right - lpRect.left; // save width //TRACE("Combo Edit %d\r\n",ddSize1); lpRect.right = lpRect.left + btnSize; pCombo->MoveWindow(&lpRect,TRUE); pCombo->SetDroppedWidth(ddSize + btnSize); } else { GetDlgItem(nIdEdit)->ShowWindow(SW_HIDE); // hide edit //TRACE("Edit %d\r\n",ddSize); pCombo = (CComboBox*)GetDlgItem(nIdCbox); // cast to combo pCombo->GetWindowRect(&lpRect); // get win size ScreenToClient(&lpRect); // adjust to screen //int ddSize2 = lpRect.right - lpRect.left; // save width //TRACE("Combo %d\r\n",ddSize2); lpRect.right = lpRect.left + ddSize + btnSize; // get restored combo size pCombo->MoveWindow(&lpRect,TRUE); // restore combo pCombo->SetDroppedWidth(ddSize); // restore combo } } // pass dci id to update combo control and display edit controls if any void CMiscPage::TextUpdate(int nID_dci) { CString strText; int nID; nID = s.m_DP5Cfg[nID_dci].TextCtrlID; if (nID == NULL) { return; } GetDlgItem(nID)->GetWindowText(strText); s.m_DP5Cfg[nID_dci].TextValue = strText; SetModified(TRUE); } void CMiscPage::OnCbnSelchangeOptComboDaco() { CboUpdate(dciDACO); } void CMiscPage::OnCbnSelchangeOptComboScoe() { CboUpdate(dciSCOE); } void CMiscPage::OnCbnSelchangeOptComboAuo1() { CboUpdate(dciAUO1); } void CMiscPage::OnCbnSelchangeOptComboAuo2() { CboUpdate(dciAUO2); } void CMiscPage::OnCbnSelchangeOptComboScot() { CboUpdate(dciSCOT); } void CMiscPage::OnCbnSelchangeOptComboGped() { CboUpdate(dciGPED); } void CMiscPage::OnCbnSelchangeOptComboGpin() { CboUpdate(dciGPIN); } void CMiscPage::OnCbnSelchangeOptComboTpmo() { CboUpdate(dciTPMO); } void CMiscPage::OnCbnSelchangeOptComboGpme() { CboUpdate(dciGPME); } void CMiscPage::OnCbnSelchangeOptComboGpga() { CboUpdate(dciGPGA); } void CMiscPage::OnCbnSelchangeOptComboGpmc() { CboUpdate(dciGPMC); } void CMiscPage::OnCbnSelchangeOptComboScog() { CboUpdate(dciSCOG); } void CMiscPage::OnCbnSelchangeOptComboVolu() { CboUpdate(dciVOLU); } void CMiscPage::OnCbnSelchangeOptComboCon1() { CboUpdate(dciCON1); } void CMiscPage::OnCbnSelchangeOptComboCon2() { CboUpdate(dciCON2); } void CMiscPage::OnEnChangeOptTextDacf() { TextUpdate(dciDACF); } void CMiscPage::OnEnChangeOptTextDaco() { TextUpdate(dciDACO); } void CMiscPage::OnEnChangeOptTextAuo1() { TextUpdate(dciAUO1); } void CMiscPage::OnEnChangeOptTextAuo2() { TextUpdate(dciAUO2); } void CMiscPage::OnEnChangeOptTextGpin() { TextUpdate(dciGPIN); } BOOL CMiscPage::PreTranslateMessage(MSG* pMsg) { // TODO: Add your specialized code here and/or call the base class //================================================================== MSG msg = *pMsg; if (msg.message == WM_MOUSEMOVE) { // Relay events to the tooltip control msg.hwnd = (HWND)m_ToolTip.SendMessage(TTM_WINDOWFROMPOINT, 0, (LPARAM)&msg.pt); CPoint pt = pMsg->pt; ::ScreenToClient(msg.hwnd, &pt); msg.lParam = MAKELONG(pt.x, pt.y); m_ToolTip.Activate(TRUE); // make sure tooltip is active m_ToolTip.RelayEvent(&msg); // Let the ToolTip process this message. } else if ( pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN ) { CWnd* pCurrent= GetFocus(); int ctrl = pCurrent->GetDlgCtrlID(); //if (ctrl == IDC_OPT_TEXT_MCST) { if (isCEditBox(ctrl)) { ::SendMessage(this->m_hWnd, WM_COMMAND, MAKEWPARAM(ctrl, EN_CHANGE), (LPARAM) m_hWnd); CWnd* pNext= pCurrent->GetNextWindow( GW_HWNDNEXT ); pMsg->wParam = VK_TAB; //if ( pNext != NULL ) { // if (pNext->GetDlgCtrlID() != IDOK ) { // pNext->SetFocus(); // return TRUE; // } //} } else if (isCComboBox(ctrl)) { CWnd* pNext= pCurrent->GetNextWindow( GW_HWNDNEXT ); pMsg->wParam = VK_TAB; } } //================================================================== return CCfgPropPage::PreTranslateMessage(pMsg); } //AUO2 BOOL CMiscPage::isCEditBox(int nID) { BOOL isEdit = FALSE; switch (nID) { case IDC_OPT_TEXT_DACF: isEdit = TRUE; break; case IDC_OPT_TEXT_DACO: isEdit = TRUE; break; case IDC_OPT_TEXT_AUO1: isEdit = TRUE; break; case IDC_OPT_TEXT_AUO2: isEdit = TRUE; break; case IDC_OPT_TEXT_GPIN: isEdit = TRUE; break; } return isEdit; } BOOL CMiscPage::isCComboBox(int nID) { BOOL isCombo = FALSE; switch (nID) { case IDC_OPT_COMBO_DACO: isCombo = TRUE; break; case IDC_OPT_COMBO_SCOE: isCombo = TRUE; break; case IDC_OPT_COMBO_AUO1: isCombo = TRUE; break; case IDC_OPT_COMBO_AUO2: isCombo = TRUE; break; case IDC_OPT_COMBO_SCOT: isCombo = TRUE; break; case IDC_OPT_COMBO_GPED: isCombo = TRUE; break; case IDC_OPT_COMBO_GPIN: isCombo = TRUE; break; case IDC_OPT_COMBO_TPMO: isCombo = TRUE; break; case IDC_OPT_COMBO_GPME: isCombo = TRUE; break; case IDC_OPT_COMBO_GPGA: isCombo = TRUE; break; case IDC_OPT_COMBO_GPMC: isCombo = TRUE; break; case IDC_OPT_COMBO_SCOG: isCombo = TRUE; break; case IDC_OPT_COMBO_VOLU: isCombo = TRUE; break; case IDC_OPT_COMBO_CON1: isCombo = TRUE; break; case IDC_OPT_COMBO_CON2: isCombo = TRUE; break; } return isCombo; } void CMiscPage::SetCboItem(int nID, CString strVal) { HWND hPage = this->GetSafeHwnd(); int cboDP5CtrlID = nID; int idxList; CComboBox &cb = *(CComboBox *) GetDlgItem(cboDP5CtrlID); idxList = s.CtrlUtil.FindCboIdxExact(hPage,cboDP5CtrlID,strVal); // try exact first if (idxList == LB_ERR) { idxList = s.CtrlUtil.FindCboIdx(hPage,cboDP5CtrlID,strVal); } if (idxList == LB_ERR) { // if (idxList != LB_ERR) we already found the value idxList = 0; // set to first item } cb.SetCurSel(idxList); } void CMiscPage::OutputQuickset(CString strDAC, CString strOutputOffset, CString strAUX2, CString strAUX1, CString strCONN1, CString strCONN2) { SetCboItem(IDC_OPT_COMBO_DACO, strDAC); OnCbnSelchangeOptComboDaco(); GetDlgItem(IDC_OPT_TEXT_DACF)->SetWindowText(strOutputOffset); OnEnChangeOptTextDacf(); SetCboItem(IDC_OPT_COMBO_AUO2, strAUX2); OnCbnSelchangeOptComboAuo2(); SetCboItem(IDC_OPT_COMBO_AUO1, strAUX1); OnCbnSelchangeOptComboAuo1(); SetCboItem(IDC_OPT_COMBO_CON1, strCONN1); OnCbnSelchangeOptComboCon1(); SetCboItem(IDC_OPT_COMBO_CON2, strCONN2); OnCbnSelchangeOptComboCon2(); } void CMiscPage::OnBnClickedButtonOutputQuickset1() { //1. Shaped Output: DAC=SHAPED, output offset=50 mV, AUX2 = ICR, AUX1 = SCA8, CONN1 = DAC, CONN2 = AUXOUT2 OutputQuickset("SHAPED", "50 mV", "ICR", "SCA8", "DAC", "AUXOUT2"); } void CMiscPage::OnBnClickedButtonOutputQuickset2() { //2. ADC Input: DAC=INPUT, output offset=0 mV, AUX2 = ICR, AUX1 = SCA8, CONN1 = DAC, CONN2 = AUXOUT2 OutputQuickset("INPUT", "0 mV", "ICR", "SCA8", "DAC", "AUXOUT2"); } void CMiscPage::OnBnClickedButtonOutputQuickset3() { //3. Pile-Up: DAC=FAST, output offset=50 mV, AUX2 = ICR, AUX1 = PILEUP, CONN1 = DAC, CONN2 = AUXOUT2 OutputQuickset("FAST", "50mV", "ICR", "PILEUP", "DAC", "AUXOUT2"); } //////////////////////////////////////////////////////////////////////////////////// // HtmlHelp for shared dialog // NOTE: shared dialogs use string type IDD, not global IDD BOOL CMiscPage::OnHelpInfo(HELPINFO* pHelpInfo) { CString strHelp; if (pHelpInfo->iContextType == HELPINFO_WINDOW) { if (pHelpInfo->dwContextId == 0) { ::HtmlHelp(this->GetSafeHwnd(), theApp.m_pszHelpFilePath, HH_HELP_CONTEXT, HIDD_MISC_PAGE); } else { // } } return true; } void CMiscPage::OnHelp() // enable property sheet help button help { ::HtmlHelp(this->GetSafeHwnd(), theApp.m_pszHelpFilePath, HH_HELP_CONTEXT, HIDD_MISC_PAGE); //SendMessage(WM_COMMANDHELP); // } //////////////////////////////////////////////////////////////////////////////////// void CMiscPage::BuildToolTips() { if (!m_ToolTip.Create(this)) { TRACE0("Unable to create ToolTip control\n"); } else { m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_AUO1), IDS_TT_AUX_1); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_AUO1), IDS_TT_AUX_1); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_TEXT_AUO1), IDS_TT_AUX_1); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_AUO1), IDS_TT_AUX_1); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_LIMITS_AUO1), IDS_TT_AUX_1); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_TEXT_AUO2), IDS_TT_AUX_2); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_AUO2), IDS_TT_AUX_2); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_AUO2), IDS_TT_AUX_2); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_AUO2), IDS_TT_AUX_2); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_LIMITS_AUO2), IDS_TT_AUX_2); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_CON1), IDS_TT_CONNECTOR_1); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_CON1), IDS_TT_CONNECTOR_1); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_CON2), IDS_TT_CONNECTOR_2); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_CON2), IDS_TT_CONNECTOR_2); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_DACF), IDS_TT_OUTPUT_OFFSET); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_LIMITS_DACF), IDS_TT_OUTPUT_OFFSET); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_TEXT_DACF), IDS_TT_OUTPUT_OFFSET); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_DACF), IDS_TT_OUTPUT_OFFSET); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_DACO), IDS_TT_ANALOG_OUT); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_TEXT_DACO), IDS_TT_ANALOG_OUT); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_LIMITS_DACO), IDS_TT_ANALOG_OUT); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_DACO), IDS_TT_ANALOG_OUT); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_DACO), IDS_TT_ANALOG_OUT); //m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_GPED), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_GPED), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_GPGA), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_GPGA), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_OPT_TEXT_GPIN), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_GPIN), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_GPIN), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_OPT_LIMITS_GPIN), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_GPIN), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_GPMC), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_GPMC), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_GPME), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_GPME), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_STATIC_MISC_PAGE), IDS_TT); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_SCOE), IDS_TT_SCOPE_COMMANDS); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_SCOE), IDS_TT_SCOPE_COMMANDS); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_SCOG), IDS_TT_SCOPE_COMMANDS); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_SCOG), IDS_TT_SCOPE_COMMANDS); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_SCOG), IDS_TT_SCOPE_COMMANDS); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_SCOT), IDS_TT_SCOPE_COMMANDS); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_SCOT), IDS_TT_SCOPE_COMMANDS); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_TPMO), IDS_TT_TEST_PULSER); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_TPMO), IDS_TT_TEST_PULSER); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_VOLU), IDS_TT_PX__SPEAKER); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_VOLU), IDS_TT_PX__SPEAKER); //m_ToolTip.AddTool(GetDlgItem(IDC_STATIC_MISC_ADVANCED), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_STATIC_MISC_BASIC), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_STATIC_MISC_QUICKSET), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_BUTTON_OUTPUT_QUICKSET1), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_BUTTON_OUTPUT_QUICKSET2), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_BUTTON_OUTPUT_QUICKSET3), IDS_TT); //m_ToolTip.AddTool(GetDlgItem(IDC_STATIC_MISC_STANDARD), IDS_TT); m_ToolTip.Activate(TRUE); m_ToolTip.SetMaxTipWidth(200); } } void CMiscPage::OnBnClickedCheckEnableSca() { s.SCAEnabled = GetCheckBOOL(IDC_CHECK_ENABLE_SCA); s.profile->SCAEnabled = s.SCAEnabled; // 20110810 sca support EnableScaControls(s.SCAEnabled); } void CMiscPage::OnCbnSelchangeComboScaIndex() { int iIndex; iIndex = GetComboIndex(IDC_COMBO_SCA_INDEX); iIndex++; s.sca.CurIndex.Format("%d",iIndex); UpdateSCAControls(); } void CMiscPage::OnEnChangeEditLowThreshold() { int iIndex; iIndex = atoi(s.sca.CurIndex); if ((iIndex < 1) || (iIndex > MAX_SCA_REGISTER)) { s.sca.CurIndex.Format("%d",1); } GetDlgItem(IDC_EDIT_LOW_THRESHOLD)->GetWindowText(s.sca.Low[iIndex - 1]); } void CMiscPage::OnEnChangeEditHighThreshold() { int iIndex; iIndex = atoi(s.sca.CurIndex); if ((iIndex < 1) || (iIndex > MAX_SCA_REGISTER)) { s.sca.CurIndex.Format("%d",1); } GetDlgItem(IDC_EDIT_HIGH_THRESHOLD)->GetWindowText(s.sca.High[iIndex - 1]); } void CMiscPage::OnCbnSelchangeComboOutputLevel() { int iIndex; iIndex = atoi(s.sca.CurIndex); if ((iIndex < 1) || (iIndex > MAX_SCA_REGISTER)) { s.sca.CurIndex.Format("%d",1); } s.sca.Output[iIndex - 1] = GetComboValue(IDC_COMBO_OUTPUT_LEVEL); } void CMiscPage::OnBnClickedButtonScaDefaults() { s.scafn.InitSCA(&s.sca, 8192); s.SCAEnabled = FALSE; SetCheckBOOL(IDC_CHECK_ENABLE_SCA, s.SCAEnabled); UpdateSCAControls(); EnableScaControls(s.SCAEnabled); } void CMiscPage::OnCbnSelchangeComboScaPulseWidth() { s.sca.PulseWidth = GetComboValue(IDC_COMBO_SCA_PULSE_WIDTH); } BOOL CMiscPage::GetCheckBOOL(int nID) { CButton *chkBox; BOOL isChecked; chkBox = (CButton *)GetDlgItem(nID); isChecked = (BOOL)chkBox->GetCheck(); return isChecked; } void CMiscPage::SetCheckBOOL(int nID, BOOL isChecked) { CButton *chkBox; chkBox = (CButton *)GetDlgItem(nID); chkBox->SetCheck(isChecked); } void CMiscPage::EnableScaControls(BOOL Enable, BOOL isVisible) { //SCA Enable CheckBox (DO NOT DISABLE) //EnableControl(IDC_CHECK_ENABLE_SCA, Enable, isVisible); //SCA Control Buttons EnableControl(IDC_BUTTON_SCA_DEFAULTS, Enable, isVisible); EnableControl(IDC_BUTTON_PREVIEW_SCA, Enable, isVisible); //SCA ComboBox Controls EnableControl(IDC_COMBO_OUTPUT_LEVEL, Enable, isVisible); EnableControl(IDC_COMBO_SCA_INDEX, Enable, isVisible); EnableControl(IDC_COMBO_SCA_PULSE_WIDTH, Enable, isVisible); //SCA Edit Controls EnableControl(IDC_EDIT_HIGH_THRESHOLD, Enable, isVisible); EnableControl(IDC_EDIT_LOW_THRESHOLD, Enable, isVisible); //SCA Static Controls EnableControl(IDC_STATIC_SCA_GROUP, Enable, isVisible); EnableControl(IDC_STATIC_SCA_INDEX, Enable, isVisible); EnableControl(IDC_STATIC_LOW_THRESHOLD, Enable, isVisible); EnableControl(IDC_STATIC_HIGH_THRESHOLD, Enable, isVisible); EnableControl(IDC_STATIC_OUTPUT_LEVEL, Enable, isVisible); EnableControl(IDC_STATIC_SCA_PULSE_WIDTH, Enable, isVisible); EnableControl(IDC_STATIC_CURRENT_SCA, Enable, isVisible); } void CMiscPage::EnableControl(int nID, BOOL Enable, BOOL isVisible) { GetDlgItem(nID)->EnableWindow(Enable); GetDlgItem(nID)->ShowWindow(isVisible); } void CMiscPage::UpdateSCAControls() { int iIndex; iIndex = atoi(s.sca.CurIndex); if (iIndex < 1) { s.sca.CurIndex.Format("%d",1); } GetDlgItem(IDC_STATIC_CURRENT_SCA)->SetWindowText("SCA " + s.sca.CurIndex); // display sca number //Set SCA ComboBox Controls SetSCAComboIndex(IDC_COMBO_OUTPUT_LEVEL, s.sca.Output[iIndex - 1]); SetSCAComboIndex(IDC_COMBO_SCA_INDEX, s.sca.CurIndex); SetSCAComboIndex(IDC_COMBO_SCA_PULSE_WIDTH, s.sca.PulseWidth); ////SCA Edit Controls GetDlgItem(IDC_EDIT_LOW_THRESHOLD)->SetWindowText(s.sca.Low[iIndex - 1]); GetDlgItem(IDC_EDIT_HIGH_THRESHOLD)->SetWindowText(s.sca.High[iIndex - 1]); } void CMiscPage::SetSCAComboIndex(int nID, CString strValue) { CComboBox* pCombo; int CurSel; int Count; pCombo = (CComboBox*)GetDlgItem(nID); CurSel = s.scafn.varValueToIndex(strValue); Count = pCombo->GetCount(); if ((CurSel < 0) || (CurSel >= Count)) { CurSel = 0; } pCombo->SetCurSel(CurSel); } int CMiscPage::GetComboIndex(int nID) { CComboBox* pCombo; int CurSel; pCombo = (CComboBox*)GetDlgItem(nID); CurSel = pCombo->GetCurSel(); if (CurSel == LB_ERR){ CurSel = 0; } return CurSel; } CString CMiscPage::GetComboValue(int nID) { CString strValue; CComboBox* pCombo = (CComboBox*)GetDlgItem(nID); pCombo->GetLBText(pCombo->GetCurSel(),strValue); return strValue; } void CMiscPage::OnBnClickedButtonPreviewSca() { CString strSCA; //strSCA = s.scafn.SCAStringALL(s.sca, TRUE); strSCA = s.scafn.SCAStringALLDisplay(s.sca); AfxMessageBox(strSCA); }