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. Dialog Box question

Dialog Box question

Scheduled Pinned Locked Moved C / C++ / MFC
question
21 Posts 3 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.
  • P Offline
    P Offline
    Pett
    wrote on last edited by
    #1

    Hi I want to bring up a dialog box when a button is clicked.I'm having problems getting the dialog box to appear when I click on the file. My code is: void CMainFrame::OnSFile() { m_chatterChooser.DoModal(); } And I've declared in the header: CDialog m_chatterChooser; Is this correct? :~ Thank you.

    G 1 Reply Last reply
    0
    • P Pett

      Hi I want to bring up a dialog box when a button is clicked.I'm having problems getting the dialog box to appear when I click on the file. My code is: void CMainFrame::OnSFile() { m_chatterChooser.DoModal(); } And I've declared in the header: CDialog m_chatterChooser; Is this correct? :~ Thank you.

      G Offline
      G Offline
      Gero Gerber
      wrote on last edited by
      #2

      Did you create a dialog ressource and derived a new CDialog class based on this ressource? Gero

      P 1 Reply Last reply
      0
      • G Gero Gerber

        Did you create a dialog ressource and derived a new CDialog class based on this ressource? Gero

        P Offline
        P Offline
        Pett
        wrote on last edited by
        #3

        I created the resource, but no.. didn't derive a new CDialog class. I thought I didn't have to.:~ I will try that. Thank you!

        G 1 Reply Last reply
        0
        • P Pett

          I created the resource, but no.. didn't derive a new CDialog class. I thought I didn't have to.:~ I will try that. Thank you!

          G Offline
          G Offline
          Gero Gerber
          wrote on last edited by
          #4

          Use class-wizard to generate the derived class from CDialog. Remember to select the right dialog ressource id when generating the derived class. Gero

          P 1 Reply Last reply
          0
          • G Gero Gerber

            Use class-wizard to generate the derived class from CDialog. Remember to select the right dialog ressource id when generating the derived class. Gero

            P Offline
            P Offline
            Pett
            wrote on last edited by
            #5

            ok, I've done that, but still nothing happens when I click on the button. What am I not doing?:confused:

            G 1 Reply Last reply
            0
            • P Pett

              ok, I've done that, but still nothing happens when I click on the button. What am I not doing?:confused:

              G Offline
              G Offline
              Gero Gerber
              wrote on last edited by
              #6

              Did you use class wizard? Did you chose the right dialog ressource id in class wizard? Which type is m_chatterChooser now? Gero

              P 1 Reply Last reply
              0
              • G Gero Gerber

                Did you use class wizard? Did you chose the right dialog ressource id in class wizard? Which type is m_chatterChooser now? Gero

                P Offline
                P Offline
                Pett
                wrote on last edited by
                #7

                I have it as CDialog. I chose the resource ID for the dialog that I just built. (Chatter chooser). What do I have to change the type to? I put CCHooser which is the name of the class.. and I got errors. Please bear with me, I'm new to this. Thank you so much

                G 2 Replies Last reply
                0
                • P Pett

                  I have it as CDialog. I chose the resource ID for the dialog that I just built. (Chatter chooser). What do I have to change the type to? I put CCHooser which is the name of the class.. and I got errors. Please bear with me, I'm new to this. Thank you so much

                  G Offline
                  G Offline
                  Gero Gerber
                  wrote on last edited by
                  #8

                  m_chatterChooser must be of type CChooser

                  P 1 Reply Last reply
                  0
                  • P Pett

                    I have it as CDialog. I chose the resource ID for the dialog that I just built. (Chatter chooser). What do I have to change the type to? I put CCHooser which is the name of the class.. and I got errors. Please bear with me, I'm new to this. Thank you so much

                    G Offline
                    G Offline
                    Gero Gerber
                    wrote on last edited by
                    #9

                    If your derived class is named CCHooser you have to include CCHooser.h in the source file where you have declared m_chatterChooser. #include "CCHooser.h" Gero

                    P 1 Reply Last reply
                    0
                    • G Gero Gerber

                      If your derived class is named CCHooser you have to include CCHooser.h in the source file where you have declared m_chatterChooser. #include "CCHooser.h" Gero

                      P Offline
                      P Offline
                      Pett
                      wrote on last edited by
                      #10

                      I have six errors!:confused: I have in my mainframe.cpp #include "CHOOSER.h" #include "CHOOSER.cpp" and void CMainFrame::OnSFile() { // attempting to open a small dialog box to choose a chatter to send file to: m_chatterChooser.DoModal();} In my mainframe.h: CCHOOSER m_chatterChooser; Also, the name of the class is CCHOOSER, but the fileview has chooser.cpp and chooser.h I know this is a simple thing.. why I am having so much trouble? :confused:

                      G 1 Reply Last reply
                      0
                      • P Pett

                        I have six errors!:confused: I have in my mainframe.cpp #include "CHOOSER.h" #include "CHOOSER.cpp" and void CMainFrame::OnSFile() { // attempting to open a small dialog box to choose a chatter to send file to: m_chatterChooser.DoModal();} In my mainframe.h: CCHOOSER m_chatterChooser; Also, the name of the class is CCHOOSER, but the fileview has chooser.cpp and chooser.h I know this is a simple thing.. why I am having so much trouble? :confused:

                        G Offline
                        G Offline
                        Gero Gerber
                        wrote on last edited by
                        #11

                        You must not include this line! #include "CHOOSER.cpp" Gero

                        P 1 Reply Last reply
                        0
                        • G Gero Gerber

                          You must not include this line! #include "CHOOSER.cpp" Gero

                          P Offline
                          P Offline
                          Pett
                          wrote on last edited by
                          #12

                          If this wasn't me, ikt would almost be funny! Now I have 5 errors!

                          G 1 Reply Last reply
                          0
                          • G Gero Gerber

                            m_chatterChooser must be of type CChooser

                            P Offline
                            P Offline
                            Pett
                            wrote on last edited by
                            #13

                            Errors! compiling... Mainfrm.cpp D:\Documents and Settings\Administrator\My Documents\CS61A Info\Assignment1\cs61a\CHATTER\mainfrm.h(48) : error C2146: syntax error : missing ';' before identifier 'm_chatterChooser' D:\Documents and Settings\Administrator\My Documents\CS61A Info\Assignment1\cs61a\CHATTER\mainfrm.h(48) : error C2501: 'CCHOOSER' : missing storage-class or type specifiers D:\Documents and Settings\Administrator\My Documents\CS61A Info\Assignment1\cs61a\CHATTER\mainfrm.h(48) : error C2501: 'm_chatterChooser' : missing storage-class or type specifiers D:\Documents and Settings\Administrator\My Documents\CS61A Info\Assignment1\cs61a\CHATTER\Mainfrm.cpp(162) : error C2065: 'm_chatterChooser' : undeclared identifier D:\Documents and Settings\Administrator\My Documents\CS61A Info\Assignment1\cs61a\CHATTER\Mainfrm.cpp(162) : error C2228: left of '.DoModal' must have class/struct/union type Error executing cl.exe. chatter.exe - 5 error(s), 0 warning(s) :confused::confused::confused:

                            G J 2 Replies Last reply
                            0
                            • P Pett

                              If this wasn't me, ikt would almost be funny! Now I have 5 errors!

                              G Offline
                              G Offline
                              Gero Gerber
                              wrote on last edited by
                              #14

                              Just send me your project (gerogerber@gmx.de), or tell me which errors you get. Gero

                              1 Reply Last reply
                              0
                              • P Pett

                                Errors! compiling... Mainfrm.cpp D:\Documents and Settings\Administrator\My Documents\CS61A Info\Assignment1\cs61a\CHATTER\mainfrm.h(48) : error C2146: syntax error : missing ';' before identifier 'm_chatterChooser' D:\Documents and Settings\Administrator\My Documents\CS61A Info\Assignment1\cs61a\CHATTER\mainfrm.h(48) : error C2501: 'CCHOOSER' : missing storage-class or type specifiers D:\Documents and Settings\Administrator\My Documents\CS61A Info\Assignment1\cs61a\CHATTER\mainfrm.h(48) : error C2501: 'm_chatterChooser' : missing storage-class or type specifiers D:\Documents and Settings\Administrator\My Documents\CS61A Info\Assignment1\cs61a\CHATTER\Mainfrm.cpp(162) : error C2065: 'm_chatterChooser' : undeclared identifier D:\Documents and Settings\Administrator\My Documents\CS61A Info\Assignment1\cs61a\CHATTER\Mainfrm.cpp(162) : error C2228: left of '.DoModal' must have class/struct/union type Error executing cl.exe. chatter.exe - 5 error(s), 0 warning(s) :confused::confused::confused:

                                G Offline
                                G Offline
                                Gero Gerber
                                wrote on last edited by
                                #15

                                Maybe a misspelling - try CChooser instead CCHOOSER. C++ is case sensitive. Gero

                                P 1 Reply Last reply
                                0
                                • G Gero Gerber

                                  Maybe a misspelling - try CChooser instead CCHOOSER. C++ is case sensitive. Gero

                                  P Offline
                                  P Offline
                                  Pett
                                  wrote on last edited by
                                  #16

                                  That didn't work, same 5 errors. I know C++ is case sensitive, that's why I put it in all caps. The class is in all caps. I'm going to delete the class and start again.. and give it a name that doesn't start with C! Is that a good idea? Thank you so much for your help!:rose::rose:

                                  G 1 Reply Last reply
                                  0
                                  • P Pett

                                    That didn't work, same 5 errors. I know C++ is case sensitive, that's why I put it in all caps. The class is in all caps. I'm going to delete the class and start again.. and give it a name that doesn't start with C! Is that a good idea? Thank you so much for your help!:rose::rose:

                                    G Offline
                                    G Offline
                                    Gero Gerber
                                    wrote on last edited by
                                    #17

                                    If you want send me the code. Gero

                                    P 2 Replies Last reply
                                    0
                                    • G Gero Gerber

                                      If you want send me the code. Gero

                                      P Offline
                                      P Offline
                                      Pett
                                      wrote on last edited by
                                      #18

                                      The whole project (actually it is two.. client and server) is large. Shall I send just the relevant code pasted in a document?

                                      1 Reply Last reply
                                      0
                                      • P Pett

                                        Errors! compiling... Mainfrm.cpp D:\Documents and Settings\Administrator\My Documents\CS61A Info\Assignment1\cs61a\CHATTER\mainfrm.h(48) : error C2146: syntax error : missing ';' before identifier 'm_chatterChooser' D:\Documents and Settings\Administrator\My Documents\CS61A Info\Assignment1\cs61a\CHATTER\mainfrm.h(48) : error C2501: 'CCHOOSER' : missing storage-class or type specifiers D:\Documents and Settings\Administrator\My Documents\CS61A Info\Assignment1\cs61a\CHATTER\mainfrm.h(48) : error C2501: 'm_chatterChooser' : missing storage-class or type specifiers D:\Documents and Settings\Administrator\My Documents\CS61A Info\Assignment1\cs61a\CHATTER\Mainfrm.cpp(162) : error C2065: 'm_chatterChooser' : undeclared identifier D:\Documents and Settings\Administrator\My Documents\CS61A Info\Assignment1\cs61a\CHATTER\Mainfrm.cpp(162) : error C2228: left of '.DoModal' must have class/struct/union type Error executing cl.exe. chatter.exe - 5 error(s), 0 warning(s) :confused::confused::confused:

                                        J Offline
                                        J Offline
                                        jhwurmbach
                                        wrote on last edited by
                                        #19

                                        I try to help you: Pett wrote: D:\Documents and Settings\Administrator\My Documents\CS61A Info\Assignment1\cs61a\CHATTER\mainfrm.h(48) : error C2146: syntax error : missing ';' before identifier 'm_chatterChooser' D Here, m_chatterChooser has an unknown datatype. In the mainfrm.h mentioned write a line #include "chooser.h" (next to the other #include lines). Use the name of the FILE where CChooser is declared, not the name of the class itself. (normaly these differ by a leading 'C')and a trailing '.h' Pett wrote: D:\Documents and Settings\Administrator\My Documents\CS61A Info\Assignment1\cs61a\CHATTER\mainfrm.h(48) : error C2501: 'CCHOOSER' : missing storage-class or type specifiers Here is the same problem. CHOOSER is wrong spelling (case-sensitive) Pett wrote: D:\Documents and Settings\Administrator\My Documents\CS61A Info\Assignment1\cs61a\CHATTER\mainfrm.h(48) : error C2501: 'm_chatterChooser' : missing storage-class or type specifiers Here, same line - related problem! Pett wrote: D:\Documents and Settings\Administrator\My Documents\CS61A Info\Assignment1\cs61a\CHATTER\Mainfrm.cpp(162) : error C2065: 'm_chatterChooser' : undeclared identifier The variable m_chatterChooser is not known - you due to the errors before. Pett wrote: D:\Documents and Settings\Administrator\My Documents\CS61A Info\Assignment1\cs61a\CHATTER\Mainfrm.cpp(162) : error C2228: left of '.DoModal' must have class/struct/union type Same line-same problem. You can not call a methos from an non-existing object. Hope this helped. If you post your errors, it is much easier to help you. Don't give up. You WILL make it. I know how intimidating I was in the beginning when the compiler spat out hundreds of errors, just for one missing comma.

                                        P 1 Reply Last reply
                                        0
                                        • G Gero Gerber

                                          If you want send me the code. Gero

                                          P Offline
                                          P Offline
                                          Pett
                                          wrote on last edited by
                                          #20

                                          Thank you so much.:rose: What you suggested worked! Pett.

                                          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