Passing DDX Control Variables between Dialogs (Parent->Child)
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Passing DDX Control Variables between Dialogs (Parent->Child)

  1. #1
    Join Date
    Mar 2013
    Location
    I know how fast I'm moving
    Posts
    11

    Passing DDX Control Variables between Dialogs (Parent->Child)

    Hello,
    I apologize in advance, I'm very new to programming in general, especially C++, and I'm trying to update inherited code as best I can so please bear with me.

    I have a main dialog which has (DDX?) controls for the user. eg a slider, and a combo box.
    Previously, an image adjusted by these controls was in the same dialog.
    I need to put this image in a New, separate dialog but it still must be controlled by the slider and combo box on the main dialog.
    (I hope that makes sense)

    My question is how can I pass the control's variables between the dialogs? I have, say,
    Code:
    //MainDlg.cpp
    DDX_Control(pDX, IDC_ComboBrightness, m_Brightness
    I was told that I could do something like:
    Code:
    //ImageDlg.h
    public:  
    	ImageDlg(CWnd* pParent = NULL, CComboBox m_Brightness);  // standard constructor
    But I get errors including: Missing default parameter for parameter 2

    I also need to pass the image array, is that perhaps the same method?

    Even if someone could even point me to an appropriate MSDN article or a tutorial, I'm happy to do the reading - I just can't seem to hit on the right search parameters, or my C++ to English translations aren't as good as they should be yet.

    Thanks so much!
    Cheers!

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

    Re: Passing DDX Control Variables between Dialogs (Parent->Child)

    Quote Originally Posted by Grue42 View Post
    Hello,
    I apologize in advance, I'm very new to programming in general, especially C++, and I'm trying to update inherited code as best I can so please bear with me.

    I have a main dialog which has (DDX?) controls for the user. eg a slider, and a combo box.
    Previously, an image adjusted by these controls was in the same dialog.
    I need to put this image in a New, separate dialog but it still must be controlled by the slider and combo box on the main dialog.
    (I hope that makes sense)

    My question is how can I pass the control's variables between the dialogs? I have, say,


    But I get errors including: Missing default parameter for parameter 2

    I also need to pass the image array, is that perhaps the same method?

    Even if someone could even point me to an appropriate MSDN article or a tutorial, I'm happy to do the reading - I just can't seem to hit on the right search parameters, or my C++ to English translations aren't as good as they should be yet.

    Thanks so much!
    Cheers!
    You do it the same way you set any other variables in another class. In your case one possible way would be to create a CComboBox pointer in your ImageDlg class and set it after you create the dialog. For example,
    Code:
    //in ImageDlg.h
    CComboBox* m_pCombo;
    
    //in MainDlg
    ImageDlg dlg;
    dlg.m_pCombo = &m_pMainCombo;
    Use your real variable names. Mine are just examples.

  3. #3
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,960

    Re: Passing DDX Control Variables between Dialogs (Parent->Child)

    Quote Originally Posted by Grue42 View Post
    I have a main dialog which has (DDX?) controls for the user. eg a slider, and a combo box.
    Previously, an image adjusted by these controls was in the same dialog.
    I need to put this image in a New, separate dialog but it still must be controlled by the slider and combo box on the main dialog.
    (I hope that makes sense)

    My question is how can I pass the control's variables between the dialogs?
    Actually I fail to understand what is this passing about. There must be some image characteristics visualized by the controls, so it seems normal to communicate the essential characteristics themselves but not the controls those are visualized by.
    Best regards,
    Igor

  4. #4
    Join Date
    Mar 2013
    Location
    I know how fast I'm moving
    Posts
    11

    Re: Passing DDX Control Variables between Dialogs (Parent->Child)

    Quote Originally Posted by Igor Vartanov View Post
    Actually I fail to understand what is this passing about. There must be some image characteristics visualized by the controls, so it seems normal to communicate the essential characteristics themselves but not the controls those are visualized by.
    I'll answer as best I can, it's inherited software so I'm trying to come up to speed.
    An array is generated with each pixel's shade of gray. Then it's using imgPlot2 (an NI IMAQ?) which draws the image.

    I thought if I could point to the array and the slider values I could call imgPlot2 to create the image in the new dialog box. I'm also not sure (yet) if the sliders will stay on the parent dialog box, or move to the image dialog box so I thought it might be important to be able to pass those values around.

    ...Was that clear as mud?
    So I guess maybe I need some kind of pointer to the array and controls I need, like GCDEF suggested? Will I be able to call a pointer created in the main dialog from the child dialog?

  5. #5
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,068

    Re: Passing DDX Control Variables between Dialogs (Parent->Child)

    Quote Originally Posted by Grue42 View Post
    So I guess maybe I need some kind of pointer to the array and controls I need, like GCDEF suggested? Will I be able to call a pointer created in the main dialog from the child dialog?
    I wouldn't have suggested it if you couldn't do it.

  6. #6
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,960

    Re: Passing DDX Control Variables between Dialogs (Parent->Child)

    I thought if I could point to the array and the slider values I could call imgPlot2 to create the image in the new dialog box. I'm also not sure (yet) if the sliders will stay on the parent dialog box, or move to the image dialog box so I thought it might be important to be able to pass those values around.
    Please note, here you're constantly talking about values while your intention is passing controls. This was, and remains, my main confusion from the beginning. Control (slider) is a visual representation of its value (integer number), so why to pass the control but not the number itself?
    Best regards,
    Igor

  7. #7
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    11,243

    Re: Passing DDX Control Variables between Dialogs (Parent->Child)

    Passing controls from one view to another can quickly lead to code that is difficult to maintain. I've worked on code where much of the business logic is base on which dialog has been opened and what is the parent's, parent of that dialog. Trust me, working on code like that is no fun. Generally when I work on something like that, I'll switch the code over to more of a doc/view architecture where each view (i.e. dialog) doesn't have a dependency on other views (dialogs), but rather only interacts with the 'document'.

    In the case of a Dialog app (where there is no built-in doc/view mechanism), it's simply to create a 'document' and pass it to each of the dialogs.

    I've got a simple sample of this that I'll post shortly (once I find it).

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center