Again a question...

How do i get the handle of the main window
of the process that just called one of my own DLL function?

without requiring it to be a parameter on my own DLL function.
Posted on 2002-10-06 17:47:11 by BogdanOntanu
GetActiveWindow does what you want I think.
Posted on 2002-10-06 18:18:45 by _js_

Again a question...

How do i get the handle of the main window
of the process that just called one of my own DLL function?

without requiring it to be a parameter on my own DLL function.


Look into this thread.
You might need to pass the process ID of the calling process to the DLL and do EnumWindows with GetWindowThreadProcessId in EnumWindowsProc. Just compare the PIDs until you find the correct one and return the HWND.
Posted on 2002-10-07 01:02:51 by bazik
For whom might intrest:

GetForegroundWindow() worked ... even if i first thought it will not :(

Thanks bazik ... i was going to do what you suggested but because it was more complicated i give the above function one last chance and it worked... however GetActiveWindow is not working. Good to know.
Posted on 2002-10-12 14:51:37 by BogdanOntanu
Erm... and what happens, pray tell, if the window that called your DLL happens to not be in the foreground? ;)

I think Bazik's solution is the safest bet.
Posted on 2002-10-12 15:29:12 by iblis