CString strName("");// got caption
CWnd * cw = GetParent();
cw->GetWindowText(strName); //got the caption of father's window
CWnd * cwd = GetDlgItem(IDC_BUTTON1);
cwd->GetWindowText(strName); //got the caption of IDC_BUTTON1
CWnd * pWnd = GetActiveWindow();
pWnd ->GetWindowText(strName); //got the caption of activewindow, also means the current window.