Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need to know if there are any non-minimized windows, that is, if there are any or several windows that are visible... in other words, if Windows is displaying only the Desktop...

What I have tried:

Trying to find out something in Google Search.....
Posted
Updated 22-Feb-21 7:13am
v2

You would need to use the Win32 functions: EnumWindows function (winuser.h) - Win32 apps | Microsoft Docs[^] and IsIconic function (winuser.h) - Win32 apps | Microsoft Docs[^] via C/C++, as .NET does not have equivalents as far as I am aware.
 
Share this answer
 
List all desktop windows code example: [^]
/// <summary>
/// EnumDesktopWindows Demo - shows the caption of all desktop windows.
/// Authors: Svetlin Nakov, Martin Kulov
/// Bulgarian Association of Software Developers - http://www.devbg.org/en/
/// </summary>
Perhaps off-topic, but, fyi: in a WinForm Application: you can use Application.OpenForms to get a list of all open Forms, including minimized Forms.

Code example:
private void button1_Click(object sender, EventArgs e)
{  
    int notMinimizedFormCnt = 0;

    foreach (Form frm in Application.OpenForms)
    {
        // exclude the Form in which this code is called ?
        if (frm == this) continue;

        if (frm.WindowState != FormWindowState.Minimized) notMinimizedFormCnt++;
    }

    label1.Text = notMinimizedFormCnt.ToString();
}
Note that if you have called Hide() on a Form, it still shows up in the Application.OpenForms collection: it's WindowState property is not changed ! imho, WinForms should provide another value in the WindowState enum for a hidden Form.
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900