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. Get the caption of active window...

Get the caption of active window...

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharpvisual-studio
16 Posts 6 Posters 1 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.
  • R Rajkumar R

    see this, ::GetActiveWindow()->GetWindowText(strCap); //ERROR It looks like calling a member function using a class instance, possibly CWnd * (from GetActiveWindow), and :: makes the Global scope rather CWnd.

    Rajesh R Subramanian wrote:

    Only if he is using MFC

    I implicitly telling him to move to MFC. :)

    R Offline
    R Offline
    Rajesh R Subramanian
    wrote on last edited by
    #7

    Rajkumar R wrote:

    I implicitly telling him to move to MFC.

    :laugh:

    Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

    1 Reply Last reply
    0
    • K krmed

      Or he can combine them into one:

      GetWindowText(GetActiveWindow(), strCap, sizeof(strcap));

      That assumes that strcap is a definitive size. The last parameter may need to change if it happens to be a CString or strring or pointer to some buffer. Good luck.

      Karl - WK5M PP-ASEL-IA (N43CS) PGP Key: 0xDB02E193 PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193

      D Offline
      D Offline
      Demian Panello
      wrote on last edited by
      #8

      Oh yeah, of course.

      Demian. "I have always wished that my computer would be as easy to use as my telephone. My wish has come true. I no longer know how to use my telephone." -Bjarne Stroustrup, computer science professor, designer of C++ programming language (1950- )

      1 Reply Last reply
      0
      • R Rajesh R Subramanian

        Rajkumar R wrote:

        use CWnd::GetActiveWindow()

        Only if he is using MFC. :)

        Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

        P Offline
        P Offline
        ptr_Electron
        wrote on last edited by
        #9

        yeap am using MFC, thank you all Friends... CWnd::GetActiveWindow()->GetWindowText(strCap); did the job

        1 Reply Last reply
        0
        • R Rajkumar R

          see this, ::GetActiveWindow()->GetWindowText(strCap); //ERROR It looks like calling a member function using a class instance, possibly CWnd * (from GetActiveWindow), and :: makes the Global scope rather CWnd.

          Rajesh R Subramanian wrote:

          Only if he is using MFC

          I implicitly telling him to move to MFC. :)

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

          Rajkumar R wrote:

          I implicitly telling him to move to MFC.

          Why this bad suggestion? :-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

          R 1 Reply Last reply
          0
          • R Rajesh R Subramanian

            Rajkumar R wrote:

            use CWnd::GetActiveWindow()

            Only if he is using MFC. :)

            Nobody can give you wiser advice than yourself. - Cicero .·´¯`·->Rajesh<-·´¯`·. Codeproject.com: Visual C++ MVP

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

            Probably he is (there's namespace scope specification). :)

            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

            R 1 Reply Last reply
            0
            • C CPallini

              Rajkumar R wrote:

              I implicitly telling him to move to MFC.

              Why this bad suggestion? :-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

              R Offline
              R Offline
              Rajkumar R
              wrote on last edited by
              #12

              to use CWnd::GetActiveWindow() :-D

              1 Reply Last reply
              0
              • C CPallini

                Probably he is (there's namespace scope specification). :)

                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

                R Offline
                R Offline
                Rajkumar R
                wrote on last edited by
                #13

                namespace scope can be used in non-MFC C++. :)

                C 1 Reply Last reply
                0
                • R Rajkumar R

                  namespace scope can be used in non-MFC C++. :)

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

                  It is redundant: if you don't need it, don't use it. :-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

                  R 1 Reply Last reply
                  0
                  • C CPallini

                    It is redundant: if you don't need it, don't use it. :-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

                    R Offline
                    R Offline
                    Rajkumar R
                    wrote on last edited by
                    #15

                    int CMyNonMFCFrameWorkNameSpace::GetWindowText(HWND hWnd, LPTSTR lpString, int nMaxCount ) { CMyNonMFCFrameWorkLog log("GetWindowText"); return ::GetWindowText(hWnd, lpString, nMaxCount); } There are useful example with other API's, though the above is not a so useful example, it is possible to have such situation that is not redundant. otherwise namespace concept is not needed. I can give example exactly that match OPs statement without MFC classes and other namespace. :)

                    C 1 Reply Last reply
                    0
                    • R Rajkumar R

                      int CMyNonMFCFrameWorkNameSpace::GetWindowText(HWND hWnd, LPTSTR lpString, int nMaxCount ) { CMyNonMFCFrameWorkLog log("GetWindowText"); return ::GetWindowText(hWnd, lpString, nMaxCount); } There are useful example with other API's, though the above is not a so useful example, it is possible to have such situation that is not redundant. otherwise namespace concept is not needed. I can give example exactly that match OPs statement without MFC classes and other namespace. :)

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

                      Rajkumar R wrote:

                      the above is not a so useful example

                      :-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

                      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