// McaPage.cpp : implementation file // #include "stdafx.h" #include "afxpriv.h" // afxpriv.h has WM_COMMANDHELP id #include "McaPageRes.h" #include "McaPage.h" #include ".\McaPage.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CMcaPage property page IMPLEMENT_DYNCREATE(CMcaPage, CCfgPropPage) //IDD_MCA_PAGE //#define IDD_MCA_PAGE 106 //CMcaPage::CMcaPage() : CCfgPropPage(IDD_MCA_PAGE) //CMcaPage::CMcaPage() : CCfgPropPage(CMcaPage::IDD) CMcaPage::CMcaPage() : CCfgPropPage("IDD_MCA_PAGE") { //{{AFX_DATA_INIT(CMcaPage) // NOTE: the ClassWizard will add member initialization here isDMcaControls = FALSE; //}}AFX_DATA_INIT } CMcaPage::~CMcaPage() { } void CMcaPage::DoDataExchange(CDataExchange* pDX) { CCfgPropPage::DoDataExchange(pDX); //{{AFX_DATA_MAP(CMcaPage) //}}AFX_DATA_MAP DDX_Control(pDX, IDC_STATIC_MCA_PAGE, m_McaPageLabel); DDX_Control(pDX, IDC_STATIC_MCA_ADVANCED, m_McaAdvancedLabel); DDX_Control(pDX, IDC_STATIC_MCA_STANDARD, m_McaStandardLabel); } BEGIN_MESSAGE_MAP(CMcaPage, CCfgPropPage) //{{AFX_MSG_MAP(CMcaPage) //}}AFX_MSG_MAP ON_CBN_SELCHANGE(IDC_OPT_COMBO_PRET, OnCbnSelchangeOptComboPret) ON_EN_CHANGE(IDC_OPT_TEXT_THSL, OnEnChangeOptTextThsl) ON_CBN_SELCHANGE(IDC_OPT_COMBO_MCAE, OnCbnSelchangeOptComboMcae) ON_CBN_SELCHANGE(IDC_OPT_COMBO_MCAC, OnCbnSelchangeOptComboMcac) ON_CBN_SELCHANGE(IDC_OPT_COMBO_GATE, OnCbnSelchangeOptComboGate) ON_CBN_SELCHANGE(IDC_OPT_COMBO_PREC, OnCbnSelchangeOptComboPrec) ON_CBN_SELCHANGE(IDC_OPT_COMBO_SOFF, OnCbnSelchangeOptComboSoff) ON_CBN_SELCHANGE(IDC_OPT_COMBO_PDMD, OnCbnSelchangeOptComboPdmd) ON_EN_CHANGE(IDC_OPT_TEXT_PRET, OnEnChangeOptTextPret) ON_EN_CHANGE(IDC_OPT_TEXT_PREC, OnEnChangeOptTextPrec) ON_EN_CHANGE(IDC_OPT_TEXT_MCST, OnEnChangeOptTextMcst) ON_EN_CHANGE(IDC_OPT_TEXT_SOFF, OnEnChangeOptTextSoff) ON_CBN_SELCHANGE(IDC_OPT_COMBO_MCAS, OnCbnSelchangeOptComboMcas) ON_EN_CHANGE(IDC_OPT_TEXT_MCSL, OnEnChangeOptTextMcsl) ON_EN_CHANGE(IDC_OPT_TEXT_MCSH, OnEnChangeOptTextMcsh) ON_EN_CHANGE(IDC_OPT_TEXT_PRCL, OnEnChangeOptTextPrcl) ON_EN_CHANGE(IDC_OPT_TEXT_PRCH, OnEnChangeOptTextPrch) ON_CBN_SELCHANGE(IDC_OPT_COMBO_PRER, OnCbnSelchangeOptComboPrer) ON_EN_CHANGE(IDC_OPT_TEXT_PRER, OnEnChangeOptTextPrer) ON_CBN_SELCHANGE(IDC_OPT_COMBO_PREL, OnCbnSelchangeOptComboPrel) ON_EN_CHANGE(IDC_OPT_TEXT_PREL, OnEnChangeOptTextPrel) ON_CBN_SELCHANGE(IDC_OPT_COMBO_TLLD, OnCbnSelchangeOptComboTlld) ON_EN_CHANGE(IDC_OPT_TEXT_TLLD, OnEnChangeOptTextTlld) ON_BN_CLICKED(IDC_PRESETCOUNTCURSORBUTTON, OnBnClickedPresetcountcursorbutton) ON_BN_CLICKED(IDC_PRESETCOUNTROIBUTTON, OnBnClickedPresetcountroibutton) ON_COMMAND(ID_HELP, OnHelp) ON_WM_HELPINFO() ON_CBN_SELCHANGE(IDC_OPT_COMBO_DMCA_GAIA, OnCbnSelchangeOptComboDmcaGaia) ON_CBN_SELCHANGE(IDC_OPT_COMBO_DMCA_PURE, OnCbnSelchangeOptComboDmcaPure) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CMcaPage message handlers BOOL CMcaPage::OnSetActive() { BOOL bIsDMCA_Ctrls = FALSE; BOOL bIsDMCA_Dev = FALSE; int DppType; //CString strDPP(""); //CString strDPP2(""); if (s.ReloadCfg) { InitControls(); } else { // reset DMCA controls if not matching device type DppType = s.profile->device_type; //strDPP.Format("DppType %d <-> Profile device_type %d\r\n",DppType,s.profile->device_type); //strDPP2 += strDPP; //AfxMessageBox(strDPP); bIsDMCA_Dev = FALSE; if (DppType == dppMCA8000D) { bIsDMCA_Dev = TRUE; } //bIsDMCA_Ctrls = GetDlgItem(IDC_OPT_FRAME_DMCA_GAIA)->IsWindowVisible(); bIsDMCA_Ctrls = isDMcaControls; //strDPP.Format("bIsDMCA_Dev %d <-> bIsDMCA_Ctrls %d\r\n",bIsDMCA_Dev,bIsDMCA_Ctrls); //strDPP2 += strDPP; //AfxMessageBox(strDPP2); if (bIsDMCA_Dev != bIsDMCA_Ctrls) { //strDPP = "InitControls\r\n"; //strDPP2 += strDPP; //AfxMessageBox("InitControls"); InitControls(); } //AfxMessageBox(strDPP2); } return CCfgPropPage::OnSetActive(); } BOOL CMcaPage::OnInitDialog() { CCfgPropPage::OnInitDialog(); BuildToolTips(); m_McaPageLabel .SetFontName("Arial") .SetFontSize(24) .SetTextColor(RGB(0,0,255)) .SetBkColor(RGB(244, 243, 238)) .SetFontItalic(TRUE) .SetFontBold(TRUE); m_McaAdvancedLabel .SetFontName("Arial") .SetFontSize(18) .SetTextColor(RGB(0, 70, 213)) .SetBkColor(RGB(248, 248, 246)) .SetFontItalic(TRUE) .SetFontBold(FALSE); m_McaStandardLabel .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 } //dciTHSL THSL 0 IDC_OPT_TEXT_THSL dctTxt dcgMCA Slow Threshhold % //dciMCAE MCAE IDC_OPT_COMBO_MCAE 0 dctCbo dcgMCA MCA Enable //dciMCAC MCAC IDC_OPT_COMBO_MCAC 0 dctCbo dcgMCA MCA/MCS Channels //dciGATE GATE IDC_OPT_COMBO_GATE 0 dctCbo dcgMCA Gate Control //dciPRET PRET IDC_OPT_COMBO_PRET IDC_OPT_TEXT_PRET dctCboTxt dcgMCA Preset Time S //dciPREC PREC IDC_OPT_COMBO_PREC IDC_OPT_TEXT_PREC dctCboTxt dcgMCA Preset Counts cnts //dciMCST MCST 0 IDC_OPT_TEXT_MCST dctTxt dcgMCA MCS Timebase S //dciSOFF SOFF IDC_OPT_COMBO_SOFF IDC_OPT_TEXT_SOFF dctCboTxt dcgMCA Set Spectrum Offset CH //dciMCAS MCAS IDC_OPT_COMBO_MCAS 0 dctCbo dcgBootOpt MCA Source //dciPDMD PDMD IDC_OPT_COMBO_PDMD 0 dctCbo dcgShaping Peak Detect Mode (Min/Max) void CMcaPage::InitControls() { HWND hPage = this->GetSafeHwnd(); BOOL bEnableGATE; int DppType; DppType = s.profile->device_type; bEnableGATE =((DppType == dppDP5) || (DppType == dppDP5X) || (DppType == dppMCA8000D)); CComboBox &cbMCAS = *(CComboBox *) GetDlgItem(IDC_OPT_COMBO_MCAS); CComboBox &cbPDMD = *(CComboBox *) GetDlgItem(IDC_OPT_COMBO_PDMD); // MCAS and PDMD have different values for MCA8000D if (DppType == dppMCA8000D) { GetDlgItem(IDC_OPT_FRAME_GATE)->SetWindowText("Gate 1"); if (cbMCAS.GetCount() != 2) { //NORM;MCS; cbMCAS.ResetContent(); cbMCAS.AddString("NORM"); cbMCAS.AddString("MCS"); cbMCAS.Clear(); } if (cbPDMD.GetCount() != 5) { //NORM;MIN;ABS;CLK;INT; cbPDMD.ResetContent(); cbPDMD.AddString("NORM"); cbPDMD.AddString("MIN"); cbPDMD.AddString("ABS"); cbPDMD.AddString("CLK"); cbPDMD.AddString("INT"); cbPDMD.Clear(); } } else { GetDlgItem(IDC_OPT_FRAME_GATE)->SetWindowText("Gate Control"); if (cbMCAS.GetCount() != 5) { // NORM;MCS;FAST;PUR;RTD; cbMCAS.ResetContent(); cbMCAS.AddString("NORM"); cbMCAS.AddString("MCS"); cbMCAS.AddString("FAST"); cbMCAS.AddString("PUR"); cbMCAS.AddString("RTD"); cbMCAS.Clear(); } if (cbPDMD.GetCount() != 2) { //NORM;MCS; cbPDMD.ResetContent(); cbPDMD.AddString("NORM"); cbPDMD.AddString("MIN"); cbPDMD.Clear(); } } GetDlgItem(IDC_OPT_FRAME_GATE)->EnableWindow(bEnableGATE); GetDlgItem(IDC_OPT_COMBO_GATE)->EnableWindow(bEnableGATE); InitDlgItem(hPage,s.m_DP5Cfg[dciTHSL]); InitDlgItem(hPage,s.m_DP5Cfg[dciMCAE]); InitDlgItem(hPage,s.m_DP5Cfg[dciMCAC]); InitDlgItem(hPage,s.m_DP5Cfg[dciGATE]); InitDlgItem(hPage,s.m_DP5Cfg[dciPRET]); InitDlgItem(hPage,s.m_DP5Cfg[dciPREC]); InitDlgItem(hPage,s.m_DP5Cfg[dciMCST]); InitDlgItem(hPage,s.m_DP5Cfg[dciSOFF]); InitDlgItem(hPage,s.m_DP5Cfg[dciMCAS]); InitDlgItem(hPage,s.m_DP5Cfg[dciMCSL]); InitDlgItem(hPage,s.m_DP5Cfg[dciMCSH]); InitDlgItem(hPage,s.m_DP5Cfg[dciPRCL]); InitDlgItem(hPage,s.m_DP5Cfg[dciPRCH]); InitDlgItem(hPage,s.m_DP5Cfg[dciPRER]); InitDlgItem(hPage,s.m_DP5Cfg[dciPDMD]); InitDlgItem(hPage,s.m_DP5Cfg[dciTLLD]); CboUpdate(dciPRET); CboUpdate(dciMCAE); CboUpdate(dciMCAC); CboUpdate(dciGATE); CboUpdate(dciPREC); CboUpdate(dciSOFF); CboUpdate(dciMCAS); CboUpdate(dciPRER); CboUpdate(dciPDMD); CboUpdate(dciTLLD); if (s.profile->device_type == dppMCA8000D) { ShowMCA8000D_Controls(SW_SHOW); InitDlgItemDMCA(hPage,s.m_DP5Cfg[dciGAIA],IDC_OPT_COMBO_DMCA_GAIA); InitDlgItemDMCA(hPage,s.m_DP5Cfg[dciPURE],IDC_OPT_COMBO_DMCA_PURE); CboUpdateDMCA(dciGAIA,IDC_OPT_COMBO_DMCA_GAIA); CboUpdateDMCA(dciPURE,IDC_OPT_COMBO_DMCA_PURE); InitDlgItem(hPage,s.m_DP5Cfg[dciSOFF]); CboUpdate(dciSOFF); InitDlgItem(hPage,s.m_DP5Cfg[dciPREL]); CboUpdate(dciPREL); } else { ShowMCA8000D_Controls(SW_HIDE); InitDlgItem(hPage,s.m_DP5Cfg[dciSOFF]); CboUpdate(dciSOFF); InitDlgItem(hPage,s.m_DP5Cfg[dciPRET]); CboUpdate(dciPRET); } } void CMcaPage::ShowMCA8000D_Controls(int iShowWin) { int iNotShowWin; if (iShowWin == SW_HIDE) { isDMcaControls = FALSE; iNotShowWin = SW_SHOW; } else { isDMcaControls = TRUE;; iNotShowWin = SW_HIDE; } GetDlgItem(IDC_OPT_FRAME_DMCA_GAIA)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_COMBO_DMCA_GAIA)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_FRAME_DMCA_PURE)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_COMBO_DMCA_PURE)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_FRAME_PREL)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_COMBO_PREL)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_TEXT_PREL)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_UNITS_PREL)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_LIMITS_PREL)->ShowWindow(iShowWin); GetDlgItem(IDC_OPT_FRAME_PRET)->ShowWindow(iNotShowWin); GetDlgItem(IDC_OPT_COMBO_PRET)->ShowWindow(iNotShowWin); GetDlgItem(IDC_OPT_TEXT_PRET)->ShowWindow(iNotShowWin); GetDlgItem(IDC_OPT_UNITS_PRET)->ShowWindow(iNotShowWin); GetDlgItem(IDC_OPT_LIMITS_PRET)->ShowWindow(iNotShowWin); //CString strIsSOFF_Move(""); //strIsSOFF_Move.Format("%d",iShowWin); //AfxMessageBox(strIsSOFF_Move); if (iShowWin) { //MoveCtrl(IDC_OPT_FRAME_SOFF, 0, -90); //MoveCtrl(IDC_OPT_COMBO_SOFF, 0, -90); //MoveCtrl(IDC_OPT_TEXT_SOFF, 0, -90); //MoveCtrl(IDC_OPT_UNITS_SOFF, 0, -90); //MoveCtrl(IDC_OPT_LIMITS_SOFF, 0, -90); MoveCtrlEx(IDC_OPT_FRAME_SOFF, IDC_OPT_FRAME_SOFF2, IDC_OPT_FRAME_SOFF2); MoveCtrlEx(IDC_OPT_COMBO_SOFF, IDC_OPT_COMBO_SOFF2, IDC_OPT_COMBO_SOFF2); MoveCtrlEx(IDC_OPT_TEXT_SOFF, IDC_OPT_TEXT_SOFF2, IDC_OPT_TEXT_SOFF2); MoveCtrlEx(IDC_OPT_UNITS_SOFF, IDC_OPT_UNITS_SOFF2, IDC_OPT_UNITS_SOFF2); MoveCtrlEx(IDC_OPT_LIMITS_SOFF, IDC_OPT_LIMITS_SOFF2, IDC_OPT_LIMITS_SOFF2); } else { MoveCtrlEx(IDC_OPT_FRAME_SOFF, IDC_OPT_FRAME_SOFF3, IDC_OPT_FRAME_SOFF3); MoveCtrlEx(IDC_OPT_COMBO_SOFF, IDC_OPT_COMBO_SOFF3, IDC_OPT_COMBO_SOFF3); MoveCtrlEx(IDC_OPT_TEXT_SOFF, IDC_OPT_TEXT_SOFF3, IDC_OPT_TEXT_SOFF3); MoveCtrlEx(IDC_OPT_UNITS_SOFF, IDC_OPT_UNITS_SOFF3, IDC_OPT_UNITS_SOFF3); MoveCtrlEx(IDC_OPT_LIMITS_SOFF, IDC_OPT_LIMITS_SOFF3, IDC_OPT_LIMITS_SOFF3); } } void CMcaPage::InitDlgItemDMCA(HWND hDlg, DP5_CONFIGURATION cfg, int cboDP5CtrlID) { CString strVal = cfg.Setting; int idxList; CString strUnits; CString strLimits; if ((cfg.CtrlType & dctCbo) > 0) { // try to find list index for any combo switch (cboDP5CtrlID) { case IDC_OPT_COMBO_DMCA_GAIA: // one plus the combobox index (1=1V,2=10V) idxList = atoi(strVal); idxList--; if ((idxList < 0) || (idxList > 1)) { idxList=0; } break; case IDC_OPT_COMBO_DMCA_PURE: //ON;OFF; 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 idxList = 0; // set to first item } break; } CComboBox &cb = *(CComboBox *) GetDlgItem(cboDP5CtrlID); cb.SetCurSel(idxList); } } // MCA8000D special controls are not listed in the main control data structure // The DMCA controls moved to this page are combo boxes only // The "standard controls" for the moved DMCA commands are on other pages // The dialog item id must be passed in to get the data void CMcaPage::CboUpdateDMCA(int nID_dci, int nID) { CString strCboText; if (nID == NULL) { return; } CComboBox &cb = *(CComboBox *) GetDlgItem(nID); int idx = cb.GetCurSel(); if (idx > LB_ERR) { switch (nID_dci) { case dciGAIA: // one plus the combobox index (1=1V,2=10V) if ((idx < 0) || (idx > 1)) { idx=0; } strCboText.Format("%d",(idx+1)); break; case dciPURE: //ON;OFF; cb.GetLBText(idx,strCboText); break; } s.m_DP5Cfg[nID_dci].ComboIndex = idx; s.m_DP5Cfg[nID_dci].ComboValue = strCboText; SetModified(TRUE); } else { return; } } void CMcaPage::OnCbnSelchangeOptComboDmcaGaia() { CboUpdateDMCA(dciGAIA,IDC_OPT_COMBO_DMCA_GAIA); } void CMcaPage::OnCbnSelchangeOptComboDmcaPure() { CboUpdateDMCA(dciPURE,IDC_OPT_COMBO_DMCA_PURE); } void CMcaPage::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_THSL: UNIT_INIT(THSL, strUnits); LIMIT_INIT(THSL, strLimits); break; case IDC_OPT_TEXT_PRET: UNIT_INIT(PRET, strUnits); LIMIT_INIT(PRET, strLimits); break; case IDC_OPT_TEXT_PREC: UNIT_INIT(PREC, strUnits); LIMIT_INIT(PREC, strLimits); break; case IDC_OPT_TEXT_MCST: UNIT_INIT(MCST, strUnits); LIMIT_INIT(MCST, strLimits); break; case IDC_OPT_TEXT_MCSL: UNIT_INIT(MCSL, strUnits); LIMIT_INIT(MCSL, strLimits); break; case IDC_OPT_TEXT_MCSH: UNIT_INIT(MCSH, strUnits); LIMIT_INIT(MCSH, strLimits); break; case IDC_OPT_TEXT_PRCL: UNIT_INIT(PRCL, strUnits); LIMIT_INIT(PRCL, strLimits); break; case IDC_OPT_TEXT_PRCH: UNIT_INIT(PRCH, strUnits); LIMIT_INIT(PRCH, strLimits); break; case IDC_OPT_TEXT_PRER: UNIT_INIT(PRER, strUnits); LIMIT_INIT(PRER, strLimits); break; case IDC_OPT_TEXT_PREL: UNIT_INIT(PREL, strUnits); LIMIT_INIT(PREL, strLimits); break; case IDC_OPT_TEXT_SOFF: UNIT_INIT(SOFF, strUnits); LIMIT_INIT(SOFF, strLimits); break; case IDC_OPT_TEXT_TLLD: UNIT_INIT(TLLD, strUnits); LIMIT_INIT(TLLD, strLimits); break; } } } // pass dci id to update combo control and display edit controls if any void CMcaPage::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_PRET: ALL_VIS(PRET, CmdShow); CBO_TEXT_VIS(PRET, (CmdShow!=0)); break; case IDC_OPT_COMBO_PREC: ALL_VIS(PREC, CmdShow); CBO_TEXT_VIS(PREC, (CmdShow!=0)); break; case IDC_OPT_COMBO_PRER: ALL_VIS(PRER, CmdShow); CBO_TEXT_VIS(PRER, (CmdShow!=0)); break; case IDC_OPT_COMBO_PREL: ALL_VIS(PREL, CmdShow); CBO_TEXT_VIS(PREL, (CmdShow!=0)); break; case IDC_OPT_COMBO_SOFF: ALL_VIS(SOFF, CmdShow); CBO_TEXT_VIS(SOFF, (CmdShow!=0)); break; case IDC_OPT_COMBO_TLLD: ALL_VIS(TLLD, CmdShow); CBO_TEXT_VIS(TLLD, (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 CMcaPage::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 CMcaPage::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 CMcaPage::OnCbnSelchangeOptComboPret() { CboUpdate(dciPRET); } void CMcaPage::OnCbnSelchangeOptComboMcae() { CboUpdate(dciMCAE); } void CMcaPage::OnCbnSelchangeOptComboMcac() { CboUpdate(dciMCAC); } void CMcaPage::OnCbnSelchangeOptComboGate() { CboUpdate(dciGATE); } void CMcaPage::OnCbnSelchangeOptComboPrec() { CboUpdate(dciPREC); } void CMcaPage::OnCbnSelchangeOptComboSoff() { CboUpdate(dciSOFF); } void CMcaPage::OnCbnSelchangeOptComboPdmd() { CboUpdate(dciPDMD); } void CMcaPage::OnEnChangeOptTextThsl() { TextUpdate(dciTHSL); } void CMcaPage::OnEnChangeOptTextPret() { TextUpdate(dciPRET); //CString strText; //GetDlgItem(IDC_OPT_TEXT_PRET)->GetWindowText(strText); //AfxMessageBox(s.m_DP5Cfg[dciPRET].TextValue); //AfxMessageBox(strText); } void CMcaPage::OnEnChangeOptTextPrec() { TextUpdate(dciPREC); } void CMcaPage::OnEnChangeOptTextMcst() { TextUpdate(dciMCST); } void CMcaPage::OnEnChangeOptTextSoff() { TextUpdate(dciSOFF); } void CMcaPage::OnCbnSelchangeOptComboMcas() { CboUpdate(dciMCAS); } void CMcaPage::OnCbnSelchangeOptComboPrer() { CboUpdate(dciPRER); } void CMcaPage::OnEnChangeOptTextPrer() { TextUpdate(dciPRER); } void CMcaPage::OnCbnSelchangeOptComboPrel() { CboUpdate(dciPREL); } void CMcaPage::OnEnChangeOptTextPrel() { TextUpdate(dciPREL); } void CMcaPage::OnEnChangeOptTextMcsl() { TextUpdate(dciMCSL); } void CMcaPage::OnEnChangeOptTextMcsh() { TextUpdate(dciMCSH); } void CMcaPage::OnEnChangeOptTextPrcl() { TextUpdate(dciPRCL); } void CMcaPage::OnEnChangeOptTextPrch() { TextUpdate(dciPRCH); } void CMcaPage::OnEnChangeOptTextTlld() { TextUpdate(dciTLLD); } void CMcaPage::OnCbnSelchangeOptComboTlld() { CboUpdate(dciTLLD); } BOOL CMcaPage::PreTranslateMessage(MSG* pMsg) { int ctrl; CWnd* pCurrent; 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 ) { pCurrent = GetFocus(); 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); } BOOL CMcaPage::isCEditBox(int nID) { BOOL isEdit = FALSE; switch (nID) { case IDC_OPT_TEXT_THSL: isEdit = TRUE; break; case IDC_OPT_TEXT_PRET: isEdit = TRUE; break; case IDC_OPT_TEXT_PREC: isEdit = TRUE; break; case IDC_OPT_TEXT_PRER: isEdit = TRUE; break; case IDC_OPT_TEXT_PREL: isEdit = TRUE; break; case IDC_OPT_TEXT_MCST: isEdit = TRUE; break; case IDC_OPT_TEXT_MCSL: isEdit = TRUE; break; case IDC_OPT_TEXT_MCSH: isEdit = TRUE; break; case IDC_OPT_TEXT_PRCL: isEdit = TRUE; break; case IDC_OPT_TEXT_PRCH: isEdit = TRUE; break; case IDC_OPT_TEXT_SOFF: isEdit = TRUE; break; } return isEdit; } BOOL CMcaPage::isCComboBox(int nID) { BOOL isCombo = FALSE; switch (nID) { case IDC_OPT_COMBO_MCAS: isCombo = TRUE; break; case IDC_OPT_COMBO_MCAE: isCombo = TRUE; break; case IDC_OPT_COMBO_MCAC: isCombo = TRUE; break; case IDC_OPT_COMBO_GATE: isCombo = TRUE; break; case IDC_OPT_COMBO_PRET: isCombo = TRUE; break; case IDC_OPT_COMBO_PREC: isCombo = TRUE; break; case IDC_OPT_COMBO_PRER: isCombo = TRUE; break; case IDC_OPT_COMBO_PREL: isCombo = TRUE; break; case IDC_OPT_COMBO_SOFF: isCombo = TRUE; break; case IDC_OPT_COMBO_PDMD: isCombo = TRUE; break; } return isCombo; } void CMcaPage::OnBnClickedPresetcountcursorbutton() { int ChPos; CString strChPos; ChPos = 0; ChPos = s.spectraList.m_currentSpectrum->PosToChannel(s.plot->m_xCursorData); if (ChPos == 0) ChPos = 1; //ChPos++; //20110503 strChPos.Format("%d",ChPos - 1); GetDlgItem(IDC_OPT_TEXT_PRCL)->SetWindowText(strChPos); TextUpdate(dciPRCL); strChPos.Format("%d",ChPos + 1); GetDlgItem(IDC_OPT_TEXT_PRCH)->SetWindowText(strChPos); TextUpdate(dciPRCH); } // This will change when dpp channels=dpppmca channels // NOTE: the dp5 spectrum 1-max chan // DppMCA 0-(max chan-1) // Preset Chan Low = (roi start channel) + 1 //offset chan // Preset Chan High = (roi end channel) + 1 //offset chan void CMcaPage::OnBnClickedPresetcountroibutton() { int ChPosL; int ChPosH; CString strChPos; CSpectrum &sp = *s.spectraList.m_currentSpectrum; // get handle to current spectrum int i = sp.m_roi.m_selectIndex; // get the index of the current ROI if (i >= 0 && i < sp.m_roi.m_count) // test if ROI is valid and in list { ChPosL = sp.m_roi[i].m_start; // + 1; //20110503 // roi start channel if (ChPosL < 0) ChPosL = 0; strChPos.Format("%d",ChPosL); GetDlgItem(IDC_OPT_TEXT_PRCL)->SetWindowText(strChPos); TextUpdate(dciPRCL); ChPosH = sp.m_roi[i].m_end; // + 1; //20110503 // roi end channel if (ChPosH <= ChPosL + 2) ChPosH = ChPosL + 2; strChPos.Format("%d",ChPosH); GetDlgItem(IDC_OPT_TEXT_PRCH)->SetWindowText(strChPos); TextUpdate(dciPRCH); } } //////////////////////////////////////////////////////////////////////////////////// // HtmlHelp for shared dialog // NOTE: shared dialogs use string type IDD, not global IDD BOOL CMcaPage::OnHelpInfo(HELPINFO* pHelpInfo) { CString strHelp; if (pHelpInfo->iContextType == HELPINFO_WINDOW) { if (pHelpInfo->dwContextId == 0) { ::HtmlHelp(this->GetSafeHwnd(), theApp.m_pszHelpFilePath, HH_HELP_CONTEXT, HIDD_MCA_PAGE); } else { // } } return true; } void CMcaPage::OnHelp() // enable property sheet help button help { ::HtmlHelp(this->GetSafeHwnd(), theApp.m_pszHelpFilePath, HH_HELP_CONTEXT, HIDD_MCA_PAGE); //SendMessage(WM_COMMANDHELP); // } //////////////////////////////////////////////////////////////////////////////////// void CMcaPage::BuildToolTips() { if (!m_ToolTip.Create(this)) { TRACE0("Unable to create ToolTip control\n"); } else { m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_GATE), IDS_TT_GATE_CONTROL); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_GATE), IDS_TT_GATE_CONTROL); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_MCAC), IDS_TT_MCA_MCS_CHANNELS); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_MCAC), IDS_TT_MCA_MCS_CHANNELS); //m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_MCAE), IDS_TT_ANA_LOAD_LIB); //m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_MCAE), IDS_TT_ANA_LOAD_LIB); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_MCAS), IDS_TT_MCA_SOURCE); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_MCAS), IDS_TT_MCA_SOURCE); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_MCSH), IDS_TT_MCS_LOW_HIGH_CHANNEL); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_LIMITS_MCSH), IDS_TT_MCS_LOW_HIGH_CHANNEL); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_TEXT_MCSH), IDS_TT_MCS_LOW_HIGH_CHANNEL); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_MCSH), IDS_TT_MCS_LOW_HIGH_CHANNEL); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_MCSL), IDS_TT_MCS_LOW_HIGH_CHANNEL); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_LIMITS_MCSL), IDS_TT_MCS_LOW_HIGH_CHANNEL); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_TEXT_MCSL), IDS_TT_MCS_LOW_HIGH_CHANNEL); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_MCSL), IDS_TT_MCS_LOW_HIGH_CHANNEL); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_MCST), IDS_TT_MCS_TIMEBASE); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_LIMITS_MCST), IDS_TT_MCS_TIMEBASE); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_TEXT_MCST), IDS_TT_MCS_TIMEBASE); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_MCST), IDS_TT_MCS_TIMEBASE); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_PDMD), IDS_TT_PEAK_DETECT_MODE); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_PDMD), IDS_TT_PEAK_DETECT_MODE); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_PRCH), IDS_TT_PRESET_COUNT_LOW_HIGH_CHANNEL); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_LIMITS_PRCH), IDS_TT_PRESET_COUNT_LOW_HIGH_CHANNEL); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_TEXT_PRCH), IDS_TT_PRESET_COUNT_LOW_HIGH_CHANNEL); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_PRCH), IDS_TT_PRESET_COUNT_LOW_HIGH_CHANNEL); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_PRCL), IDS_TT_PRESET_COUNT_LOW_HIGH_CHANNEL); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_LIMITS_PRCL), IDS_TT_PRESET_COUNT_LOW_HIGH_CHANNEL); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_TEXT_PRCL), IDS_TT_PRESET_COUNT_LOW_HIGH_CHANNEL); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_PRCL), IDS_TT_PRESET_COUNT_LOW_HIGH_CHANNEL); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_PREC), IDS_TT_PRESET_COUNT); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_PREC), IDS_TT_PRESET_COUNT); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_LIMITS_PREC), IDS_TT_PRESET_COUNT); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_TEXT_PREC), IDS_TT_PRESET_COUNT); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_PREC), IDS_TT_PRESET_COUNT); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_PRER), IDS_TT_PRESET_REAL_TIME); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_PRER), IDS_TT_PRESET_REAL_TIME); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_LIMITS_PRER), IDS_TT_PRESET_REAL_TIME); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_TEXT_PRER), IDS_TT_PRESET_REAL_TIME); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_PRER), IDS_TT_PRESET_REAL_TIME); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_PREL), IDS_TT_PRESET_LIVE_TIME); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_PREL), IDS_TT_PRESET_LIVE_TIME); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_LIMITS_PREL), IDS_TT_PRESET_LIVE_TIME); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_TEXT_PREL), IDS_TT_PRESET_LIVE_TIME); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_PREL), IDS_TT_PRESET_LIVE_TIME); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_PRET), IDS_TT_PRESET_ACQUISITION_TIME); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_PRET), IDS_TT_PRESET_ACQUISITION_TIME); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_LIMITS_PRET), IDS_TT_PRESET_ACQUISITION_TIME); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_TEXT_PRET), IDS_TT_PRESET_ACQUISITION_TIME); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_PRET), IDS_TT_PRESET_ACQUISITION_TIME); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_SOFF), IDS_TT_SET_SPECTRUM_OFFSET); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_SOFF), IDS_TT_SET_SPECTRUM_OFFSET); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_LIMITS_SOFF), IDS_TT_SET_SPECTRUM_OFFSET); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_TEXT_SOFF), IDS_TT_SET_SPECTRUM_OFFSET); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_SOFF), IDS_TT_SET_SPECTRUM_OFFSET); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_THSL), IDS_TT_SLOW_THRESHOLD); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_LIMITS_THSL), IDS_TT_SLOW_THRESHOLD); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_TEXT_THSL), IDS_TT_SLOW_THRESHOLD); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_THSL), IDS_TT_SLOW_THRESHOLD); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_COMBO_TLLD), IDS_TT_LOW_LEVEL_DISCRIMINATOR); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_FRAME_TLLD), IDS_TT_LOW_LEVEL_DISCRIMINATOR); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_LIMITS_TLLD), IDS_TT_LOW_LEVEL_DISCRIMINATOR); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_TEXT_TLLD), IDS_TT_LOW_LEVEL_DISCRIMINATOR); m_ToolTip.AddTool(GetDlgItem(IDC_OPT_UNITS_TLLD), IDS_TT_LOW_LEVEL_DISCRIMINATOR); m_ToolTip.AddTool(GetDlgItem(IDC_PRESETCOUNTCURSORBUTTON), IDS_TT_PRESET_COUNT); m_ToolTip.AddTool(GetDlgItem(IDC_PRESETCOUNTROIBUTTON), IDS_TT_PRESET_COUNT); //m_ToolTip.AddTool(GetDlgItem(IDC_STATIC_MCA_ADVANCED), _T("Advanced controls for experienced users.")); //m_ToolTip.AddTool(GetDlgItem(IDC_STATIC_MCA_BASIC), _T("Basic controls for most users.")); //m_ToolTip.AddTool(GetDlgItem(IDC_STATIC_MCA_PAGE), _T("MCA Controls Page")); //m_ToolTip.AddTool(GetDlgItem(IDC_STATIC_MCA_STANDARD), _T("Basic controls for most users.")); m_ToolTip.Activate(TRUE); m_ToolTip.SetMaxTipWidth(200); } } void CMcaPage::MoveCtrl(int nID, long deltaX, long deltaY) { CRect m_Rect; // CRect representing tab control's position. //CString strRect(""); //CString strAll(""); GetDlgItem(nID)->GetWindowRect(&m_Rect); //strRect.Format("Rect: %d %d %d %d \r\n", m_Rect.left, m_Rect.top, m_Rect.Width(), m_Rect.Height()); //strAll += strRect; ScreenToClient(m_Rect); GetDlgItem(nID)->MoveWindow(m_Rect.left + deltaX, m_Rect.top + deltaY, m_Rect.Width(), m_Rect.Height(), 1); //strRect.Format("Rect: %d %d %d %d \r\n", m_Rect.left, m_Rect.top, m_Rect.Width(), m_Rect.Height()); //strAll += strRect; //ScreenToClient(m_Rect); //AfxMessageBox(strRect); //AfxMessageBox(strAll); GetDlgItem(nID)->ShowWindow(SW_SHOW); } void CMcaPage::MoveCtrlEx(int nID, int nID_Left, int nID_Top) { CRect m_Rect; // CRect representing tab control's position. CRect m_Rect_Left; // CRect representing tab control's position. CRect m_Rect_Top; // CRect representing tab control's position. //CString strRect(""); //CString strAll(""); GetDlgItem(nID)->GetWindowRect(&m_Rect); GetDlgItem(nID_Left)->GetWindowRect(&m_Rect_Left); GetDlgItem(nID_Top)->GetWindowRect(&m_Rect_Top); //strRect.Format("Rect: %d %d %d %d \r\n", m_Rect.left, m_Rect.top, m_Rect.Width(), m_Rect.Height()); //strAll += strRect; ScreenToClient(m_Rect); ScreenToClient(m_Rect_Left); ScreenToClient(m_Rect_Top); GetDlgItem(nID)->MoveWindow(m_Rect_Left.left, m_Rect_Top.top, m_Rect.Width(), m_Rect.Height(), 1); //strRect.Format("Rect: %d %d %d %d \r\n", m_Rect.left, m_Rect.top, m_Rect.Width(), m_Rect.Height()); //strAll += strRect; //ScreenToClient(m_Rect); //AfxMessageBox(strRect); //AfxMessageBox(strAll); GetDlgItem(nID)->ShowWindow(SW_SHOW); }