locked
how can i get the height of the windows Taskbar?!?!? RRS feed

  • Question

  • hello... how can i get the task bar height?!?!?
    Thursday, September 10, 2009 6:36 PM

Answers

  • Yes.  There's another way.  Use the Screen class.  The taskbar is the difference between its Bounds and WorkingArea properties.  You probably only really need WorkingArea.

    Hans Passant.
    • Marked as answer by liurong luo Friday, September 18, 2009 2:55 AM
    Thursday, September 10, 2009 9:07 PM
  • You will have to use P/Invoke

    http://msdn.microsoft.com/en-us/library/bb762108%28VS.85%29.aspx

    http://www.pcreview.co.uk/forums/thread-3387688.php


    John Grove - TFD Group, Senior Software Engineer, EI Division, http://www.tfdg.com
    • Edited by JohnGrove Thursday, September 10, 2009 9:12 PM
    • Marked as answer by liurong luo Friday, September 18, 2009 2:55 AM
    Thursday, September 10, 2009 6:38 PM

All replies

  • You will have to use P/Invoke

    http://msdn.microsoft.com/en-us/library/bb762108%28VS.85%29.aspx

    http://www.pcreview.co.uk/forums/thread-3387688.php


    John Grove - TFD Group, Senior Software Engineer, EI Division, http://www.tfdg.com
    • Edited by JohnGrove Thursday, September 10, 2009 9:12 PM
    • Marked as answer by liurong luo Friday, September 18, 2009 2:55 AM
    Thursday, September 10, 2009 6:38 PM
  • Yes.  There's another way.  Use the Screen class.  The taskbar is the difference between its Bounds and WorkingArea properties.  You probably only really need WorkingArea.

    Hans Passant.
    • Marked as answer by liurong luo Friday, September 18, 2009 2:55 AM
    Thursday, September 10, 2009 9:07 PM
  • This is how to get the Taskbar's Height (using WPF)

    int PSBH = System.Windows.Forms.Screen.PrimaryScreen.Bounds
    int TaskBarHeight = PSBH - System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;

    If you want to account for dpi

    int PSH = SystemParameters.PrimaryScreenHeight;
    int PSBH = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
    double ratio = PSH / PSBH;
    int TaskBarHeight = PSBH - System.Windows.Forms.Screen.PrimaryScreen.WorkingArea.Height;
    TaskBarHeight *= ratio;


    • Proposed as answer by Elijah Loez Thursday, February 28, 2019 7:15 PM
    • Edited by Elijah Loez Thursday, February 28, 2019 7:16 PM Formatting
    Thursday, February 28, 2019 7:05 PM