zoukankan      html  css  js  c++  java
  • 获取任务栏坐标


        Public Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" _
            (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Object, ByVal fuWinIni As Long) As Long

        Const SPI_GETWORKAREA As Long = 48

        Public Structure Rect
            Public Left As Long
            Public Top As Long
            Public Right As Long
            Public Bottom As Long
        End Structure

        Public Enum AlignmentConst
            vbLeft = 0
            vbRight = 1
            vbTop = 2
            vbBottom = 3
        End Enum

        Public Function GetWorkArea() As Rect
            'PIXELS

            Dim Result As Long
            Dim WorkArea As Rect

            Result = SystemParametersInfo(SPI_GETWORKAREA, 0&, WorkArea, 0&)
            GetWorkArea = WorkArea
        End Function

        Public Function GetAlignment() As AlignmentConst
            'Find the alignment of the taskbar

            Dim WorkArea As Rect
            Dim Align As AlignmentConst

            WorkArea = GetWorkArea

            If WorkArea.Left <> 0 Then
                'the taskbar MUST be right aligned
                Align = AlignmentConst.vbLeft
            Else
                If WorkArea.Top <> 0 Then
                    'The taskbar MUST be bottom aligned
                    Align = AlignmentConst.vbTop
                Else
                    If (WorkArea.Bottom - WorkArea.Top) = Screen.PrimaryScreen.Bounds.Height Then
                        'If the workarea height is equal to the screen height then
                        'the taskbar MUST be left aligned
                        Align = AlignmentConst.vbRight
                    Else
                        Align = AlignmentConst.vbBottom
                    End If
                End If
            End If

            GetAlignment = Align
        End Function

        Public Function TaskBarDimensions() As Rect
            'Find out what the taskbars', left, top, right and bottom values are
            'in TWIPS

            Const X = 0
            Const Y = 1

            Dim WorkArea As Rect
            Dim TaskBarDet As Rect
            Dim TwipsPP(2) As Byte 'Twips Per Pixel

            WorkArea = GetWorkArea
            TwipsPP(X) = Screen.PrimaryScreen.Bounds.Left
            TwipsPP(Y) = Screen.PrimaryScreen.Bounds.Top

            'set the taskbars' default values to the screen size
            TaskBarDet.Top = 0
            TaskBarDet.Bottom = Screen.PrimaryScreen.Bounds.Height
            TaskBarDet.Left = 0
            TaskBarDet.Right = Screen.PrimaryScreen.Bounds.Width

            'change the appropiate value according to alignment
            Select Case GetAlignment
                Case AlignmentConst.vbLeft
                    TaskBarDet.Right = (WorkArea.Left * TwipsPP(X))
                Case AlignmentConst.vbRight
                    TaskBarDet.Left = (WorkArea.Right * TwipsPP(X))
                Case AlignmentConst.vbTop
                    TaskBarDet.Bottom = (WorkArea.Top * TwipsPP(Y))
                Case AlignmentConst.vbBottom
                    TaskBarDet.Top = (WorkArea.Bottom * TwipsPP(Y))
            End Select

            'return result
            TaskBarDimensions = TaskBarDet
        End Function

  • 相关阅读:
    Knative Serving 进阶: Knative Serving SDK 开发实践
    从求生存到修体系,我在阿里找到了技术人的成长模式
    K8s 学习者绝对不能错过的最全知识图谱(内含 56个知识点链接)
    P1197 [JSOI2008]星球大战
    P1311 选择客栈
    P2822 组合数问题
    贪心 加工生产调度
    P3375 【模板】KMP字符串匹配
    P1025 数的划分
    P1019 单词接龙
  • 原文地址:https://www.cnblogs.com/lbnnbs/p/4782066.html
Copyright © 2011-2022 走看看