Search notes:

Examples for Visual Basic for Application accessing the Windows API: EnumDisplayMonitors

EnumDisplayMonitors calls a callback function for each monitor that is attached to the system.
The following example iterates over all monitors and debug-prints their top-left coordinates and size (width x height).
This example needs the VBA declarations of the Windows API which can be found here.
option explicit

sub main()
    EnumDisplayMonitors 0, 0, addressOf monitorEnumProc, 0
end sub


function monitorEnumProc(byVal hMonitor as long, byVal hdcMonitor as long, byRef rMonitor as RECT, byVal dwData as long) as long
   debug.print "Found monitor with top left = " & rMonitor.left & "," & rMonitor.top & " and size = " & (rMonitor.right-rMonitor.left) & "x" (rMonitor.bottom-rMonitor.top)

 ' Return true so as to continue with the enumeration
   monitorEnumProc = true
end function
Github repository WinAPI-4-VBA, path: /examples/EnumDisplayMonitors.bas

See also

Other examples

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1759390574, '216.73.216.42', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/VBA/Win-API/examples/EnumDisplayMonitors(59): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78