Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. DoModal method

DoModal method

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Farah Mansor
    wrote on last edited by
    #1

    Hi all, Can somebody help me on this. I create one dialog let say First dialog. On my First dialog I will validate the OnOK button and if it true open Second dialog. But before I open it, I should dispose the First dialog. This program work ok on my pc(which got visual c++). However when I install in a new pc, it doesn't open the Second dialog. The DoModal method return -1 in a new pc (I check this using text file). The codes are like these: in MyApp class: MyClass::InitInstance() { CFirstDlg firstDlg; m_pMainWnd = &firstDlg; int nResponse = firstDlg.DoModal(); } in CFirstDlg class: CFirstDlg::OnOK() { if (validate) { CDialog::EndDialog(TRUE); CSecondDlg secondDlg; int nResponse = secondDlg.DoModal(); // print nResponse to text file if (nResponse < 0) AfxMessageBox("cannot open second dialog"); else AfxMessageBox("Second dialog opened"); } else { ... } } The problem is how can I make sure that the DoModal method will give me a positive value so it can display the second dialog?? My second dialog is using thread and the first dialog don't. Is the thread give me the problem?? What make me feel weird is it works fine in my pc so I cannot detect what's wrong with the code. :confused: Anybody can help me?? Thanks in advance. FM

    M 1 Reply Last reply
    0
    • F Farah Mansor

      Hi all, Can somebody help me on this. I create one dialog let say First dialog. On my First dialog I will validate the OnOK button and if it true open Second dialog. But before I open it, I should dispose the First dialog. This program work ok on my pc(which got visual c++). However when I install in a new pc, it doesn't open the Second dialog. The DoModal method return -1 in a new pc (I check this using text file). The codes are like these: in MyApp class: MyClass::InitInstance() { CFirstDlg firstDlg; m_pMainWnd = &firstDlg; int nResponse = firstDlg.DoModal(); } in CFirstDlg class: CFirstDlg::OnOK() { if (validate) { CDialog::EndDialog(TRUE); CSecondDlg secondDlg; int nResponse = secondDlg.DoModal(); // print nResponse to text file if (nResponse < 0) AfxMessageBox("cannot open second dialog"); else AfxMessageBox("Second dialog opened"); } else { ... } } The problem is how can I make sure that the DoModal method will give me a positive value so it can display the second dialog?? My second dialog is using thread and the first dialog don't. Is the thread give me the problem?? What make me feel weird is it works fine in my pc so I cannot detect what's wrong with the code. :confused: Anybody can help me?? Thanks in advance. FM

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      Sounds like the second dialog either a) contains an ActiveX control that isn't installed, or b) is trying to instantiate a COM object that isn't installed. Post your CSecondDialog::OnInitDialog() code. --Mike-- http://home.inreach.com/mdunn/ "You named the Borg... Hugh?"   -- Guinan

      F 1 Reply Last reply
      0
      • M Michael Dunn

        Sounds like the second dialog either a) contains an ActiveX control that isn't installed, or b) is trying to instantiate a COM object that isn't installed. Post your CSecondDialog::OnInitDialog() code. --Mike-- http://home.inreach.com/mdunn/ "You named the Borg... Hugh?"   -- Guinan

        F Offline
        F Offline
        Farah Mansor
        wrote on last edited by
        #3

        This is CSecondDlg::OnInitDialog() code: BOOL CSecondDlg::OnInitDialog() { CDialog::OnInitDialog(); ... // TODO: Add extra initialization here // Create a StatusBar CRect rect; if (!m_wndStatusBar.Create(WS_CHILD|WS_VISIBLE, rect, this, IDC_STATUSBAR_STATIC)) { TRACE0("Failed to create status bar\n"); return -1; } // give first status bar pane a border int strPartDim[3]= {100, 130, -1}; m_wndStatusBar.SetParts(3, strPartDim); DisplayTime(); // to display time in status bar // 1st Thread CWzdThread* kpThread = (CWzdThread*)AfxBeginThread(RUNTIME_CLASS(CWzdThread), THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED); kpThread->SetOwner(this); if (!kpThread) { ASSERT(FALSE); return FALSE; } pThread = kpThread; pThread->ResumeThread(); // 2nd Thread CAnotherThread* kpThread1 = (CAnotherThread*)AfxBeginThread(RUNTIME_CLASS(CAnotherThread), THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED); kpThread1->SetOwner(this); if (!kpThread1) { ASSERT(FALSE); return FALSE; } pThread1 = kpThread1; pThread1->ResumeThread(); } m_bInformCSDA = FALSE; SetTimer(ID_COUNT_TIMER, 50, NULL); return TRUE; // return TRUE unless you set the focus to a control } My second dialog also using ActiveX control (for Winsock and create registry). Do these controls give me the problem?? Thanks in advance. FM

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups