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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. m_pMainWnd is NULL in CWinApp::Run

m_pMainWnd is NULL in CWinApp::Run

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 4 Posters 1 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.
  • J Offline
    J Offline
    JensB
    wrote on last edited by
    #1

    Hi, In my app::InitInstance() { ... CMyDlg dlg; m_pMainWnd = &dlg; dlg.DoModal(); return TRUE; } The 'CMyDlg' has an internal timer that gets activated after 1 second, and starts executing some actions. After done, the timer is killed and 'CDialog::OnOK' is called. This gets the dialog closed. In the app i need to return TRUE, else i got exit code != 0. But now, i get this ennoying warning: Warning: m_pMainWnd is NULL in CWinApp::Run - quitting application. Any way to get this (annoying) warning out of the program? Greetings, Jens

    L P 2 Replies Last reply
    0
    • J JensB

      Hi, In my app::InitInstance() { ... CMyDlg dlg; m_pMainWnd = &dlg; dlg.DoModal(); return TRUE; } The 'CMyDlg' has an internal timer that gets activated after 1 second, and starts executing some actions. After done, the timer is killed and 'CDialog::OnOK' is called. This gets the dialog closed. In the app i need to return TRUE, else i got exit code != 0. But now, i get this ennoying warning: Warning: m_pMainWnd is NULL in CWinApp::Run - quitting application. Any way to get this (annoying) warning out of the program? Greetings, Jens

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      "Typically, you set this member variable when you override InitInstance. In a worker thread, the value of this data member is inherited from its parent thread." Can you show the complete code for InitInstance up to dlg.DoModal();? Also, why are you writing to this variable? The tigress is here :-D

      1 Reply Last reply
      0
      • J JensB

        Hi, In my app::InitInstance() { ... CMyDlg dlg; m_pMainWnd = &dlg; dlg.DoModal(); return TRUE; } The 'CMyDlg' has an internal timer that gets activated after 1 second, and starts executing some actions. After done, the timer is killed and 'CDialog::OnOK' is called. This gets the dialog closed. In the app i need to return TRUE, else i got exit code != 0. But now, i get this ennoying warning: Warning: m_pMainWnd is NULL in CWinApp::Run - quitting application. Any way to get this (annoying) warning out of the program? Greetings, Jens

        P Offline
        P Offline
        PJ Arends
        wrote on last edited by
        #3

        Dialog based apps must return FALSE from their CWinApp::InitInstance function.


        "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ???  You're definitely a superstar!!!" - mYkel - 21 Jun '04 "There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05 Within you lies the power for good - Use it!

        J 1 Reply Last reply
        0
        • P PJ Arends

          Dialog based apps must return FALSE from their CWinApp::InitInstance function.


          "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 "Obviously ???  You're definitely a superstar!!!" - mYkel - 21 Jun '04 "There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05 Within you lies the power for good - Use it!

          J Offline
          J Offline
          JensB
          wrote on last edited by
          #4

          Hi, I tried to return false, but then the exit-code of the process is '1'. The exit-code needs to be '0'. I removed the m_pMainWnd = &dlg; line alsoo. Greetings, Jens -- modified at 9:40 Monday 12th September, 2005

          D 1 Reply Last reply
          0
          • J JensB

            Hi, I tried to return false, but then the exit-code of the process is '1'. The exit-code needs to be '0'. I removed the m_pMainWnd = &dlg; line alsoo. Greetings, Jens -- modified at 9:40 Monday 12th September, 2005

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            You need to use:

            BOOL CMyDialog::InitInstance()
            {
            return FALSE; // so that the application's message pump doesn't start
            }

            int CMyDialog::ExitInstance()
            {
            return 0; // the application's exit code
            }


            "One must learn from the bite of the fire to leave it alone." - Native American Proverb

            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