Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to get window list

How to get window list

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    manish patel
    wrote on last edited by
    #1

    Hello all I want to develop one application in which i want to know the list of all open window either it is minimized Is this possible to know?? If possible then provide some code Snippets. Thanks in advance.

    Manish Patel. B.E. - Information Technology.

    I S T 3 Replies Last reply
    0
    • M manish patel

      Hello all I want to develop one application in which i want to know the list of all open window either it is minimized Is this possible to know?? If possible then provide some code Snippets. Thanks in advance.

      Manish Patel. B.E. - Information Technology.

      I Offline
      I Offline
      Iain Clarke Warrior Programmer
      wrote on last edited by
      #2

      manish.patel wrote:

      If possible then provide some code Snippets.

      I refuse your demand! I will however point you in the right direction... (OK, *a* direction). A B.E. in information technology can surely read documentation for the details. You can use GetDesktopWindow to get the, um, desktop window. Then either GetWindow with parameters GW_CHILD or GW_NEXT. You can check with functions such as IsWindowVisible etc to filter out various states. Alternately, you could use EnumChildWindows to do some of the work for you, at the expense of writing a second function. Iain.

      CPallini no longer cares if Iain Clarke appears or not. /sad

      C 1 Reply Last reply
      0
      • I Iain Clarke Warrior Programmer

        manish.patel wrote:

        If possible then provide some code Snippets.

        I refuse your demand! I will however point you in the right direction... (OK, *a* direction). A B.E. in information technology can surely read documentation for the details. You can use GetDesktopWindow to get the, um, desktop window. Then either GetWindow with parameters GW_CHILD or GW_NEXT. You can check with functions such as IsWindowVisible etc to filter out various states. Alternately, you could use EnumChildWindows to do some of the work for you, at the expense of writing a second function. Iain.

        CPallini no longer cares if Iain Clarke appears or not. /sad

        C Offline
        C Offline
        CPallini
        wrote on last edited by
        #3

        Iain Clarke wrote:

        CPallini no longer cares if Iain Clarke appears or not. /sad

        Who did tell you it? He cares for sure. :-D

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

        I 1 Reply Last reply
        0
        • C CPallini

          Iain Clarke wrote:

          CPallini no longer cares if Iain Clarke appears or not. /sad

          Who did tell you it? He cares for sure. :-D

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

          I Offline
          I Offline
          Iain Clarke Warrior Programmer
          wrote on last edited by
          #4

          Well, I had by "special request", then "in spite of being asked not to", so it seemed about time for a different variation! Iain.

          Iain Clarke appears because CPallini still cares.

          1 Reply Last reply
          0
          • M manish patel

            Hello all I want to develop one application in which i want to know the list of all open window either it is minimized Is this possible to know?? If possible then provide some code Snippets. Thanks in advance.

            Manish Patel. B.E. - Information Technology.

            S Offline
            S Offline
            Stephen Hewitt
            wrote on last edited by
            #5

            Here's a start:

            // VanillaConsole.cpp : Defines the entry point for the console application.
            //
             
            #include "stdafx.h"
            #include <windows.h>
            #include <tchar.h>
            #include <malloc.h>
            #include <iostream>
            using namespace std;
             
            BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam)
            {
            int len = GetWindowTextLength(hWnd);
            if (len == 0 )
            {
            return true;
            }
             
            LPTSTR pText = static_cast<LPTSTR>(_alloca((len+1)*sizeof(TCHAR)));
             
            GetWindowText(hWnd, pText, len+1);
             
            cout << pText << endl;
             
            return true;
            }
             
            int main()
            {
            EnumWindows(&EnumWindowsProc, 0);
             
            return 0;
            }

            Steve

            M 1 Reply Last reply
            0
            • S Stephen Hewitt

              Here's a start:

              // VanillaConsole.cpp : Defines the entry point for the console application.
              //
               
              #include "stdafx.h"
              #include <windows.h>
              #include <tchar.h>
              #include <malloc.h>
              #include <iostream>
              using namespace std;
               
              BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam)
              {
              int len = GetWindowTextLength(hWnd);
              if (len == 0 )
              {
              return true;
              }
               
              LPTSTR pText = static_cast<LPTSTR>(_alloca((len+1)*sizeof(TCHAR)));
               
              GetWindowText(hWnd, pText, len+1);
               
              cout << pText << endl;
               
              return true;
              }
               
              int main()
              {
              EnumWindows(&EnumWindowsProc, 0);
               
              return 0;
              }

              Steve

              M Offline
              M Offline
              manish patel
              wrote on last edited by
              #6

              Hey Steve Thanks for your kind reply and providing code for me.. Again Thanks bye..

              Manish Patel. B.E. - Information Technology.

              1 Reply Last reply
              0
              • M manish patel

                Hello all I want to develop one application in which i want to know the list of all open window either it is minimized Is this possible to know?? If possible then provide some code Snippets. Thanks in advance.

                Manish Patel. B.E. - Information Technology.

                T Offline
                T Offline
                ThatsAlok
                wrote on last edited by
                #7

                try FindWindow and FindWindowEx combination [][^]

                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
                Never mind - my own stupidity is the source of every "problem" - Mixture

                cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You/codeProject$$>

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups