Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Grab Key board focus

Grab Key board focus

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aks
    wrote on last edited by
    #1

    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

    _ 1 Reply Last reply
    0
    • A 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

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      Try SetForegroundWindow[^] or BringWindowToTop[^]

      «_Superman_» I love work. It gives me something to do between weekends.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups