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. FindWindow

FindWindow

Scheduled Pinned Locked Moved C / C++ / MFC
jsonhelptutorialquestion
14 Posts 7 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
    msr_codeproject
    wrote on last edited by
    #1

    Hi, I want to get handle of an already opened window. For this I can not use FindWindow() API as Window's title is not known. And also, I can not use Class name as it is not a registered class. Can anybody tell me how to solve this issue? Thanks in advance. Regards MSR

    CPalliniC M 2 Replies Last reply
    0
    • M msr_codeproject

      Hi, I want to get handle of an already opened window. For this I can not use FindWindow() API as Window's title is not known. And also, I can not use Class name as it is not a registered class. Can anybody tell me how to solve this issue? Thanks in advance. Regards MSR

      CPalliniC Offline
      CPalliniC Offline
      CPallini
      wrote on last edited by
      #2

      As far as I know, every window must belong to a registered class.

      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
      [My articles]

      In testa che avete, signor di Ceprano?

      M 1 Reply Last reply
      0
      • CPalliniC CPallini

        As far as I know, every window must belong to a registered class.

        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
        [My articles]

        M Offline
        M Offline
        msr_codeproject
        wrote on last edited by
        #3

        Hi, thanks for the reply. But here we are not regidtering class explicitly. This is the code

        CDlg* pDlg = new CDlg;

        DialogBoxParam(hInt, MAKEINTRESOURCE(IDD_DLG),
        hWnd, (DLGPROC)(*pDlg ).WindowMapProc, (LPARAM)pDlg);

        I have tried using

        FindWindow("CDlg", NULL);

        But it is not working. Now , how to go forward to find IDD_DLG. Regards MSR

        CPalliniC L 2 Replies Last reply
        0
        • M msr_codeproject

          Hi, thanks for the reply. But here we are not regidtering class explicitly. This is the code

          CDlg* pDlg = new CDlg;

          DialogBoxParam(hInt, MAKEINTRESOURCE(IDD_DLG),
          hWnd, (DLGPROC)(*pDlg ).WindowMapProc, (LPARAM)pDlg);

          I have tried using

          FindWindow("CDlg", NULL);

          But it is not working. Now , how to go forward to find IDD_DLG. Regards MSR

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          Your windows is child of the hWnd one and as such must be searched for.

          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
          [My articles]

          In testa che avete, signor di Ceprano?

          T 1 Reply Last reply
          0
          • M msr_codeproject

            Hi, thanks for the reply. But here we are not regidtering class explicitly. This is the code

            CDlg* pDlg = new CDlg;

            DialogBoxParam(hInt, MAKEINTRESOURCE(IDD_DLG),
            hWnd, (DLGPROC)(*pDlg ).WindowMapProc, (LPARAM)pDlg);

            I have tried using

            FindWindow("CDlg", NULL);

            But it is not working. Now , how to go forward to find IDD_DLG. Regards MSR

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            CDlg is the class which creates the dialog window and must use some Windows classname, either one of the predefined classes, or a new one registered before creation. What is the base of CDlg? [edit]It is also likely that the dialog will contain a title that you can search for.[/edit]

            Unrequited desire is character building. OriginalGriff

            CPalliniC M 2 Replies Last reply
            0
            • M msr_codeproject

              Hi, I want to get handle of an already opened window. For this I can not use FindWindow() API as Window's title is not known. And also, I can not use Class name as it is not a registered class. Can anybody tell me how to solve this issue? Thanks in advance. Regards MSR

              M Offline
              M Offline
              My Bones
              wrote on last edited by
              #6

              Use WindowFromPoint Api if you know approx location in x,y cords this returns handle e.g.

              [DllImport("user32.dll")]
              static extern IntPtr WindowFromPoint(POINT Point);

              The trick is making sure unknown application starts in a known place. Regards David Rathbone

              C 1 Reply Last reply
              0
              • L Lost User

                CDlg is the class which creates the dialog window and must use some Windows classname, either one of the predefined classes, or a new one registered before creation. What is the base of CDlg? [edit]It is also likely that the dialog will contain a title that you can search for.[/edit]

                Unrequited desire is character building. OriginalGriff

                CPalliniC Offline
                CPalliniC Offline
                CPallini
                wrote on last edited by
                #7

                The DialogBoxParam function automatically assigns the predefined class name "#32770" (i.e. dialog box, see here[^]) to the newly created dialog.

                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
                [My articles]

                In testa che avete, signor di Ceprano?

                L 1 Reply Last reply
                0
                • M My Bones

                  Use WindowFromPoint Api if you know approx location in x,y cords this returns handle e.g.

                  [DllImport("user32.dll")]
                  static extern IntPtr WindowFromPoint(POINT Point);

                  The trick is making sure unknown application starts in a known place. Regards David Rathbone

                  C Offline
                  C Offline
                  Code o mat
                  wrote on last edited by
                  #8

                  Not to mention it musn't be covered by any other window...i doubt this method would be reliable.

                  > The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<

                  1 Reply Last reply
                  0
                  • CPalliniC CPallini

                    The DialogBoxParam function automatically assigns the predefined class name "#32770" (i.e. dialog box, see here[^]) to the newly created dialog.

                    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
                    [My articles]

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #9

                    I think the OP would like to know this. ;)

                    Unrequited desire is character building. OriginalGriff

                    CPalliniC 1 Reply Last reply
                    0
                    • L Lost User

                      I think the OP would like to know this. ;)

                      Unrequited desire is character building. OriginalGriff

                      CPalliniC Offline
                      CPalliniC Offline
                      CPallini
                      wrote on last edited by
                      #10

                      So let he/she know. :-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
                      [My articles]

                      In testa che avete, signor di Ceprano?

                      1 Reply Last reply
                      0
                      • L Lost User

                        CDlg is the class which creates the dialog window and must use some Windows classname, either one of the predefined classes, or a new one registered before creation. What is the base of CDlg? [edit]It is also likely that the dialog will contain a title that you can search for.[/edit]

                        Unrequited desire is character building. OriginalGriff

                        M Offline
                        M Offline
                        msr_codeproject
                        wrote on last edited by
                        #11

                        Hi, CDlg is derived from CDlgSlct. I have tried using the base class also. But of no use. Regards MSR

                        L enhzflepE 2 Replies Last reply
                        0
                        • M msr_codeproject

                          Hi, CDlg is derived from CDlgSlct. I have tried using the base class also. But of no use. Regards MSR

                          L Offline
                          L Offline
                          Lost User
                          wrote on last edited by
                          #12

                          And what is CDlgSlct derived from? You should know and understand your inheritance tree. In either case see the message from CPallini which tells you what identifier to use for the Dialog windows class.

                          Unrequited desire is character building. OriginalGriff

                          1 Reply Last reply
                          0
                          • M msr_codeproject

                            Hi, CDlg is derived from CDlgSlct. I have tried using the base class also. But of no use. Regards MSR

                            enhzflepE Offline
                            enhzflepE Offline
                            enhzflep
                            wrote on last edited by
                            #13

                            Just to be clear, a C++ class should not be confused with a windows class. Use Spy++, it will tell you the (windows) class name of any window you care to query. Do this to a dialog, and you'll see the name that cPallini provided - the same class-name that you should use with FindWindow. To that end, which C++ class you inherit from is somewhat irrelevant. You just need the windows class name for a dialog box.

                            1 Reply Last reply
                            0
                            • CPalliniC CPallini

                              Your windows is child of the hWnd one and as such must be searched for.

                              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
                              [My articles]

                              T Offline
                              T Offline
                              Tracy Software
                              wrote on last edited by
                              #14

                              Use EnumWindows EnumChildWindows and look for #32778 class name use the SPY++ to test it Mithrill :-\

                              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