1. Use static member variables
Set the static member variable static ms_str in other windows, and
assign the content of the control you want to access to the static member variable in advance, so that the data can be accessed through the class name
SetDlgItemText(IDC_STATIC1, COtherDlg::ms_str); //COtherDlg其他窗口类名
2. Use the window handle
CString str1;
HWND hWnd = ::FindWindow(NULL, _T("其他窗口的名称")); //获取窗口的句柄
COtherDlg* pWnd = (COtherDlg*)COtherDlg::FromHandle(hWnd);//由句柄得到对话框的对象指针,COtherDlg其他窗口类名
CEdit* pEdit = (CEdit*)pWnd->GetDlgItem(IDC_EDIT1); //获取其他窗口控件
pEdit ->GetWindowText(str1); //获取控件内容