November 25, 2020, 05:20:44 AM

Author Topic: [bb] EnumerateDisplays by Xaymar [ 1+ years ago ]  (Read 650 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] EnumerateDisplays by Xaymar [ 1+ years ago ]
« on: June 29, 2017, 12:28:40 AM »
Title : EnumerateDisplays
Author : Xaymar
Posted : 1+ years ago

Description : 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.


Code :
Code: BlitzBasic
  1. ;----------------------------------------------------------------
  2. ;-- Userlib
  3. ;----------------------------------------------------------------
  4. ;.lib "Utility_Displays.dll"
  5. ;Utility_EnumerateDisplays():"Utility_EnumerateDisplays"
  6. ;Utility_GetDisplayCount%():"Utility_GetDisplayCount"
  7. ;Utility_GetDisplay(id%, rectangle*):"Utility_GetDisplay"
  8. ;----------------------------------------------------------------
  9.  
  10. ;----------------------------------------------------------------
  11. ;-- C++ DLL
  12. ;----------------------------------------------------------------
  13. ; #Include <windows.h>
  14. ;
  15. ; struct Display {
  16. ;     int left;
  17. ;     int top;
  18. ;     int right;
  19. ;     int bottom;
  20. ;     Display* nextDisplay;
  21. ;     Display* prevDisplay;
  22. ; };
  23. ; Display* firstDisplay = NULL;
  24. ; Display* lastDisplay = NULL;
  25. ;
  26. ; BOOL CALLBACK _EnumerateDisplaysProcedure(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData);
  27. ; STDAPIV_(void) Utility_EnumerateDisplays() {
  28. ;     /* Clean up the Linked List first. */
  29. ;     if (firstDisplay) {
  30. ;         Display* displayPointer = firstDisplay;
  31. ;         while(displayPointer) {
  32. ;             Display* thisDisplay = displayPointer;
  33. ;             displayPointer = displayPointer->nextDisplay;
  34. ;             delete thisDisplay;
  35. ;         }
  36. ;         firstDisplay = NULL;
  37. ;         lastDisplay = NULL;
  38. ;     }
  39. ;
  40. ;     EnumDisplayMonitors(NULL, NULL, _EnumerateDisplaysProcedure, 0);
  41. ; }
  42. ;
  43. ; BOOL CALLBACK _EnumerateDisplaysProcedure(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
  44. ;     Display* thisDisplay = new Display;
  45. ;     ZeroMemory(thisDisplay,sizeof(thisDisplay));
  46. ;
  47. ;     if (!firstDisplay) firstDisplay = thisDisplay;
  48. ;     if (!lastDisplay) {
  49. ;         lastDisplay = thisDisplay;
  50. ;     } else {
  51. ;         lastDisplay->nextDisplay = thisDisplay;
  52. ;         thisDisplay->prevDisplay = lastDisplay;
  53. ;     }
  54. ;     thisDisplay->left = lprcMonitor->left;
  55. ;     thisDisplay->top = lprcMonitor->top;
  56. ;     thisDisplay->right = lprcMonitor->right;
  57. ;     thisDisplay->bottom = lprcMonitor->bottom;
  58. ;     lastDisplay = thisDisplay;
  59. ;
  60. ;     return TRUE;
  61. ; }
  62. ;
  63. ; STDAPIV_(int) Utility_GetDisplayCount() {
  64. ;     int displayCount = 0;
  65. ;     Display* displayPointer = firstDisplay;
  66. ;     while (displayPointer) {
  67. ;         displayCount++;
  68. ;         displayPointer = displayPointer->nextDisplay;
  69. ;     }
  70. ;     return displayCount;
  71. ; }
  72. ;
  73. ; STDAPIV_(void) Utility_GetDisplay(int displayId, LPRECT display) {
  74. ;     int displayCount = 0;
  75. ;     Display* displayPointer = firstDisplay;
  76. ;     while (displayPointer) {
  77. ;         if ((displayCount == displayId) && (display) && (displayPointer)) {
  78. ;             display->left = displayPointer->left;
  79. ;             display->top = displayPointer->top;
  80. ;             display->right = displayPointer->right;
  81. ;             display->bottom = displayPointer->bottom;
  82. ;         }
  83. ;         displayCount++;
  84. ;         displayPointer = displayPointer->nextDisplay;
  85. ;     }
  86. ; }
  87. ;
  88. ; BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {return TRUE;}
  89. ;----------------------------------------------------------------
  90. ; Linker Options: -static-libgcc -static-libstdc++
  91. ; Linker Libraries: user32
  92. ;----------------------------------------------------------------
  93.  
  94. ;----------------------------------------------------------------
  95. ;-- Types
  96. ;----------------------------------------------------------------
  97. Type Rectangle
  98.         Field X,Y
  99.         Field X2,Y2
  100. End Type
  101. ;----------------------------------------------------------------


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal