• 获取任务栏坐标



        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

  • 相关阅读:
    [转]Sublime Text 3安装Json格式化插件
    Golang 新手可能会踩的 50 个坑【转】
    [golang]svg图片默认按照左上角旋转,改为按中心旋转,重新计算中心偏移量
    序列化是干什么的,有什么作用,什么情况下会用到?
    Hbase设置多个hmaster
    基于JMX动态配置Log4J日志级别
    面向过程与面向对象编程的区别和优缺点
    log4j自带的两个类MDC和NDC作用以及用途
    【架构师之路】集群/分布式环境下5种session处理策略
    Java Web项目如何做到升级不断掉服务,同时涉及到的相关问题
  • 原文地址:https://www.cnblogs.com/lbnnbs/p/4782066.html
Copyright © 2020-2023  润新知