Specific code is as follows:
Non-modal window call:
Void CViewComTestView: : OnButton1 ()
{
//TODO: Add your the control notification handler code here
if(! Dlg1. M_hWnd)
{
Dlg1. Create (IDD_DIALOG1);
Dlg1. ShowWindow (SW_SHOW);
}
The else
{
Dlg1. DestroyWindow ();
Dlg1. Create (IDD_DIALOG1);
Dlg1. ShowWindow (SW_SHOW);
}
}
Add a message:
# define WM_MAIN_MSG WM_USER + 0 x01001
# define WM_SUB_MSG WM_USER + 0 x02001
Message response function definition:
BEGIN_MESSAGE_MAP (CMySubDlg CDialog)
//{{AFX_MSG_MAP (CMySubDlg)
ON_BN_CLICKED (IDC_BUTTON1 OnButton1)
//}} AFX_MSG_MAP
ON_MESSAGE (WM_SUB_MSG CMySubDlg: : OnSubMsg)
END_MESSAGE_MAP ()
BEGIN_MESSAGE_MAP (CViewComTestView CFormView)
//{{AFX_MSG_MAP (CViewComTestView)
ON_BN_CLICKED (IDC_BUTTON1 OnButton1)
ON_BN_CLICKED (IDC_BUTTON3 OnButton2)
//}} AFX_MSG_MAP
//Standard printing commands
ON_COMMAND (ID_FILE_PRINT CFormView: : OnFilePrint)
ON_COMMAND (ID_FILE_PRINT_DIRECT CFormView: : OnFilePrint)
ON_COMMAND (ID_FILE_PRINT_PREVIEW CFormView: : OnFilePrintPreview)
ON_MESSAGE (WM_MAIN_MSG CViewComTestView: : OnMainMsg)
END_MESSAGE_MAP ()
Child window send a message to the parent window:
Void CMySubDlg: : OnButton1 ()
{
//TODO: Add your the control notification handler code here
Cstrings strEdit;
GetDlgItemText (IDC_EDIT1 strEdit);
//get a handle to the parent window
HWND HWND=this - & gt; The GetParent () - & gt; GetSafeHwnd ();
//send a message to the parent window
If (hWnd==NULL) MessageBox (_T (" get the parent window handle failure!" ));
: : SendNotifyMessage (hWnd WM_MAIN_MSG, (WPARAM) & amp; StrEdit, NULL);
}
The message response function of the parent window: (child window when sending a message window without any response)
Afx_msg LRESULT CViewComTestView: : OnMainMsg (WPARAM WPARAM, LPARAM LPARAM)
{
WParam cstrings * strMsg=(cstrings *);
SetDlgItemText (IDC_EDIT1. * strMsg);
return 0;
}
Pray god give directions!!!!!!!!!!
CodePudding user response:
SendNotifyMessage messages sent not into circular queue.Using SendMessage look,
CodePudding user response:
Dlg1. Create (IDD_DIALOG1, this);//try to specify the parent windowCodePudding user response:
HWND HWND=this - & gt; The GetParent () - & gt; GetSafeHwnd ();Don't pass this way for the parent window handle
When creating a child window handle to the parent window when a variable of an assignment to the child window to use in the child window
CodePudding user response:
The