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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Get Windows TaskBar Height & width

Get Windows TaskBar Height & width

Scheduled Pinned Locked Moved C / C++ / MFC
c++json
5 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.
  • Q Offline
    Q Offline
    QuickDeveloper
    wrote on last edited by
    #1

    hi I want to get the Windows TaskBar Height and Width in MFC. Any API's are welcome Thanx in advance

    "Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"

    D D M 3 Replies Last reply
    0
    • Q QuickDeveloper

      hi I want to get the Windows TaskBar Height and Width in MFC. Any API's are welcome Thanx in advance

      "Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"

      D Offline
      D Offline
      Daniel Kanev
      wrote on last edited by
      #2

      Hello! HWND hWnd = FindWindow("Shell_TrayWnd",""); if(hWnd != NULL) { RECT rect; GetWindowRect(hWnd, &rect); int height = rect.right - rect.left; int width = rect.bottom - rect.top; }

      1 Reply Last reply
      0
      • Q QuickDeveloper

        hi I want to get the Windows TaskBar Height and Width in MFC. Any API's are welcome Thanx in advance

        "Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        I suppose you could subtract the height of the desktop's client area (i.e., SystemParametersInfo(SPI_GETWORKAREA, ...)) from the height of the screen (i.e., GetSystemMetrics(SM_CYSCREEN)). The difference would be the height of the taskbar. For an MFC solution, something like:

        CWnd *pTaskbar = CWnd::FindWindow("Shell_TrayWnd", NULL);
        CRect rc;
        pTaskbar->GetWindowRect(rc);
        int nWidth = rc.Width();
        int nHeight = rc.Height();


        "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

        "Judge not by the eye but by the heart." - Native American Proverb

        1 Reply Last reply
        0
        • Q QuickDeveloper

          hi I want to get the Windows TaskBar Height and Width in MFC. Any API's are welcome Thanx in advance

          "Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"

          M Offline
          M Offline
          Michael Dunn
          wrote on last edited by
          #4

          Call SHAppBarMessage(ABM_GETTASKBARPOS). No sense searching through windows when there's an API that does exactly what you want.

          --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

          F 1 Reply Last reply
          0
          • M Michael Dunn

            Call SHAppBarMessage(ABM_GETTASKBARPOS). No sense searching through windows when there's an API that does exactly what you want.

            --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ

            F Offline
            F Offline
            FrecherxDachs
            wrote on last edited by
            #5

            According to the API description you have to pass the hwnd of your taskbar. :/

            SHAppBarMessage(ABM_QUERYPOS, pabd);

            pabd
            A pointer to an APPBARDATA structure. The uEdge member specifies a screen edge, and the rc member contains the proposed bounding rectangle. When the SHAppBarMessage function returns, rc contains the approved bounding rectangle. You must specify the cbSize, hWnd, uEdge, and rc members when sending this message; all other members are ignored.

            Source: msdn

            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