Get entered info from modal MFC form

后端 未结 1 1318
一整个雨季
一整个雨季 2021-01-28 05:50

I have created form CPreparationDlg that has Edit Control. Then I have created application that creates modal form and afer pressing OK on it I need to

相关标签:
1条回答
  • 2021-01-28 06:43

    The answer to the question you are asking:

    You can not read or write from Edit controls on a dialog from outside of the dialog class. The windows associated with the MFC controls do not exist before the call to DoModal, or after the the return from DoModal.

    The dialog class must have member variables with simple types such as int, double, string.

    You can set these variables in the constructor, or before the call to DoModal.

    Within the dialog class in an OnOK handler, you move values from the controls to the member variables.

    After DoModal returns, you can retrieve the values from the member variables.

    You would also want to check the return value of DoModal, since you need to know if the user exited with Ok or Cancel to know whether the returned value is valid.

    These are fundamental principles of MFC dialogs.

    As for the questions you don't ask, the posted code is still not correct. The commented-out declaraion //CPreparationDlg Dlg; means that the variable Dlg is undefined. Setting m_pMainWnd, then calling DoModal within InitInstance also does not appear to be standard usage of an MFC application.

    You will need to do some more research to find out how that all works.

    0 讨论(0)
提交回复
热议问题