Search code examples
c++windowsuser-interfacewinapiwindowing

Is a control tree cached after the first call to FindWindowEx/EnumChildWindows?


I noticed that if you call FindWindowEx or EnumChildWindows against a hWnd that belongs to a window that's not in the foreground, i.e. minimized, then they don't report any children. On the other hand if I first call SetForegroundWindow against the window I'm querying, and after that FindWindowEx or EnumChildWindows, they report all the children. Next calls report all the children even if the window I'm interested in is not in foreground. It's almost it does some sort of caching after the first call?


Solution

  • Is this a window in your own application, or are you investigating what a third-party application does?

    I would guess that the application only creates its child windows the first time it is brought into the foreground; this would explain the behaviour you are seeing. To my knowledge, EnumChildWindows does not perform any caching.