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. Passing Window Handles?

Passing Window Handles?

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 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

    How does one pass the parent dialog box's handle to the contructor of a child dialog box that it creates? I need to access the public methods of the parent dialog box from the child dialog box. Thanks.

    F L M 3 Replies Last reply
    0
    • L Lost User

      How does one pass the parent dialog box's handle to the contructor of a child dialog box that it creates? I need to access the public methods of the parent dialog box from the child dialog box. Thanks.

      F Offline
      F Offline
      Fazlul Kabir
      wrote on last edited by
      #2

      When you create the child dialog, pass the pointer of the parent dialog For example, call this from a parent dialog

      void CParentDlg::SomeFunc()
      {
      CChildDlg dlg(this);
      dlg.DoModal();
      .
      .
      }

      Now call GetParent() to access the parent dialog

      CParentDlg* pParentWnd = (CParentDlg*)GetParent();

      Now use pParentWnd to access the public functions from child dialog Hope this helps // Fazlul


      Get RadVC today! Play RAD in VC++ http://www.capitolsoft.com

      1 Reply Last reply
      0
      • L Lost User

        How does one pass the parent dialog box's handle to the contructor of a child dialog box that it creates? I need to access the public methods of the parent dialog box from the child dialog box. Thanks.

        L Offline
        L Offline
        luckylourson
        wrote on last edited by
        #3

        you can use GetParent()

        1 Reply Last reply
        0
        • L Lost User

          How does one pass the parent dialog box's handle to the contructor of a child dialog box that it creates? I need to access the public methods of the parent dialog box from the child dialog box. Thanks.

          M Offline
          M Offline
          Masaaki Onishi
          wrote on last edited by
          #4

          Hello, the codegurus around the world.;) GetParent() is one way, but not so much technically. So, pass the handle of parent of the constructor.

           CChildDlg dlg (this);
           dlg.DoModal();
          

          And the constructor of CChildDlg;

           ChildDlg::ChildDlg (CWnd\* pWnd)
           {
              ASSERT(pWnd);
              //Declare CWnd\* m\_pParent as the private member value;
              m\_pParent = pWnd;
           }
          

          Good Luck! Have a nice day!

          -Masaaki Onishi-

          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