0

For the 2 parameters lpClassName and lpWindowName in FindWindow, what do i throw in there to hide all open windows? Is this possible? MSDN makes it sound like if both parameters are null, that will do the trick, but before i test it, i want to make sure that works so i dont have to restart my computer before i reverse the action

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by clutchkiller
0

FindWindow will only return a handle to one window, to do this you will have to loop through all opened applications and hide them one at a time. Try looking up the EnumWindows function, it may provide your solution.

0

I looked that function up, but im still confused, could you elaborate on a proper method to hide all open windows? Im still a new programmer/windows programmer.

0
#include <windows.h>
#include <iostream>
#include <vector>

using namespace std;

std::vector<HWND> vis;

bool EnumWindowsProc(HWND hWnd, long lParam)
{

    if (IsWindowVisible(hWnd)) {
        vis.push_back(hWnd);
    }

    return true;
}


int main()
{
    EnumWindows((WNDENUMPROC)EnumWindowsProc, 0);

    for (int i=0; i < (int)vis.size(); i++) {
        ShowWindow(vis[i], SW_HIDE);
    }

    Sleep(10000);

    for (int i=0; i < (int)vis.size(); i++) {
        ShowWindow(vis[i], SW_SHOW);
    }


    return 0;
}

Just remember to add code which prevents you from hiding the console window (ie: the one that they need in order to type in their password). This program as it is now, simply hides all windows for a short amount of time, and then makes them show up again.

0

thanks comatose, ill dink around with what you just showed me and make it work in the proper context im looking for.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.