Code archives/User Libs/EnumerateDisplays
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
| Utility_EnumerateDisplays() Where: Before any other call to Utility_GetDisplay* What: Initializes a LinkedList of Displays on the System for the DLL. Utility_GetDisplayCount%() What: Returns the amount of Displays on this System. Utility_GetDisplay( id%, rectangle* ) What: Grab a Display's information into a Rectangle structure. Could be used for creating a Border less window mode for your game or application. Maybe even for multiple display rendering. | |||||
;----------------------------------------------------------------
;-- Userlib
;----------------------------------------------------------------
;.lib "Utility_Displays.dll"
;Utility_EnumerateDisplays():"Utility_EnumerateDisplays"
;Utility_GetDisplayCount%():"Utility_GetDisplayCount"
;Utility_GetDisplay(id%, rectangle*):"Utility_GetDisplay"
;----------------------------------------------------------------
;----------------------------------------------------------------
;-- C++ DLL
;----------------------------------------------------------------
; #Include <windows.h>
;
; struct Display {
; int left;
; int top;
; int right;
; int bottom;
; Display* nextDisplay;
; Display* prevDisplay;
; };
; Display* firstDisplay = NULL;
; Display* lastDisplay = NULL;
;
; BOOL CALLBACK _EnumerateDisplaysProcedure(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData);
; STDAPIV_(void) Utility_EnumerateDisplays() {
; /* Clean up the Linked List first. */
; if (firstDisplay) {
; Display* displayPointer = firstDisplay;
; while(displayPointer) {
; Display* thisDisplay = displayPointer;
; displayPointer = displayPointer->nextDisplay;
; delete thisDisplay;
; }
; firstDisplay = NULL;
; lastDisplay = NULL;
; }
;
; EnumDisplayMonitors(NULL, NULL, _EnumerateDisplaysProcedure, 0);
; }
;
; BOOL CALLBACK _EnumerateDisplaysProcedure(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
; Display* thisDisplay = new Display;
; ZeroMemory(thisDisplay,sizeof(thisDisplay));
;
; if (!firstDisplay) firstDisplay = thisDisplay;
; if (!lastDisplay) {
; lastDisplay = thisDisplay;
; } else {
; lastDisplay->nextDisplay = thisDisplay;
; thisDisplay->prevDisplay = lastDisplay;
; }
; thisDisplay->left = lprcMonitor->left;
; thisDisplay->top = lprcMonitor->top;
; thisDisplay->right = lprcMonitor->right;
; thisDisplay->bottom = lprcMonitor->bottom;
; lastDisplay = thisDisplay;
;
; return TRUE;
; }
;
; STDAPIV_(int) Utility_GetDisplayCount() {
; int displayCount = 0;
; Display* displayPointer = firstDisplay;
; while (displayPointer) {
; displayCount++;
; displayPointer = displayPointer->nextDisplay;
; }
; return displayCount;
; }
;
; STDAPIV_(void) Utility_GetDisplay(int displayId, LPRECT display) {
; int displayCount = 0;
; Display* displayPointer = firstDisplay;
; while (displayPointer) {
; if ((displayCount == displayId) && (display) && (displayPointer)) {
; display->left = displayPointer->left;
; display->top = displayPointer->top;
; display->right = displayPointer->right;
; display->bottom = displayPointer->bottom;
; }
; displayCount++;
; displayPointer = displayPointer->nextDisplay;
; }
; }
;
; BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {return TRUE;}
;----------------------------------------------------------------
; Linker Options: -static-libgcc -static-libstdc++
; Linker Libraries: user32
;----------------------------------------------------------------
;----------------------------------------------------------------
;-- Types
;----------------------------------------------------------------
Type Rectangle
Field X,Y
Field X2,Y2
End Type
;---------------------------------------------------------------- |
Comments
None.
Code Archives Forum