How can I change focus between child windows within an MDI application
-
Hello everyone, I am having trouble changing focus from child window to another. Of course, I want to be able to do that without using the mouse or keyboard, but the code itself. The application is used in an automated video grabbing. This is the code I have written: class CMyAppDoc : public CDocument { public: CView *pOldActiveView; .. .. CMyAppDoc::OnButton1() { CMDIFrameWnd* pMainWnd = (CMDIFrameWnd*)AfxGetMainWnd(); // Get the active MDI child window. CMDIChildWnd* pChild = (CMDIChildWnd*)pMainWnd->MDIGetActive(); // Get the active view attached to the active MDI child window. pOldActiveView = pChild->GetActiveView(); } After clicking Button1 I manually change the focus by the mouse and then click Button2, which includes the following code: CMyAppDoc::Button2() { pOldActiveView->SetActiveWindow(); } Summarizing the code, clicking the Button1 should assign the pointer pOldActiveView the address of the active child window during the time it is pressed. Then After manually chainging the focus to another child window the active child window will change but the pointer is still pointing to our old active child window. So then by clicking Button2 should set the focus on the old child window, but unfortunately nothing changes. I have also tried "pOldActiveView->SetFocus()" instead but didn't change anything as well. Any help will be highly appreciated.