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. System wide CBT-Hook reacts only to windows in creating process

System wide CBT-Hook reacts only to windows in creating process

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
1 Posts 1 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.
  • N Offline
    N Offline
    Nick Nougat
    wrote on last edited by
    #1

    Hi! I need to be able to control the life time of a window that was created in a different process. For that purpose I set a CBT-hook to check for the HCBT_DESTROYWND notification. The problem is that I only get notifications for destroyed windows that were created by threads in my own process. The hook callback function is, as the docs request, in a separate dll. I use this function call to set the hook: ::SetWindowsHookEx(WH_CBT, _CBTProc, hInstance, NULL); Here, hInstance is the handle to the loaded separate dll and _CBTProc is the pointer to my callback inside that dll. As I said: it works, I get notifications, but ONLY for windows owned by threads in my process. That's not what I consider a "system wide" hook! As a workaround I also tried to get the ID of thread owning the window I want to be informed about via GetWindowThreadProcessID() and used that ID instead of the NULL parameter when setting the hook - to no avail... In this same separate dll I use a system wide mouse hook. This mouse hook _does_ work however. So my question is: did I miss something important concerning CBT hooks? How can I get a really system wide CBT hook installed? Thanks in advance Nick

    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