CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2002
    Posts
    30

    Variables in a Dialog app

    I need to access the main window variables in a Dialog base app, from a child dialog. Can I access them directly or i need to create another variable and transfer its content?

    Anyone could help me? Thanks in advance.

  2. #2
    Join Date
    Apr 2002
    Location
    PA, USA
    Posts
    1,658
    if your main window has public member variables, you can use it that way. If not, then you'll need either 1) access functions (like GetVariable1(), GetVariable2(), etc) or 2) make the dlg class a friend class to the parent window (not recommended).

    What are you trying to do? If you give more information we can give you better advice!
    =--=--=--=--=--=--=--=--=--=--=--=--=--=
    Please rate this post to show your appreciation for those that helped you.

    Before You Post A Question, Please Read This: How & When To Ask Your Question
    =--=--=--=--=--=--=--=--=--=--=--=--=--=

    -eli
    http://www.toad-software.com
    http://www.dailymission.com - Do It Daily

  3. #3
    Join Date
    Jun 2001
    Location
    Michigan
    Posts
    2,222
    Say you have 2 dialog classes, dialog1 and dialog2

    //Within your dialog1.cpp:

    dialog2 dlg;
    dlg.DoModal();

    // so you're saying from within dialog2.cpp you want to access variables from within dialog1?

    //you can do something like this in dialog2.cpp

    #include "dialog1.h"
    diglag1* parentDlg=(dialog1*) GetParent();
    parentDlg->/*access vars here*/

  4. #4
    Join Date
    Jul 2002
    Posts
    30
    Thanks again guys!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured