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. How to set Member variable as extern variable [modified]

How to set Member variable as extern variable [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
19 Posts 4 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Now here is a class

    class CPipeLineApp: public CWinApp
    {
    public:
    CDengLu* dgDlg;
    .......
    }

    I want to set dgDlg as a extern variable so that I can call dgDlg in class CMainFrame. dgDlg has variables :name and pass. I want to call them too. Please lend me a hand.

    modified on Wednesday, March 16, 2011 8:43 PM

    D A 2 Replies Last reply
    0
    • L Lost User

      Now here is a class

      class CPipeLineApp: public CWinApp
      {
      public:
      CDengLu* dgDlg;
      .......
      }

      I want to set dgDlg as a extern variable so that I can call dgDlg in class CMainFrame. dgDlg has variables :name and pass. I want to call them too. Please lend me a hand.

      modified on Wednesday, March 16, 2011 8:43 PM

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

      Jokcy wrote:

      I want to set dgDlg as a extern variable so that I can call dgDlg in class CMainFrame.

      As it is, dgDlg can be accessed from any CMainFrame method.

      "One man's wage rise is another man's price increase." - Harold Wilson

      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

      "Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather

      L 2 Replies Last reply
      0
      • L Lost User

        Now here is a class

        class CPipeLineApp: public CWinApp
        {
        public:
        CDengLu* dgDlg;
        .......
        }

        I want to set dgDlg as a extern variable so that I can call dgDlg in class CMainFrame. dgDlg has variables :name and pass. I want to call them too. Please lend me a hand.

        modified on Wednesday, March 16, 2011 8:43 PM

        A Offline
        A Offline
        Albert Holguin
        wrote on last edited by
        #3

        You don't have to set that as an extern, its public and part of CMainFrame... means you should be able to reach it from any CMainFrame... what are you trying to do?

        L 1 Reply Last reply
        0
        • D David Crow

          Jokcy wrote:

          I want to set dgDlg as a extern variable so that I can call dgDlg in class CMainFrame.

          As it is, dgDlg can be accessed from any CMainFrame method.

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather

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

          How?

          1 Reply Last reply
          0
          • D David Crow

            Jokcy wrote:

            I want to set dgDlg as a extern variable so that I can call dgDlg in class CMainFrame.

            As it is, dgDlg can be accessed from any CMainFrame method.

            "One man's wage rise is another man's price increase." - Harold Wilson

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            "Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather

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

            I'm awfully sorry.I've made a mistake.The question has been modified.Please help me.

            O 1 Reply Last reply
            0
            • A Albert Holguin

              You don't have to set that as an extern, its public and part of CMainFrame... means you should be able to reach it from any CMainFrame... what are you trying to do?

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

              I'am so sorry .I've made a serious mistake.

              class CPipeLineApp : public CWinApp
              {
              public:
              CDengLu* dgDlg;
              .....
              };

              I want to call dgDlg in class CMainFrame. I also want to call dgDlg's variables: name and pass Forwarding your help.

              A 2 Replies Last reply
              0
              • L Lost User

                I'm awfully sorry.I've made a mistake.The question has been modified.Please help me.

                O Offline
                O Offline
                Ozer Karaagac
                wrote on last edited by
                #7

                As far as I understand your question, you can access it like below.

                ((CPipeLineApp*)AfxGetApp())->dgDlg;

                A L 2 Replies Last reply
                0
                • L Lost User

                  I'am so sorry .I've made a serious mistake.

                  class CPipeLineApp : public CWinApp
                  {
                  public:
                  CDengLu* dgDlg;
                  .....
                  };

                  I want to call dgDlg in class CMainFrame. I also want to call dgDlg's variables: name and pass Forwarding your help.

                  A Offline
                  A Offline
                  Albert Holguin
                  wrote on last edited by
                  #8

                  still not sure what the problem is... if CPipeLineApp is derived from CWinApp, then he owns the CMainFrame, so you have complete access to it...

                  1 Reply Last reply
                  0
                  • L Lost User

                    I'am so sorry .I've made a serious mistake.

                    class CPipeLineApp : public CWinApp
                    {
                    public:
                    CDengLu* dgDlg;
                    .....
                    };

                    I want to call dgDlg in class CMainFrame. I also want to call dgDlg's variables: name and pass Forwarding your help.

                    A Offline
                    A Offline
                    Albert Holguin
                    wrote on last edited by
                    #9

                    ...I'm thinking you don't really know the MFC framework?

                    L 1 Reply Last reply
                    0
                    • O Ozer Karaagac

                      As far as I understand your question, you can access it like below.

                      ((CPipeLineApp*)AfxGetApp())->dgDlg;

                      A Offline
                      A Offline
                      Albert Holguin
                      wrote on last edited by
                      #10

                      ozer's right... my 5! [i forgot you can rate these!]

                      O 1 Reply Last reply
                      0
                      • A Albert Holguin

                        ...I'm thinking you don't really know the MFC framework?

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

                        :( I'am a green hand.

                        A 1 Reply Last reply
                        0
                        • L Lost User

                          :( I'am a green hand.

                          A Offline
                          A Offline
                          Albert Holguin
                          wrote on last edited by
                          #12

                          see what ozer wrote above... i think i misunderstood your question, i thought you were trying to access cmainframe from cwinapp, a trivial operation, but you're really trying to access dgDlg (who is owned the cwinapp) from the cmainframe... that's not as trivial (but almost... ;P ) Happy coding! :)

                          1 Reply Last reply
                          0
                          • O Ozer Karaagac

                            As far as I understand your question, you can access it like below.

                            ((CPipeLineApp*)AfxGetApp())->dgDlg;

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

                            Thank you for you method! I've got it.:thumbsup: ;) :-D

                            A 1 Reply Last reply
                            0
                            • L Lost User

                              Thank you for you method! I've got it.:thumbsup: ;) :-D

                              A Offline
                              A Offline
                              Albert Holguin
                              wrote on last edited by
                              #14

                              don't forget to vote his answer up as good! ...i just had someone come around and downvote some of my posts :mad:

                              1 Reply Last reply
                              0
                              • A Albert Holguin

                                ozer's right... my 5! [i forgot you can rate these!]

                                O Offline
                                O Offline
                                Ozer Karaagac
                                wrote on last edited by
                                #15

                                Thanks. :)

                                Time is never on our side! -- Albert Holguin

                                A 1 Reply Last reply
                                0
                                • O Ozer Karaagac

                                  Thanks. :)

                                  Time is never on our side! -- Albert Holguin

                                  A Offline
                                  A Offline
                                  Albert Holguin
                                  wrote on last edited by
                                  #16

                                  interesting quote... sounds familiar... :laugh:

                                  O 1 Reply Last reply
                                  0
                                  • A Albert Holguin

                                    interesting quote... sounds familiar... :laugh:

                                    O Offline
                                    O Offline
                                    Ozer Karaagac
                                    wrote on last edited by
                                    #17

                                    But, I couldn't find out how I could save it as default in my settings. Do you know how?

                                    A L 2 Replies Last reply
                                    0
                                    • O Ozer Karaagac

                                      But, I couldn't find out how I could save it as default in my settings. Do you know how?

                                      A Offline
                                      A Offline
                                      Albert Holguin
                                      wrote on last edited by
                                      #18

                                      Have no idea! ...i've only recently become an active participant in this forum... :doh:

                                      1 Reply Last reply
                                      0
                                      • O Ozer Karaagac

                                        But, I couldn't find out how I could save it as default in my settings. Do you know how?

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

                                        ?I think it will save auto automatically.When close the work space ,it'll warn you.

                                        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