CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2011
    Posts
    60

    pass parameter in oninitdialog

    Hello,

    Thank you very much for taking time from you busy day to help me out. I very much appreciate it. I need to pass a variable to a dialog box.
    Code:
    Doc* pDoc;
    Dialog dlg;		
    int input = dlg.DoModal();
    When I call dlg.DoModal() I need to somehow pass the pDoc into the dialog box. Everything I need the variable for is taking place inside the oninitdialog function. Is there anyway to pass the variable to that function? Again thank you very much for the help.

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: pass parameter in oninitdialog

    Quote Originally Posted by Gregorina View Post
    Hello,

    Thank you very much for taking time from you busy day to help me out. I very much appreciate it. I need to pass a variable to a dialog box.
    Code:
    Doc* pDoc;
    Dialog dlg;		
    int input = dlg.DoModal();
    When I call dlg.DoModal() I need to somehow pass the pDoc into the dialog box. Everything I need the variable for is taking place inside the oninitdialog function. Is there anyway to pass the variable to that function? Again thank you very much for the help.
    You can't. Typically you'd create a member variable in Dialog, such as

    Doc* m_pDoc;

    Then your code would look like
    Code:
    Doc* pDoc;
    Dialog dlg;	
    dlg.m_pDoc = pDoc;	
    int input = dlg.DoModal();
    Then you'd access m_pDoc from OnInitDialog.

  3. #3
    Join Date
    Mar 2011
    Posts
    60

    Re: pass parameter in oninitdialog

    Wow that was easy. Thank you. Don't know why I didn't think of that.

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