Announcement

Collapse
No announcement yet.

TaskBar Position

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • TaskBar Position

    Is there a better/simpler API way to do determine where the TaskBar is located?

    Code:
    #Include "win32api.inc"
    Function PBMain() As Long
       Local w,h As Long, hWnd As Dword, rc As Rect
       'move the Dialog so it's bottom is flush with the top of the TaskBar
       hWnd = FindWindow("Shell_trayWnd",ByVal 0)
       GetWindowRect hWnd, rc
       Desktop Get Size To w,h
    
       If rc.nTop < h/2 And rc.nBottom < h/2 Then temp$ = "top"
       If rc.nTop > h/2 And rc.nBottom > h/2 Then temp$ = "bottom"
    
       If rc.nLeft < w/2 And rc.nRight < w/2 Then temp$ = "left"
       If rc.nLeft > w/2 And rc.nRight > w/2 Then temp$ = "right"
    
       ? temp$
    
    End Function

  • #2
    Not sure it would be simpler but can read from the registry - see tips here
    Rgds, Dave

    Comment


    • #3
      Howdy, Dave!

      Thanks for the link. And yep, a registry change is probably no better than the code above. I'll stick with that for now.

      Comment


      • #4
        This is one alternative method for finding the bounding rectangle of the Taskbar (would still have to decide where to place the dialog):

        https://docs.microsoft.com/en-us/win...-gettaskbarpos
        Adam Drake
        PowerBASIC

        Comment


        • #5
          SystemParametersInfo can also be useful..
          '
          Code:
            ' where is TaskBar?
            LOCAL w, h AS LONG, rc AS Rect
            SystemParametersInfo(%SPI_GETWORKAREA, 0, rc, 0)
            DESKTOP GET SIZE TO w, h
          
            IF rc.nTop = 0  AND rc.nBottom < h THEN ? "Bottom"
            IF rc.nTop > 0  AND rc.nBottom = h THEN ? "Top"
            IF rc.nLeft = 0 AND rc.nRight  < w THEN ? "Right"
            IF rc.nLeft > 0 AND rc.nRight  = w THEN ? "Left"
          '

          Comment


          • #6
            Added - the reason why there is no TaskBarArea is probably because we usually only need to know work area to be able to position programs (center, in corner, etc).

            Comment

            Working...
            X