Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to detect spawning and destruction of windows?

How to detect spawning and destruction of windows?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 298 Views
  • 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.
  • G Offline
    G Offline
    grainyblob
    wrote on last edited by
    #1

    Hi. I am not quite sure if this is the correct place to put this, but I am using Qt for my project, so I believe it is fine.
    I would like to write my own shell for windows 11. I thought I would first work on the taskbar, and so I began first with a QTimer which constantly kept checking for processes with a window title every 100ms. This would add a button to the taskbar for that window.

    It didnt seem like a good choice though. It would drive up the CPU usage and also I wanted to learn if there was a better way, more optimized to do it. I tried to use wmi as suggested by https://stackoverflow.com/questions/1986249/net-process-monitor/1986856#1986856 (for C#, not C++) and write my own implementation but it resulted in bugs.

    The program would crash every so often when a new window was spawned, and some windows wouldn't even open. Eg. if i opened notepad, it would show the icon on the windows taskbar but the window would never appear. when my program crashes, it appears then.

    My project uses LLVM, written in Qt framework for C++, any alternative methods and suggestions are appreciated 😊

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SamiV123
      wrote on last edited by SamiV123
      #2

      I think you can do this with a so called shell hook library.

      https://learn.microsoft.com/en-us/windows/win32/winmsg/about-hooks

      See the part about monitoring messages. When a new window is created a WM_CREATE message is posted to the window's event queue.

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved