Grab Key board focus
-
hi, I have 2 applications A & B. They are started independently. Application B can show/hide Application A.( Using named events and threads) Scenario 1: A is displayed. A is hide( SW_HIDE ) by itself by clicking a button on A. A is showed from B. ::SetWindowPos( this->m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE ); ::SetWindowPos( this->m_hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE ); SetActiveWindow(); SetFocus(); GetDlgItem( IDC_EDIT1)->SetFocus(); In this case A is displayed and has the Key board focus. Scenario 2: A is displayed. A is hide from B. A is showed from B. In this case A is displayed and has the cursor is blinking on the edit control of A. But it doesn't have the Key board focus. i.e. if I press the tab to change the focus, application B's tab order is changing. Could you please let me know how can I get the key board focus on above case( Scenario2). I know that AttchThreadInput can solve this issue. But I need to know whether any alternate solution for this.
aks
-
hi, I have 2 applications A & B. They are started independently. Application B can show/hide Application A.( Using named events and threads) Scenario 1: A is displayed. A is hide( SW_HIDE ) by itself by clicking a button on A. A is showed from B. ::SetWindowPos( this->m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE ); ::SetWindowPos( this->m_hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE ); SetActiveWindow(); SetFocus(); GetDlgItem( IDC_EDIT1)->SetFocus(); In this case A is displayed and has the Key board focus. Scenario 2: A is displayed. A is hide from B. A is showed from B. In this case A is displayed and has the cursor is blinking on the edit control of A. But it doesn't have the Key board focus. i.e. if I press the tab to change the focus, application B's tab order is changing. Could you please let me know how can I get the key board focus on above case( Scenario2). I know that AttchThreadInput can solve this issue. But I need to know whether any alternate solution for this.
aks
Try SetForegroundWindow[^] or BringWindowToTop[^]
«_Superman_» I love work. It gives me something to do between weekends.