![]() When loading the application, we have to find a monitor which is closest to the saved window position. >So (all) we have to determine is if the previously saved position of a form is valid in the current monitor setup if it is not we have to adjust its Left and Top to fall in the Primary or the Nearest monitor or display a message. RE: How to detect when two monitors are being used gmmastros (Programmer) 19 Dec 11 15:29 These details tell the exact layout of all monitors, if required. You can inquire more about the monitor by passing this handle to GetMonitorInfo API function which fills in a MONITORINFOEX structure which contains details like monitor resolution and its virtual screen coordinates. Note that the callback function returns a unique handle, hMonitor, for each enumerated monitor. I tested on my notebook with projector output as extended screen and it worked fine. ![]() Set the Startup Object to Sub Main and run the program. Private Function MonitorEnumProc(ByVal hMonitor As Long, ByVal hDCMonitor As Long, ByVal lprcMonitor As Long, dwData As Long) As LongÄwData = dwData + 1 'increase monitor count Private Function GetMonitorCount() As LongÄ®numDisplayMonitors 0, ByVal 0&, AddressOf MonitorEnumProc, GetMonitorCount Private Declare Function EnumDisplayMonitors Lib "user32" (ByVal hDC As Long, lprcClip As Any, ByVal lpfnEnum As Long, dwData As Long) As Long Start a new project, add a code module and insert the following code. See the following code which enumerates all monitors and returns their count. EnumDisplayMonitors enumerates all display monitors Windows has an API function, EnumDisplayMonitors for this very purpose. All these factors make it almost impossible to guess the number of monitors by merely looking at Screen dimensions. Moreover, different monitors can have different screen resolutions, physical sizes and aspect ratios. Also, the number of monitors can be more than two, placed in a mix layout. ![]() They can be placed side by side or stacked top to bottom, or even without any vertical or horizontal alignment (like a diagonal). The reason is that Windows supports muliple monitors in a highly flexible fashion. Unfortunately the Screen.Height/Width method is highly flawed.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |