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. What am I doing wrong?

What am I doing wrong?

Scheduled Pinned Locked Moved C / C++ / MFC
question
25 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.
  • F Offline
    F Offline
    FISH786
    wrote on last edited by
    #1

    I am evoking a dialog using

    CDemoKeyDlg dlg();
    m_pMainWnd = &dlg;
    INT_PTR nResponse = dlg.DoModal();
    if (nResponse == IDOK)
    {
    InitDemoInstance();
    }
    else if (nResponse == IDCANCEL)
    {
    }

    In the CDemoKeyDlg I have

    void CDemoKeyDlg::Register()
    {
    if (Id == Key)
    {
    MessageBox("Enjoy","It works",MB_OK);
    OnOK();
    }
    }

    What am I doing wrong the InitDemoInstance does not get evoked, I do get the message to enjoy?

    S 1 Reply Last reply
    0
    • F FISH786

      I am evoking a dialog using

      CDemoKeyDlg dlg();
      m_pMainWnd = &dlg;
      INT_PTR nResponse = dlg.DoModal();
      if (nResponse == IDOK)
      {
      InitDemoInstance();
      }
      else if (nResponse == IDCANCEL)
      {
      }

      In the CDemoKeyDlg I have

      void CDemoKeyDlg::Register()
      {
      if (Id == Key)
      {
      MessageBox("Enjoy","It works",MB_OK);
      OnOK();
      }
      }

      What am I doing wrong the InitDemoInstance does not get evoked, I do get the message to enjoy?

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      What happens if you call EndDialog(IDOK); instead of OnOK?

      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

      F 1 Reply Last reply
      0
      • S Stuart Dootson

        What happens if you call EndDialog(IDOK); instead of OnOK?

        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

        F Offline
        F Offline
        FISH786
        wrote on last edited by
        #3

        I tried both...The dialog box closes.

        S M 2 Replies Last reply
        0
        • F FISH786

          I tried both...The dialog box closes.

          S Offline
          S Offline
          Stuart Dootson
          wrote on last edited by
          #4

          OK - what value is DoModal actually returning then?

          Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

          F 1 Reply Last reply
          0
          • F FISH786

            I tried both...The dialog box closes.

            M Offline
            M Offline
            molesworth
            wrote on last edited by
            #5

            What value does nResponse have? That would seem to be the simplest and most basic thing to check... edit : a fraction too slow :)

            There are three kinds of people in the world - those who can count and those who can't...

            F 2 Replies Last reply
            0
            • S Stuart Dootson

              OK - what value is DoModal actually returning then?

              Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

              F Offline
              F Offline
              FISH786
              wrote on last edited by
              #6

              The control is just not returning back ?

              S 1 Reply Last reply
              0
              • M molesworth

                What value does nResponse have? That would seem to be the simplest and most basic thing to check... edit : a fraction too slow :)

                There are three kinds of people in the world - those who can count and those who can't...

                F Offline
                F Offline
                FISH786
                wrote on last edited by
                #7

                It's just not returing anything..the app just dies...

                M 1 Reply Last reply
                0
                • F FISH786

                  The control is just not returning back ?

                  S Offline
                  S Offline
                  Stuart Dootson
                  wrote on last edited by
                  #8

                  Run it under the debugger. That should indicate when the application exits, if (as appears likely) there's an exception of some sort occurring.

                  Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                  1 Reply Last reply
                  0
                  • F FISH786

                    It's just not returing anything..the app just dies...

                    M Offline
                    M Offline
                    molesworth
                    wrote on last edited by
                    #9

                    FISH786 wrote:

                    It's just not returing anything..the app just dies...

                    :omg: In which case, you must be doing something very naughty in the dialog... You need to step through the code in there, and see where it's going wrong. Put breakpoints in all the event handlers, and track through until you find the place it crashes.

                    There are three kinds of people in the world - those who can count and those who can't...

                    1 Reply Last reply
                    0
                    • M molesworth

                      What value does nResponse have? That would seem to be the simplest and most basic thing to check... edit : a fraction too slow :)

                      There are three kinds of people in the world - those who can count and those who can't...

                      F Offline
                      F Offline
                      FISH786
                      wrote on last edited by
                      #10

                      I just created a new project and using the default setting... I still don't get the nresponse..

                      BOOL CToolApp::InitInstance()
                      CToolDlg dlg;
                      m_pMainWnd = &dlg;
                      INT_PTR nResponse = dlg.DoModal();
                      if (nResponse == IDOK)
                      {
                      // TODO: Place code here to handle when the dialog is
                      // dismissed with OK
                      MessageBox(NULL,"It Works Now","Information",MB_OK);
                      }
                      else if (nResponse == IDCANCEL)
                      {
                      // TODO: Place code here to handle when the dialog is
                      // dismissed with Cancel
                      }
                      {

                      I left the CToolDlg as default..I din't put any code and just clicked the ok button. I don't get a response back.

                      S 1 Reply Last reply
                      0
                      • F FISH786

                        I just created a new project and using the default setting... I still don't get the nresponse..

                        BOOL CToolApp::InitInstance()
                        CToolDlg dlg;
                        m_pMainWnd = &dlg;
                        INT_PTR nResponse = dlg.DoModal();
                        if (nResponse == IDOK)
                        {
                        // TODO: Place code here to handle when the dialog is
                        // dismissed with OK
                        MessageBox(NULL,"It Works Now","Information",MB_OK);
                        }
                        else if (nResponse == IDCANCEL)
                        {
                        // TODO: Place code here to handle when the dialog is
                        // dismissed with Cancel
                        }
                        {

                        I left the CToolDlg as default..I din't put any code and just clicked the ok button. I don't get a response back.

                        S Offline
                        S Offline
                        Stuart Dootson
                        wrote on last edited by
                        #11

                        Sounds like there's something wrong with your system, then - I just tried the very same thing and it returned 1 (IDOK) as expected when I pressed the OK button.

                        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                        F E 2 Replies Last reply
                        0
                        • S Stuart Dootson

                          Sounds like there's something wrong with your system, then - I just tried the very same thing and it returned 1 (IDOK) as expected when I pressed the OK button.

                          Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                          F Offline
                          F Offline
                          FISH786
                          wrote on last edited by
                          #12

                          Wow, Do I re-install to fix it? Or is there something I should try before re-installing?

                          S 1 Reply Last reply
                          0
                          • F FISH786

                            Wow, Do I re-install to fix it? Or is there something I should try before re-installing?

                            S Offline
                            S Offline
                            Stuart Dootson
                            wrote on last edited by
                            #13

                            Single-step through the MFC source code of the CDialog::DoModal call. That should let you see what happens in and after the modal message loop.

                            Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                            F 1 Reply Last reply
                            0
                            • S Stuart Dootson

                              Sounds like there's something wrong with your system, then - I just tried the very same thing and it returned 1 (IDOK) as expected when I pressed the OK button.

                              Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                              E Offline
                              E Offline
                              Eytukan
                              wrote on last edited by
                              #14

                              Stuart Dootson wrote:

                              Sounds like there's something wrong with your system

                              At last there's a reason for those bunch of tree huging hippy testers to be happy!. A support to their slogan.

                              Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.

                              1 Reply Last reply
                              0
                              • S Stuart Dootson

                                Single-step through the MFC source code of the CDialog::DoModal call. That should let you see what happens in and after the modal message loop.

                                Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                                F Offline
                                F Offline
                                FISH786
                                wrote on last edited by
                                #15

                                I did single step...I do see nResponse comming back as 1. However it's just jumping the whole if block and going straight to return FALSE. This is with just plain project no code anywhere except a message box inside the

                                if (nResponse == IDOK)
                                {
                                MessageBox();
                                }
                                else if (nResponse == IDCANCEL)
                                {
                                }
                                It's jumping this whole block.

                                it going to return FALSE; the follwing is what I get at the end of the steping through.

                                'Tool.exe': Loaded 'C:\WINDOWS\system32\imm32.dll'
                                'Tool.exe': Loaded 'C:\WINDOWS\system32\uxtheme.dll'
                                'Tool.exe': Loaded 'C:\WINDOWS\system32\shell32.dll'
                                'Tool.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.5512_x-ww_35d4ce83\comctl32.dll'
                                'Tool.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.MFCLOC_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_b0db7d03\mfc90enu.dll', Binary was not built with debug information.
                                'Tool.exe': Loaded 'C:\WINDOWS\system32\msctf.dll'
                                'Tool.exe': Loaded 'C:\WINDOWS\system32\version.dll'
                                'Tool.exe': Unloaded 'C:\WINDOWS\system32\version.dll'
                                'Tool.exe': Loaded 'C:\WINDOWS\system32\msctfime.ime'
                                The program '[976] Tool.exe: Native' has exited with code 0 (0x0).

                                However I did an uninstall of the update of Internet Explorer that was done on this machine a week ago. I am Running Visual Studio 2008 Version 9.0.30729.1 SP Not sure if the above info makes any difference?

                                S 1 Reply Last reply
                                0
                                • F FISH786

                                  I did single step...I do see nResponse comming back as 1. However it's just jumping the whole if block and going straight to return FALSE. This is with just plain project no code anywhere except a message box inside the

                                  if (nResponse == IDOK)
                                  {
                                  MessageBox();
                                  }
                                  else if (nResponse == IDCANCEL)
                                  {
                                  }
                                  It's jumping this whole block.

                                  it going to return FALSE; the follwing is what I get at the end of the steping through.

                                  'Tool.exe': Loaded 'C:\WINDOWS\system32\imm32.dll'
                                  'Tool.exe': Loaded 'C:\WINDOWS\system32\uxtheme.dll'
                                  'Tool.exe': Loaded 'C:\WINDOWS\system32\shell32.dll'
                                  'Tool.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.5512_x-ww_35d4ce83\comctl32.dll'
                                  'Tool.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.MFCLOC_1fc8b3b9a1e18e3b_9.0.30729.1_x-ww_b0db7d03\mfc90enu.dll', Binary was not built with debug information.
                                  'Tool.exe': Loaded 'C:\WINDOWS\system32\msctf.dll'
                                  'Tool.exe': Loaded 'C:\WINDOWS\system32\version.dll'
                                  'Tool.exe': Unloaded 'C:\WINDOWS\system32\version.dll'
                                  'Tool.exe': Loaded 'C:\WINDOWS\system32\msctfime.ime'
                                  The program '[976] Tool.exe: Native' has exited with code 0 (0x0).

                                  However I did an uninstall of the update of Internet Explorer that was done on this machine a week ago. I am Running Visual Studio 2008 Version 9.0.30729.1 SP Not sure if the above info makes any difference?

                                  S Offline
                                  S Offline
                                  Stuart Dootson
                                  wrote on last edited by
                                  #16

                                  FISH786 wrote:

                                  if (nResponse == IDOK) { MessageBox(); } else if (nResponse == IDCANCEL) { } It's jumping this whole block.

                                  I'm surprised that it doesn't execute the messagebox - VC++ will (even in Debug mode) optimise away a completely empty if...else... statement

                                  Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                                  F 1 Reply Last reply
                                  0
                                  • S Stuart Dootson

                                    FISH786 wrote:

                                    if (nResponse == IDOK) { MessageBox(); } else if (nResponse == IDCANCEL) { } It's jumping this whole block.

                                    I'm surprised that it doesn't execute the messagebox - VC++ will (even in Debug mode) optimise away a completely empty if...else... statement

                                    Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                                    F Offline
                                    F Offline
                                    FISH786
                                    wrote on last edited by
                                    #17

                                    Well is there a way I can work around it?, I guess reinstalling is not going to help either? Quick question are you running the same version of Visual studio 2008? Could you let me know what version you running? I could uninstall 2008 and revert back to 2005 if I have to? Thanks a million.

                                    S 1 Reply Last reply
                                    0
                                    • F FISH786

                                      Well is there a way I can work around it?, I guess reinstalling is not going to help either? Quick question are you running the same version of Visual studio 2008? Could you let me know what version you running? I could uninstall 2008 and revert back to 2005 if I have to? Thanks a million.

                                      S Offline
                                      S Offline
                                      Stuart Dootson
                                      wrote on last edited by
                                      #18

                                      FISH786 wrote:

                                      Quick question are you running the same version of Visual studio 2008?

                                      VS2008 SP1

                                      FISH786 wrote:

                                      I could uninstall 2008 and revert back to 2005 if I have to?

                                      I don't there's a problem with your installation from what you've written - what you've said indicates that the right thing's being returned. Why doesn't that translate back into your code? Not sure.

                                      Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                                      F 1 Reply Last reply
                                      0
                                      • S Stuart Dootson

                                        FISH786 wrote:

                                        Quick question are you running the same version of Visual studio 2008?

                                        VS2008 SP1

                                        FISH786 wrote:

                                        I could uninstall 2008 and revert back to 2005 if I have to?

                                        I don't there's a problem with your installation from what you've written - what you've said indicates that the right thing's being returned. Why doesn't that translate back into your code? Not sure.

                                        Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                                        F Offline
                                        F Offline
                                        FISH786
                                        wrote on last edited by
                                        #19

                                        Any suggetions as to how I could resolve this? Thanks a million

                                        S 1 Reply Last reply
                                        0
                                        • F FISH786

                                          Any suggetions as to how I could resolve this? Thanks a million

                                          S Offline
                                          S Offline
                                          Stuart Dootson
                                          wrote on last edited by
                                          #20

                                          By debugging your code and working out why your code's not getting called when it should be. If that means debugging assembly language, then that's what you need to do.

                                          Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

                                          F 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