// Perfstat_UI_FinalDlg.cpp : implementation file // #include "stdafx.h" #include "Perfstat_UI_Final.h" #include "Perfstat_UI_FinalDlg.h" #include "afxdialogex.h" #ifdef _DEBUG #define new DEBUG_NEW #endif DWORD WINAPI MyThreadFunction( LPVOID lpParam ); // CAboutDlg dialog used for App About class CAboutDlg : public CDialogEx { public: CAboutDlg(); // Dialog Data enum { IDD = IDD_ABOUTBOX }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support // Implementation protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialogEx(CAboutDlg::IDD) { } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx) END_MESSAGE_MAP() // CPerfstat_UI_FinalDlg dialog CPerfstat_UI_FinalDlg::CPerfstat_UI_FinalDlg(CWnd* pParent /*=NULL*/) : CDialogEx(CPerfstat_UI_FinalDlg::IDD, pParent),m_pMediator(NULL) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); m_pToolTipCtrl = NULL; HWND handle = GetSafeOwner()->GetSafeHwnd(); TCHAR strDirectory[DIR_MAX_PATH_SIZE]; GetCurrentDirectory(DIR_MAX_PATH_SIZE, strDirectory); CString str; str.Format(strDirectory); m_pMediator = new CMediator(str); } void CPerfstat_UI_FinalDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Control(pDX, IDC_COMBO_RUN_TYPE, m_comboRunType); DDX_Control(pDX, IDC_STATIC_RUN_TYPE, m_staticRunType); DDX_Control(pDX, IDC_STATIC_TIME, m_staticTime); DDX_Control(pDX, IDC_STATIC_OUTPUT_FILE, m_staticOutput); DDX_Control(pDX, IDC_STATIC_PRESET_FILE, m_staticPreset); DDX_Control(pDX, IDC_BUTTON_ADVANCED_SETTING, m_buttonAdvancedSettings); DDX_Control(pDX, IDC_CHECK_MODE, m_checkMode); DDX_Control(pDX, IDC_CHECK_FILER_ONLY, m_checkFilerOnly); DDX_Control(pDX, IDC_CHECK_CONFIG, m_checkConfig); DDX_Control(pDX, IDC_STATIC_NODE_SELECTION, m_staticNodeSelection); DDX_Control(pDX, IDC_STATIC_TEST_RUN, m_staticTestRun); DDX_Control(pDX, IDC_BUTTON_SAVE_SETTINGS, m_buttonSave); DDX_Control(pDX, IDC_BUTTON_PREVIEW_SETTINGS, m_buttonPreview); DDX_Control(pDX, IDC_MFCBUTTON_START_PERFSTAT, m_buttonStartPerfstat); DDX_Control(pDX, IDC_MFCBUTTON_STOP_PERFSTAT, m_buttonStopPerfstat); DDX_Control(pDX, IDC_TAB_CONSOLE, m_tabCtrl); DDX_Control(pDX, IDC_BUTTON_CUSTOMIZED_RUN, m_buttonCustomizedRun); DDX_Control(pDX, IDC_MFCBUTTON_RESUME, m_buttonPausePerfstat); } BEGIN_MESSAGE_MAP(CPerfstat_UI_FinalDlg, CDialogEx) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() // ON_WM_MOUSEHOVER() ON_CBN_SETFOCUS(IDC_COMBO_RUN_TYPE, &CPerfstat_UI_FinalDlg::OnCbnSetfocusComboRunType) ON_NOTIFY(NM_THEMECHANGED, IDC_STATIC_RUN_TYPE, &CPerfstat_UI_FinalDlg::OnNMThemeChangedStaticRunType) ON_WM_MOUSEHOVER() ON_WM_MOUSEMOVE() ON_CBN_SELCHANGE(IDC_COMBO_RUN_TYPE, &CPerfstat_UI_FinalDlg::OnCbnSelchangeComboRunType) ON_BN_CLICKED(IDC_MFCBUTTON_START_PERFSTAT, &CPerfstat_UI_FinalDlg::OnBnClickedMfcbuttonStartPerfstat) ON_BN_CLICKED(IDC_MFCBUTTON_STOP_PERFSTAT, &CPerfstat_UI_FinalDlg::OnBnClickedMfcbuttonStopPerfstat) ON_BN_CLICKED(IDC_BUTTON5, &CPerfstat_UI_FinalDlg::OnBnClickedButton5) ON_EN_CHANGE(IDC_MFCEDITBROWSE_OUTPUT_FILE, &CPerfstat_UI_FinalDlg::OnEnChangeMfceditbrowseOutputFile) ON_EN_ALIGN_LTR_EC(IDC_MFCEDITBROWSE_OUTPUT_FILE, &CPerfstat_UI_FinalDlg::OnEnAlignLtrEcMfceditbrowseOutputFile) ON_EN_ALIGN_RTL_EC(IDC_MFCEDITBROWSE_OUTPUT_FILE, &CPerfstat_UI_FinalDlg::OnEnAlignRtlEcMfceditbrowseOutputFile) ON_WM_CLOSE() ON_EN_CHANGE(IDC_MFCEDITBROWSE_PRESET_FILE, &CPerfstat_UI_FinalDlg::OnEnChangeMfceditbrowsePresetFile) ON_BN_CLICKED(IDC_CHECK_FILER_ONLY, &CPerfstat_UI_FinalDlg::OnBnClickedCheckFilerOnly) ON_BN_CLICKED(IDC_CHECK_CONFIG, &CPerfstat_UI_FinalDlg::OnBnClickedCheckConfig) ON_BN_CLICKED(IDC_CHECK_MODE, &CPerfstat_UI_FinalDlg::OnBnClickedCheckMode) ON_BN_CLICKED(IDC_BUTTON_ADVANCED_SETTING, &CPerfstat_UI_FinalDlg::OnBnClickedButtonAdvancedSetting) ON_BN_CLICKED(IDC_BUTTON_PREVIEW_SETTINGS, &CPerfstat_UI_FinalDlg::OnBnClickedButtonPreviewSettings) ON_BN_CLICKED(IDC_BUTTON_SAVE_SETTINGS, &CPerfstat_UI_FinalDlg::OnBnClickedButtonSaveSettings) ON_WM_ERASEBKGND() ON_BN_CLICKED(IDC_MFCBUTTON_RESUME, &CPerfstat_UI_FinalDlg::OnBnClickedMfcbuttonResume) END_MESSAGE_MAP() // CPerfstat_UI_FinalDlg message handlers BOOL CPerfstat_UI_FinalDlg::OnInitDialog() { CDialogEx::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); if (pSysMenu != NULL) { BOOL bNameValid; CString strAboutMenu; bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX); ASSERT(bNameValid); if (!strAboutMenu.IsEmpty()) { pSysMenu->AppendMenu(MF_SEPARATOR); pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); } } // Set the icon for this dialog. The framework does this automatically // when the application's main window is not a dialog SetIcon(m_hIcon, TRUE); // Set big icon SetIcon(m_hIcon, FALSE); // Set small icon // TODO: Add extra initialization here // Initialize the dialog controls InitializeDialog(); GetDlgItem(IDC_MFCBUTTON_RESUME)->ShowWindow(FALSE); //GetDlgItem(IDC_MFCBUTTON_RESUME)->EnableWindow(FALSE); return TRUE; // return TRUE unless you set the focus to a control } void CPerfstat_UI_FinalDlg::OnSysCommand(UINT nID, LPARAM lParam) { if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else { CDialogEx::OnSysCommand(nID, lParam); } } // If you add a minimize button to your dialog, you will need the code below // to draw the icon. For MFC applications using the document/view model, // this is automatically done for you by the framework. void CPerfstat_UI_FinalDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, reinterpret_cast(dc.GetSafeHdc()), 0); // Center icon in client rectangle int cxIcon = GetSystemMetrics(SM_CXICON); int cyIcon = GetSystemMetrics(SM_CYICON); CRect rect; GetClientRect(&rect); int x = (rect.Width() - cxIcon + 1) / 2; int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon dc.DrawIcon(x, y, m_hIcon); } else { CDialogEx::OnPaint(); } } // The system calls this function to obtain the cursor to display while the user drags // the minimized window. HCURSOR CPerfstat_UI_FinalDlg::OnQueryDragIcon() { return static_cast(m_hIcon); } void CPerfstat_UI_FinalDlg :: InitializeDialog() { HWND handle = GetSafeOwner()->GetSafeHwnd(); m_pMediator->SetHWND(handle); // Initialize all the controls in the Dialog for(int nIndex = 0; nIndex < MAX_RUN_TYPE_LIMIT; ++nIndex) { m_comboRunType.AddString(STR_RUN_TYPE_COMBO[nIndex]); } m_comboRunType.SetCurSel(0); m_pMediator->SetControls(0); InitToolTips(); //m_tabCtrl.InsertItem(0,_T("Node-1")); m_tabCtrl.ShowWindow(FALSE); // Hiding the Test Run Controls m_buttonCustomizedRun.ShowWindow(FALSE); } void CPerfstat_UI_FinalDlg :: InitToolTips() { EnableToolTips(); m_pToolTipCtrl = new CToolTipCtrl; m_pToolTipCtrl->Create( this ); CString strToolTip; strToolTip.LoadStringW(IDS_TOOLTIP_RUN_TYPE); m_pToolTipCtrl->AddTool( &m_staticRunType, strToolTip.AllocSysString()); strToolTip.LoadStringW(IDS_TOOLTIP_TIME); m_pToolTipCtrl->AddTool( &m_staticTime, strToolTip.AllocSysString()); strToolTip.LoadStringW(IDS_TOOLTIP_OUTPUT); m_pToolTipCtrl->AddTool( &m_staticOutput, strToolTip.AllocSysString()); strToolTip.LoadStringW(IDS_TOOLTIP_PRESET); m_pToolTipCtrl->AddTool( &m_staticPreset, strToolTip.AllocSysString()); strToolTip.LoadStringW(IDS_TOOLTIP_ADVANCED_SETTINGS); m_pToolTipCtrl->AddTool( &m_buttonAdvancedSettings, strToolTip.AllocSysString()); strToolTip.LoadStringW(IDS_TOOLTIP_MODE); m_pToolTipCtrl->AddTool( &m_checkMode, strToolTip.AllocSysString()); strToolTip.LoadStringW(IDS_TOOLTIP_FILER_ONLY); m_pToolTipCtrl->AddTool( &m_checkFilerOnly, strToolTip.AllocSysString()); strToolTip.LoadStringW(IDS_TOOLTIP_CONFIG); m_pToolTipCtrl->AddTool( &m_checkConfig, strToolTip.AllocSysString()); strToolTip.LoadStringW(IDS_TOOLTIP_NODE_SELECTION); m_pToolTipCtrl->AddTool( &m_staticNodeSelection, strToolTip.AllocSysString()); strToolTip.LoadStringW(IDS_TOOLTIP_TEST_RUN); m_pToolTipCtrl->AddTool( &m_staticTestRun, strToolTip.AllocSysString()); strToolTip.LoadStringW(IDS_TOOLTIP_SAVE); m_pToolTipCtrl->AddTool( &m_buttonSave, strToolTip.AllocSysString()); strToolTip.LoadStringW(IDS_TOOLTIP_PREVIEW); m_pToolTipCtrl->AddTool( &m_buttonPreview, strToolTip.AllocSysString()); strToolTip.LoadStringW(IDS_TOOLTIP_START_PERFSTAT); m_pToolTipCtrl->AddTool( &m_buttonStartPerfstat, strToolTip.AllocSysString()); strToolTip.LoadStringW(IDS_TOOLTIP_PAUSE_PERFSTAT); m_pToolTipCtrl->AddTool( &m_buttonPausePerfstat, strToolTip.AllocSysString()); strToolTip.LoadStringW(IDS_TOOLTIP_STOP_PERFSTAT); m_pToolTipCtrl->AddTool( &m_buttonStopPerfstat, strToolTip.AllocSysString()); strToolTip.LoadStringW(IDS_TOOLTIP_CUSTOMIZED_RUN); m_pToolTipCtrl->AddTool( &m_buttonCustomizedRun, strToolTip.AllocSysString()); } void CPerfstat_UI_FinalDlg::OnMouseHover(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default RECT rect; m_comboRunType.GetClientRect(&rect); if(point.x >= rect.left && point.x <= rect.right && point.y >= rect.top && point.y <= rect.bottom) { MessageBox(_T("RUN TYPE INFO")); } CDialogEx::OnMouseHover(nFlags, point); } void CPerfstat_UI_FinalDlg::OnCbnSetfocusComboRunType() { // TODO: Add your control notification handler code here int nComboIndex = m_comboRunType.GetCurSel(); m_comboRunType.SetCurSel(nComboIndex); } void CPerfstat_UI_FinalDlg::OnNMThemeChangedStaticRunType(NMHDR *pNMHDR, LRESULT *pResult) { // This feature requires Windows XP or greater. // The symbol _WIN32_WINNT must be >= 0x0501. // TODO: Add your control notification handler code here *pResult = 0; } void CPerfstat_UI_FinalDlg::OnMouseMove(UINT nFlags, CPoint point) { CDialogEx::OnMouseMove(nFlags, point); } BOOL CPerfstat_UI_FinalDlg::PreTranslateMessage(MSG* pMsg) { if (m_pToolTipCtrl != NULL) { m_pToolTipCtrl->RelayEvent(pMsg); } return CDialogEx::PreTranslateMessage(pMsg); } void CPerfstat_UI_FinalDlg::OnCbnSelchangeComboRunType() { int nIndex = m_comboRunType.GetCurSel(); m_comboRunType.SetCurSel(nIndex); m_pMediator->SetControls(nIndex); if(nIndex == (MAX_RUN_TYPE_LIMIT-1)) { m_buttonCustomizedRun.ShowWindow(TRUE); } else { m_buttonCustomizedRun.ShowWindow(FALSE); } //SetDlgItems(); } void CPerfstat_UI_FinalDlg :: SetDlgItems() { BASIC_SETTINGS* basic = m_pMediator->GetBasicSettings(); CString str; str.Format(_T("%d"),basic->m_nTime); SetDlgItemText(IDC_EDIT_TIME, str); str.Format(_T("%d"),basic->m_nIterations); SetDlgItemText(IDC_EDIT_ITERATIONS, str); str.Format(basic->m_strOutputFile); SetDlgItemText(IDC_MFCEDITBROWSE_OUTPUT_FILE, str); } DWORD WINAPI MyThreadFunction( LPVOID lpParam) { CMediator* pMediator = (CMediator*)lpParam; pMediator->Run(); return 0; } void CPerfstat_UI_FinalDlg::OnBnClickedMfcbuttonStartPerfstat() { // TODO: Add your control notification handler code here //GetDlgItem(IDC_MFCBUTTON_START_PERFSTAT)->EnableWindow(FALSE); GetDlgItem(IDC_MFCBUTTON_START_PERFSTAT)->ShowWindow(FALSE); GetDlgItem(IDC_MFCBUTTON_RESUME)->ShowWindow(TRUE); GetDlgItem(IDC_MFCBUTTON_STOP_PERFSTAT)->EnableWindow(TRUE); DWORD threadID; CreateThread(NULL, 0, MyThreadFunction, m_pMediator, 0, &threadID); //m_pMediator->Run(); } void CPerfstat_UI_FinalDlg::OnBnClickedMfcbuttonStopPerfstat() { // TODO: Add your control notification handler code here GetDlgItem(IDC_MFCBUTTON_START_PERFSTAT)->EnableWindow(TRUE); GetDlgItem(IDC_MFCBUTTON_START_PERFSTAT)->ShowWindow(TRUE); GetDlgItem(IDC_MFCBUTTON_RESUME)->ShowWindow(FALSE); GetDlgItem(IDC_MFCBUTTON_STOP_PERFSTAT)->EnableWindow(FALSE); m_pMediator->Stop(); } void CPerfstat_UI_FinalDlg::OnBnClickedButton5() { // TODO: Add your control notification handler code here m_dialogAddNodeDlg.DoModal(); } void CPerfstat_UI_FinalDlg::OnEnChangeMfceditbrowseOutputFile() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialogEx::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here CString strOutput; GetDlgItemText(IDC_MFCEDITBROWSE_OUTPUT_FILE, strOutput); ((m_pMediator->GetBasicSettings())->m_strOutputFile).Format(strOutput); } void CPerfstat_UI_FinalDlg::OnEnAlignLtrEcMfceditbrowseOutputFile() { // This feature requires Windows 2000 or greater. // The symbols _WIN32_WINNT and WINVER must be >= 0x0500. // TODO: Add your control notification handler code here MessageBox(_T("Edit Browse LTR")); } void CPerfstat_UI_FinalDlg::OnEnAlignRtlEcMfceditbrowseOutputFile() { // This feature requires Windows 2000 or greater. // The symbols _WIN32_WINNT and WINVER must be >= 0x0500. // TODO: Add your control notification handler code here MessageBox(_T("Edit Browse RTL")); } void CPerfstat_UI_FinalDlg::OnClose() { // TODO: Add your message handler code here and/or call default SAFE_DELETE(m_pMediator); CDialogEx::OnClose(); } void CPerfstat_UI_FinalDlg::OnEnChangeMfceditbrowsePresetFile() { // TODO: If this is a RICHEDIT control, the control will not // send this notification unless you override the CDialogEx::OnInitDialog() // function and call CRichEditCtrl().SetEventMask() // with the ENM_CHANGE flag ORed into the mask. // TODO: Add your control notification handler code here CString strPreset; GetDlgItemText(IDC_MFCEDITBROWSE_PRESET_FILE, strPreset); ((m_pMediator->GetBasicSettings())->m_strPresetFile).Format(strPreset); } void CPerfstat_UI_FinalDlg::OnBnClickedCheckFilerOnly() { // TODO: Add your control notification handler code here (m_pMediator->GetBasicSettings())->m_bFilerOnly = m_checkFilerOnly.GetCheck(); } void CPerfstat_UI_FinalDlg::OnBnClickedCheckConfig() { // TODO: Add your control notification handler code here (m_pMediator->GetBasicSettings())->m_bConfig = m_checkConfig.GetCheck(); } void CPerfstat_UI_FinalDlg::OnBnClickedCheckMode() { // TODO: Add your control notification handler code here (m_pMediator->GetBasicSettings())->m_b7Mode = m_checkMode.GetCheck(); } void CPerfstat_UI_FinalDlg::OnBnClickedButtonAdvancedSetting() { // TODO: Add your control notification handler code here if(m_dialogAdvancedSettings.DoModal() == IDOK) { ADVANCED_SETTINGS* adv = m_pMediator->GetAdvancedSettings(); m_dialogAdvancedSettings.SetAdvancedSettings(adv); } } void CPerfstat_UI_FinalDlg::OnBnClickedButtonPreviewSettings() { // TODO: Add your control notification handler code here m_dialogPreviewSettings.DoModal(); } void CPerfstat_UI_FinalDlg::OnBnClickedButtonSaveSettings() { // TODO: Add your control notification handler code here CFileDialog fileDlg(TRUE); fileDlg.DoModal(); } BOOL CPerfstat_UI_FinalDlg::OnEraseBkgnd(CDC* pDC) { // TODO: Add your message handler code here and/or call default /* CRect rect; GetClientRect(&rect); CBrush myBrush(RGB(100, 100, 100)); // dialog background color CBrush *pOld = pDC->SelectObject(&myBrush); BOOL bRes = pDC->PatBlt(0, 0, rect.Width(), rect.Height(), PATCOPY); pDC->SelectObject(pOld); // restore old brush return bRes; // CDialog::OnEraseBkgnd(pDC); */ return CDialogEx::OnEraseBkgnd(pDC); } void CPerfstat_UI_FinalDlg::OnBnClickedMfcbuttonResume() { // TODO: Add your control notification handler code here GetDlgItem(IDC_MFCBUTTON_START_PERFSTAT)->EnableWindow(TRUE); GetDlgItem(IDC_MFCBUTTON_START_PERFSTAT)->ShowWindow(TRUE); GetDlgItem(IDC_MFCBUTTON_RESUME)->ShowWindow(FALSE); GetDlgItem(IDC_MFCBUTTON_STOP_PERFSTAT)->EnableWindow(TRUE); }