How to save state of dialog so that it not closed? - visual-c++

I design mfc dialog based application in which first i design main parent window containing multiple child windows with tab control,it works fine.After i add one dialog before parent dialog and call parent dialog from it.So call to new dialog insert Back button on parent dialog,it works well,but second time parent dialog failed to open and application close.So how to save state of parent dialog second time initialization.I used methodlogy for above scenario given below:
I call new dialog in OnInitDialog() of parent dialog as DoMOdal() method.
Back button code given below:
void CParent::OnBnClickedBack()
{
UpdateData(TRUE);
NewDlg dlg=new NewDlg();
OnOK();
dlg.DoModal();
}

Related

How Receiving WM_Notify in win32 python

I want to get notification to my Form or Dialog handle that one of the control(Ex Button) got its state changed by performing some action(Ex Selecting an Item from combobox) in the same Form or Dialog
I have tried to implement on_notify, but for some reason Its not getting called on occurrence of any event change in the form or Dialog
I need to get on_notify method to be called on any kind of style or state changed in my Dialog or form and also find which control sent the notification to the Toplevel dialog

To send a custom Message from Parent Dialog Box to child Dialog Box using SendMessage() function

There are several ways to use SendMessage()
WIN32API modal
::SendMessage(h, MY_MSG ,0,0);
MFC modal
Let's ptr having child Dialog box Handle then we can use this modal
ptr->SendMessage(MY_MSG,0,0);
But How can I get child dialog Box handle once I clicked a button in parent Dialog box see this.. I write the code
void CCustomMessageDlg::OnBnClickedOpen(){
MyDialog2 d2(IDD_CHILD_DIALOG);
d2.DoModal();
}
I Need Send Custom Message to child Dialog using SendMessage() API once Button is clicked. Can You Please Suggest A solution for this problem
You cannot send a message to the dialog after DoModal() returns, because the dialog will already be destroyed.
In case you want to pass data to the dialog, you can add a member variable to your child dialog, say:
CString m_strMyData;
Then use:
MyDialog2 d2(IDD_CHILD_DIALOG);
d2.m_strMyData = "Test";
d2.DoModal();
and access m_strMyData from within the child dialog.

dlg.DoModal() is making the dialog box modal to the application and not to the previous dialogue box

if (IDOK == dlg.DoModal())
{
csFile = dlg.GetPathName();
return (LPCTSTR)csFile;
}
return NULL;
I have a desktop application and in this I have a dialog box. When I click on open button in this dialog box another open dialog box should pop up. Once this open dialogue box is displayed I am able to again go to the previous dialogue box and click on open. So second instance of open dialog box is displayed. I can do this many times. The open dialog box is modal to the whole application and not to the previous dialog box. Can anyone help me with this? As per design once open dialog box is displayed nothing else should be active till this is closed.
The standard wizard-generated constructor for the dialog box contains an optional constructor-parameter where you can specify the parent window:
class CMyOpenDialog : public CDialog
{
// Construction
public:
CMyOpenDialog(CWnd* pParent = NULL); // standard constructor
...
When you invoke this second dialog from your dialog, supply the parent, like
CMyOpenDialogdlg(this);

How to get focus from child dialog and parent dialog

I Have one parent dialog and one child dialog, when I loaded child dialog in parent dialog the focus is not coming on parent dialog`s control, what I do to get focus on parent dialog control?
Without seeing your code, I would assume that this is a problem with dialog styles. In particular, WS_EX_CONTROLPARENT.

what all the defalut classes will get invoke the time of creating a dialog

Could you please any one let me know what all the classes will get invoke at the time of creation of Dailog in Dialog based applications.
and please let me know the differnce bitween dialog based application and SDI and MDI's.
When the dialog is created only one class is invoked: the CDialog-derived class. A dialog based application is the simplest type of MFC app.
SDI and MDI applications create a frame window, with a menu, tool bar and status bar, a view window (inside the frame), and a document object. MDI also allows the user to open more than one file at a time and creates a document, MDI frame and view for each open document. Several types of view can be used, depending on what you wish to display.

Resources