I'm making a program, with c++ and winapi, where you can click a button, then select a window and it changes the transparency of that window.
I have no problems of making the window transparent, but i can't get the hwnd of a window.
When I use this function the program just crashes (No errors are being printed to the console).
HWND getHWND(HWND self)
{
HWND found = GetForegroundWindow();
if(found == self || found == NULL)
return getHWND(self);
return found;
}
I tried using this, but I don't like it, because the user has only 2 seconds to click on another window. (I'know I could use a bigger delay, but then it might be to much.. so this isn't optimal)
HWND getHWND()
{
Sleep(2000);
return GetForegroundWindow();
}