Project1.vbp
Type=Exe Form=Form1.frm Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\..\WINDOWS\system32\stdole2.tlb#OLE Automation Module=Module1; Module1.bas IconForm="Form1" Startup="Form1" HelpFile="" Title="ScreenTest" ExeName32="ScreenTest.exe" Command32="" Name="ScreenTest" HelpContextID="0" CompatibleMode="0" MajorVer=1 MinorVer=0 RevisionVer=0 AutoIncrementVer=0 ServerSupportFiles=0 VersionCompanyName="fnst" CompilationType=0 OptimizationType=0 FavorPentiumPro(tm)=0 CodeViewDebugInfo=0 NoAliasing=0 BoundsCheck=0 OverflowCheck=0 FlPointCheck=0 FDIVCheck=0 UnroundedFP=0 StartMode=0 Unattended=0 Retained=0 ThreadPerObject=0 MaxNumberOfThreads=1
Form1.frm
VERSION 5.00 Begin VB.Form Form1 Caption = "ScreenTest" ClientHeight = 6945 ClientLeft = 60 ClientTop = 345 ClientWidth = 12420 LinkTopic = "Form1" ScaleHeight = 6945 ScaleWidth = 12420 StartUpPosition = 2 'CenterScreen Begin VB.TextBox Text1 Height = 3975 Left = 0 MultiLine = -1 'True ScrollBars = 3 'Both TabIndex = 0 Top = 0 Width = 11295 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private Sub Form_Load() Dim i% Call EnumMonitors Text1.Text = "" For i = 0 To UBound(Monitors) Text1.Text = Text1.Text & "screen:" & i + 1 & vbCrLf & _ "LEFT:" & Monitors(i).Left & vbCrLf & _ "TOP:" & Monitors(i).Top & vbCrLf & _ "RIGHT:" & Monitors(i).Right & vbCrLf & _ "BOTTON:" & Monitors(i).Bottom & vbCrLf Next End Sub Private Sub Form_Resize() Text1.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight End Sub
Module1.bas
Attribute VB_Name = "Module1" Option Explicit Public Const SM_CMONITORS = 80 Public g_iMonitorCount As Integer Public g_bOnlyPrimaryMonitor As Boolean Public Declare Function EnumDisplayMonitors Lib "user32.dll" (ByVal hdc As Long, ByVal lprcClip As Long, ByVal lpfnEnum As Long, ByVal dwData As Long) As Long Public Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long) Public Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Public Monitors() As RECT Public Function MonitorEnumProc(ByVal hMoinitor As Long, ByVal hdcMonitor As Long, lprcMonitor As Long, ByVal dwData As Long) As Long Dim rcS As RECT CopyMemory rcS, lprcMonitor, Len(rcS) Monitors(g_iMonitorCount).Top = rcS.Top Monitors(g_iMonitorCount).Left = rcS.Left Monitors(g_iMonitorCount).Bottom = rcS.Bottom Monitors(g_iMonitorCount).Right = rcS.Right g_iMonitorCount = g_iMonitorCount + 1 MonitorEnumProc = 1 End Function Public Sub EnumMonitors() Dim iMonitorCount As Integer g_iMonitorCount = 0 iMonitorCount = GetSystemMetrics(SM_CMONITORS) If iMonitorCount = 1 Then g_bOnlyPrimaryMonitor = True End If ReDim Monitors(iMonitorCount - 1) Call EnumDisplayMonitors(ByVal 0&, ByVal 0&, AddressOf MonitorEnumProc, ByVal 0&) End Sub
Powered by: 博客园 Copyright © 2024 随风飘零0 Powered by .NET 8.0 on Kubernetes