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

  • 相关阅读:
    时间选择器UIDatePicker的使用
    在app中屏蔽第三方键盘
    plist文件的相关操作
    查看mac上的隐藏文件
    设置ARC有效或者无效
    Linux 下源代码安装编译 ImageMagick6.8.48 且使其支持 JPEG
    Linux Netcat 命令—网络工具中的瑞士军刀
    Linux 好书、经典书籍推荐
    让你拥有超能力:程序员应该掌握的统计学公式
    shell 脚本实现的守护进程
  • 原文地址:https://www.cnblogs.com/lbnnbs/p/4782066.html
Copyright © 2011-2022 走看看