在几年前关于 stackoverflow 的示例中,EnumDisplaySettings 用于加载具有以下定义的数据结构 DEVMODE:
Private Type DEVMODE
dmDeviceName As String * CCHDEVICENAME
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * CCHFORMNAME
dmLogPixels As Integer
dmBitsPerPel As Long
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
dmPelsWidth 和 dmPelsHeight 被检索到此数据结构中。这也适用于我。我还想找到显示器相对于桌面区域的位置坐标。查看 Windows 开发中心中有关 DEVMODE 结构的信息,我看到还有一个 dmPosition 参数,它是一个 POINTL 结构。这已被排除在上面的 DEVMODE 类型定义之外,当我添加它时,dmPelsWidth 和 dmPelsHeight 不再检索正确的信息。
为什么上面省略了 dmPosition,为什么当我包含它时检索到的信息不再有效?
示例链接: 在 excel vba 中查找外部显示器的大小