I have a library function (that does not know anything about the application its linked to) that sometimes opens a window.
If the application's main window is closed while the library window is open, the process gets into a weird state that wont exit, even after the library function widow is closed.
If the library function is "owned" by the main window, everything closed fine. However, in general the library function has no idea what windows are open.
The standard windows functions appear to either search all windows for all processes, or they require a window handle to find another window handle.
How do I find ANY top level window of the process my function is running in?
=======================================================================
Solution, clunky but tested, works.
static BOOL CALLBACK MyEnumThreadWndProc( HWND hwnd, LPARAM param ){
HWND *oW = reinterpret_cast<hwnd*> (param);
(*oW) = hwnd;
return false;
}
...
HWND oWind=0;
EnumThreadWindows(GetCurrentThreadId(), &MyEnumThreadWndProc, reinterpret_cast<lparam>(&oWind) );