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. How to set keyboard focus to the other windows in the z-order?

How to set keyboard focus to the other windows in the z-order?

Scheduled Pinned Locked Moved C / C++ / MFC
jsonhelptutorialquestioncareer
2 Posts 2 Posters 1 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.
  • J Offline
    J Offline
    Joseph Marzbani
    wrote on last edited by
    #1

    I want to bring the window that has been activated before my application's window in the z-order and set keyboard focus to it. there are 3 API related to this job in Windows APIs: BringWindowToTop (...) SetActivatedWindow (...) SetForegroundWindow (...) I've been trying all possible combination of these functions since yesterday, but I failed. The problem is I can bring the windows I like to the front, but those never get keyboard-focused. I've also tried ShowWindow (...), but It failed to set the focus to the windows too. what to do?

    L 1 Reply Last reply
    0
    • J Joseph Marzbani

      I want to bring the window that has been activated before my application's window in the z-order and set keyboard focus to it. there are 3 API related to this job in Windows APIs: BringWindowToTop (...) SetActivatedWindow (...) SetForegroundWindow (...) I've been trying all possible combination of these functions since yesterday, but I failed. The problem is I can bring the windows I like to the front, but those never get keyboard-focused. I've also tried ShowWindow (...), but It failed to set the focus to the windows too. what to do?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      According to the MSDN documentation for SetFocus()[^] you can only set the focus to a window that is attached to your own message queue.

      Just say 'NO' to evaluated arguments for diadic functions! Ash

      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