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. CDialog access !

CDialog access !

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

    How can i access CDialog class from antoher class that declare in CDialog base application? best regards, M.J.M.

    D H 2 Replies Last reply
    0
    • M mostafa_pasha

      How can i access CDialog class from antoher class that declare in CDialog base application? best regards, M.J.M.

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

      mostafa_pasha wrote:

      How can i access CDialog class...

      Do you mean a CDialog-derived class?


      "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

      "Judge not by the eye but by the heart." - Native American Proverb

      M 1 Reply Last reply
      0
      • D David Crow

        mostafa_pasha wrote:

        How can i access CDialog class...

        Do you mean a CDialog-derived class?


        "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

        "Judge not by the eye but by the heart." - Native American Proverb

        M Offline
        M Offline
        mostafa_pasha
        wrote on last edited by
        #3

        for example i have CMyFile that is generic class (my project is CDialog base such as CMyDialog) how can i access CMyDialog through CMyFile? is that anyway that call CMyDialog's function from CMyFile class? Best regards. M.J.M.

        J D 2 Replies Last reply
        0
        • M mostafa_pasha

          for example i have CMyFile that is generic class (my project is CDialog base such as CMyDialog) how can i access CMyDialog through CMyFile? is that anyway that call CMyDialog's function from CMyFile class? Best regards. M.J.M.

          J Offline
          J Offline
          Jorgen Sigvardsson
          wrote on last edited by
          #4

          CMyFile::Method()
          {
          CMyDialog dlg;
          dlg.DoModal();
          }

          ?

          -- Not a substitute for human interaction

          1 Reply Last reply
          0
          • M mostafa_pasha

            How can i access CDialog class from antoher class that declare in CDialog base application? best regards, M.J.M.

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #5

            did you try it? CMainClass *m_Main=(CMainClass*)GetParent(); m_Main->your variables


            WhiteSky


            M 1 Reply Last reply
            0
            • H Hamid Taebi

              did you try it? CMainClass *m_Main=(CMainClass*)GetParent(); m_Main->your variables


              WhiteSky


              M Offline
              M Offline
              mostafa_pasha
              wrote on last edited by
              #6

              Hi, it does not work. GetParent get one argument as HWND. i change it , CMainClass *m_Main=(CMainClass*)GetParent(theApp.GetMainWnd()->m_hWnd); but in dialog base application , compiler say " error C2065: 'theApp' : undeclared identifier" now how can i get pointer to CVerApp class? CVerApp * = ???; which function exist to point to my CVerApp? Best Regards. M.J.M.

              H 1 Reply Last reply
              0
              • M mostafa_pasha

                Hi, it does not work. GetParent get one argument as HWND. i change it , CMainClass *m_Main=(CMainClass*)GetParent(theApp.GetMainWnd()->m_hWnd); but in dialog base application , compiler say " error C2065: 'theApp' : undeclared identifier" now how can i get pointer to CVerApp class? CVerApp * = ???; which function exist to point to my CVerApp? Best Regards. M.J.M.

                H Offline
                H Offline
                Hamid Taebi
                wrote on last edited by
                #7

                How to use this file if you use of GetParent(m_hWnd) what happens?


                WhiteSky


                M 1 Reply Last reply
                0
                • H Hamid Taebi

                  How to use this file if you use of GetParent(m_hWnd) what happens?


                  WhiteSky


                  M Offline
                  M Offline
                  mostafa_pasha
                  wrote on last edited by
                  #8

                  I have progress bar, i want to change position from my CMyFile class ! CMyFile class is generic class! i just want to change position of bar from my CMyFile so first , i get pointer to my dialog class form CMyFile! then call function SetPos() of my prograss bar class . How can i do that? best regards. MJM

                  H 1 Reply Last reply
                  0
                  • M mostafa_pasha

                    for example i have CMyFile that is generic class (my project is CDialog base such as CMyDialog) how can i access CMyDialog through CMyFile? is that anyway that call CMyDialog's function from CMyFile class? Best regards. M.J.M.

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

                    mostafa_pasha wrote:

                    is that anyway that call CMyDialog's function from CMyFile class?

                    Sure, but why would you want to? By allowing CMyFile access to the internals of CMyDialog, you have thus tied the two together (i.e., encapsulation). It's especially troublesome if you are wanting CMyFile to manipulate a UI component (e.g., progress bar) that CMyDialog owns. You should be posting a message to CMyDialog instead.


                    "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

                    "Judge not by the eye but by the heart." - Native American Proverb

                    1 Reply Last reply
                    0
                    • M mostafa_pasha

                      I have progress bar, i want to change position from my CMyFile class ! CMyFile class is generic class! i just want to change position of bar from my CMyFile so first , i get pointer to my dialog class form CMyFile! then call function SetPos() of my prograss bar class . How can i do that? best regards. MJM

                      H Offline
                      H Offline
                      Hamid Taebi
                      wrote on last edited by
                      #10

                      if this pointer is valid you dont have problem and you must create this pointer once and again use of it for call your class,I hope it helpful for you but if you have problem you can ask :)


                      WhiteSky


                      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