Hi, I have a mfc application and it is a simple dialog box that takes in user input and stores that information as separate variables. I also have a separate console based application, and once the user presses "okay" on the dialog box, the console based application should pop up, with information on it that depends on the user's input from the dialog box. I have read that I can use createprocess, and I'd assume this would go in my "OnClickOk" action handler, but I'm still not sure how to do this. Any example code would be greatly appreciated. Thanks!
Also here is my dialog.cpp, just in case this will help with an answer to my question: Code: // 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() // CRLGCDlg dialog CRLGCDlg::CRLGCDlg(CWnd* pParent /*=NULL*/) : CDialogEx(CRLGCDlg::IDD, pParent) , m_Cond1_X(0) , m_Cond1_Y(0) , m_Cond1_Resistivity(0) //, m_Cond2_X(_T("")) , m_Cond2_X(0) , m_Cond2_Y(0) , m_Cond2_Resistivity(0) , m_Cond3_X(0) , m_Cond3_Y(0) , m_Cond3_Resistivity(0) , m_RelativePermittivity(0) , m_Conductivity(0) , m_Thickness(0) , m_Start(0) , m_Stop(0) , m_Step(0) , file1PathName(_T("")) , file2PathName(_T("")) , file3PathName(_T("")) { m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); } void CRLGCDlg::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Text(pDX, IDC_COND1_X, m_Cond1_X); DDX_Text(pDX, IDC_COND1_Y, m_Cond1_Y); DDX_Text(pDX, IDC_COND1_RES, m_Cond1_Resistivity); DDX_Text(pDX, IDC_COND2_X, m_Cond2_X); DDX_Text(pDX, IDC_COND2_Y, m_Cond2_Y); DDX_Text(pDX, IDC_COND2_RES, m_Cond2_Resistivity); DDX_Text(pDX, IDC_COND3_X, m_Cond3_X); DDX_Text(pDX, IDC_COND3_Y, m_Cond3_Y); DDX_Text(pDX, IDC_COND3_RES, m_Cond3_Resistivity); DDX_Text(pDX, IDC_RELATIVE_PERM, m_RelativePermittivity); DDX_Text(pDX, IDC_CONDUCTIVITY, m_Conductivity); DDX_Text(pDX, IDC_THICKNESS, m_Thickness); DDX_Text(pDX, IDC_START, m_Start); DDX_Text(pDX, IDC_STOP, m_Stop); DDX_Text(pDX, IDC_STEP, m_Step); DDX_Text(pDX, IDC_FILE_NAME1, file1PathName); DDX_Text(pDX, IDC_FILE_NAME2, file2PathName); DDX_Text(pDX, IDC_FILE_NAME3, file3PathName); } BEGIN_MESSAGE_MAP(CRLGCDlg, CDialogEx) ON_WM_SYSCOMMAND() ON_WM_PAINT() ON_WM_QUERYDRAGICON() ON_BN_CLICKED(IDC_BROWSE1, &CRLGCDlg::OnClickedBrowse1) ON_BN_CLICKED(IDC_BROWSE2, &CRLGCDlg::OnClickedBrowse2) ON_BN_CLICKED(IDC_BROWSE3, &CRLGCDlg::OnClickedBrowse3) ON_BN_CLICKED(IDOK, &CRLGCDlg::OnClickedOk) END_MESSAGE_MAP() // CRLGCDlg message handlers BOOL CRLGCDlg::OnInitDialog() { CDialogEx::OnInitDialog(); CFont *m_title = new CFont(); m_title->CreatePointFont(150, _T("Segoe UI")); GetDlgItem(IDC_STATIC)->SetFont(m_title, TRUE); CFont *m_Cond = new CFont(); m_Cond->CreatePointFont(118, _T("Segoe UI")); GetDlgItem(IDC_CONDUCTOR1_STATIC)->SetFont(m_Cond, TRUE); GetDlgItem(IDC_CONDUCTOR2_STATIC)->SetFont(m_Cond, TRUE); GetDlgItem(IDC_CONDUCTOR3_STATIC)->SetFont(m_Cond, TRUE); CFont *m_FileName = new CFont(); m_FileName->CreatePointFont(100, _T("Segoe UI")); GetDlgItem(IDC_FILE_NAME1_STATIC)->SetFont(m_FileName, TRUE); GetDlgItem(IDC_FILE_NAME2_STATIC)->SetFont(m_FileName, TRUE); GetDlgItem(IDC_FILE_NAME3_STATIC)->SetFont(m_FileName, TRUE); GetDlgItem(IDC_DIELECTRIC_STATIC)->SetFont(m_FileName, TRUE); GetDlgItem(IDC_FREQUENCY_STATIC)->SetFont(m_FileName, TRUE); // 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 return TRUE; // return TRUE unless you set the focus to a control } void CRLGCDlg::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 CRLGCDlg::OnPaint() { if (IsIconic()) { CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(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 CRLGCDlg::OnQueryDragIcon() { return static_cast<HCURSOR>(m_hIcon); } void CRLGCDlg::OnClickedBrowse1() { // szFilters is a text string that includes two file name filters: // "*.my" for "MyType Files" and "*.*' for "All Files." TCHAR szFilters[]= _T("MyType Files (*.my)|*.my|All Files (*.*)|*.*||"); // Create an Open dialog; the default file name extension is ".my". CFileDialog fileDlg(TRUE, _T("my"), _T("*.mesh"), OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, szFilters); /* const char * buf = "Browse"; //CString browse(buf); //fileDlg.SetWindowText(browse);*/ if(fileDlg.DoModal() == IDOK) { CString file1PathName = fileDlg.GetPathName(); // Implement opening and reading file in here. //Get file's name CString fileName = fileDlg.GetFileTitle(); // SetWindowText(fileName); SetDlgItemText(IDC_FILE_NAME1, (file1PathName)); } } void CRLGCDlg::OnClickedBrowse2() { TCHAR szFilters[]= _T("MyType Files (*.my)|*.my|All Files (*.*)|*.*||"); CFileDialog fileDlg(TRUE, _T("my"), _T("*.mesh"), OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, szFilters); if(fileDlg.DoModal() == IDOK) { CString file2PathName = fileDlg.GetPathName(); CString fileName = fileDlg.GetFileTitle(); SetDlgItemText(IDC_FILE_NAME2, (fileName)); } } void CRLGCDlg::OnClickedBrowse3() { TCHAR szFilters[]= _T("MyType Files (*.my)|*.my|All Files (*.*)|*.*||"); CFileDialog fileDlg(TRUE, _T("my"), _T("*.mesh"), OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, szFilters); if(fileDlg.DoModal() == IDOK) { CString file3PathName = fileDlg.GetPathName(); CString fileName = fileDlg.GetFileTitle(); SetDlgItemText(IDC_FILE_NAME3, (fileName)); } } void CRLGCDlg::OnClickedOk() { // TODO: Add your control notification handler code here CDialogEx::OnOK(); }