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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Why do I receive WM_SETFOCUS only once?

Why do I receive WM_SETFOCUS only once?

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 3 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.
  • L Offline
    L Offline
    linjie
    wrote on last edited by
    #1

    My program has a view inherit from CView,when it receive WM_SETFOCUS I want do something,but the view receive WM_SETFOCUS message only once when program starting.why? linjie

    D V 2 Replies Last reply
    0
    • L linjie

      My program has a view inherit from CView,when it receive WM_SETFOCUS I want do something,but the view receive WM_SETFOCUS message only once when program starting.why? linjie

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      linjie wrote: the view receive WM_SETFOCUS message only once when program starting. What are you using to verify this? I tried this and used Spy++ to see the messages. The application received multiple WM_SETFOCUS messages.


      Five birds are sitting on a fence. Three of them decide to fly off. How many are left?

      1 Reply Last reply
      0
      • L linjie

        My program has a view inherit from CView,when it receive WM_SETFOCUS I want do something,but the view receive WM_SETFOCUS message only once when program starting.why? linjie

        V Offline
        V Offline
        vcplusplus
        wrote on last edited by
        #3

        Because CView has the focus of the OS. From MSDN Library ----------------- The WM_SETFOCUS message is sent to a window after it has gained the keyboard focus. The SetFocus function sends a WM_KILLFOCUS message to the window that loses the keyboard focus and a WM_SETFOCUS message to the window that receives the keyboard focus. It also activates either the window that receives the focus or the parent of the window that receives the focus. If a window is active but does not have the focus, any key pressed will produce the WM_SYSCHAR, WM_SYSKEYDOWN, or WM_SYSKEYUP message. If the VK_MENU key is also pressed, the lParam parameter of the message will have bit 30 set. Otherwise, the messages produced do not have this bit set. By using the AttachThreadInput function, a thread can attach its input processing to another thread. This allows a thread to call SetFocus to set the keyboard focus to a window associated with another thread's message queue.

        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