2
votes

I have a MFC dialog based application.

The main dialog contain a child dialog (used in a CTabCtrl control).

  • CDialog mainDlgClass;

  • CMyChildDialog childDlgClass;

How I can be able to modify the controls of the child dialog from the main dialog or the possibility to send a message, eg: via PostMessage and using RegisterWindowMessage so I can modify the child dialog's controls?

I dont know howto retrieve a handle of the child dialog.

void mainDlgClass::check() 
{
   if(condition)
       PostMessage_to_the_child_dialog(***);
   OR
   if(condition)
       Modify_CStatic_text_on_the_child_dialog(***);

}

Edit:

Screenshot of the structure:

Resource editor

resource editor

Main dialog + CTabCtrl containing the ChidlDialog

main dialog

Child dialog have WS_CHILD property set.

Resolved.

1

1 Answers

2
votes

Assuming that the second dialog is a child dialog of the main (it has WS_CHILD style), it must be created by the main dialog. Child dialog is confined to a client area of the parent window.

You can provide public member functions (accessors) in the child dialog class to be accessed by the main dialog and change whatever you need. Alternatively, you can access subclassed child’s dialog controls directly if they are declared public (led OOP-like).

The problem is that you may refer to a second dialog as child while it is not really a child (does not have WS_CHILD style). Nevertheless, you can use method described above if the second dialog is spawned as modeless.

If modal, the approach may differ, since the main dialog is disabled; therefore, user cannot access main dialog controls. If this is a case, could you please give us more information?

For example, under what circumstances, you want to alter controls.