![]() Then, another call to EnumDisplayDevice is made to fill a DISPLAY_DEVICE structure with additional information. Preliminary information is gathered with GetMonitorInfo. In my design, it instantiates to the provide information for the entire virtual desktop, and then collects information for a specific device when passed a new Handle value. The CMonitor class exposes most of the information available for any given monitor device. #Multimon api download#I've written up a small sample (Monitors), which you can download from my Web site, that uses this callback to build a global collection of CMonitor objects that describe each of the devices present. Given the nature of AddressOf, you'll need to house this callback in a standard BAS module. #Multimon api full#Windows will then call your MonitorEnumProc function once for each monitor present, and within this procedure you can call GetMonitorInfo to gather a MONITORINFOEX structure full of information about the given monitor. If you're simply interested in discovering monitor dimensions and positions, pass Null for all but the third parameter, which is a pointer to the callback function: ' Initiate enumeration of all available displays. In that case, you need to set up an EnumDisplayMonitors callback. The situation becomes more complicated if you want to retrieve coordinates for all available monitors in the system. Each of these functions returns an hMonitor, which may be passed to GetMonitorInfo for overall screen and work area coordinates. #Multimon api how to#If you need to find out information about a specific monitor, and you can point to it via a window handle or a discrete point or rectangle, there are three API functions that can be useful: MonitorFromPoint, MonitorFromRect and MonitorFromWindow (I showed how to use the latter in an earlier column). If GetSystemMetrics(SM_CMONITORS) > 1 Then ' Branch based on number of display monitors. ' Only go into topmost mode if compiled, or In the case of a screensaver, you likely also want to make your canvas topmost, so the combined set of calls looks something like this: ![]() With multi-monitor systems, you need to make four GetSystemMetrics calls, one for each X and each Y value. On single-monitor systems, you can assume the point 0,0 to be in the upper-left, and SM_CXSCREEN, SM_CYSCREEN to be in the lower-right. GetSystemMetrics provides the easiest way to retrieve the entire desktop surface coordinates. On systems that don't support this request (there's that pesky Windows 95 again), you'll get back 0, so the best strategy is to test for >1 to quickly determine your ensuing strategy. To determine the number of monitors present, you need only call that API, asking for SM_CMONITORS. The GetSystemMetrics API call has been expanded over the years to include new built-in functionality as it increases. #Multimon api code#So, why not get right to that first? Multiple-monitor support wasn't offered until Windows 98 and Windows 2000, so if you're still supporting Windows 95 and/or NT4 you'll always need to code at least two solutions for every situation you intend to address. Knowing the entire desktop coordinates can also be extremely useful if you just want to cover the whole thing with a single form. In order to do this, or tasks such as the writer above describes, you need to be able to determine how many monitors there are and the screen coordinates of each. ![]() One of my screensavers shows the same image on all monitors, while another shows different images on each monitor. You've probably seen similar applications. ![]() I've also created applications (OK, a screensaver or three) that needed to cover the entire desktop, all visible monitors included. In addition, I need to know if PowerPoint is on screen one, two or three. I am writing a VBA program and need to determine the screen resolution of all the monitors in a 3-screen system. For instance, I recently saw a newsgroup post that read in part: Multiple monitor setups are becoming increasingly common, and there are occasions where you'll want to react differently based on which monitor the user places your application's windows, or even where you'll want to make sure your application is using specific monitor(s). Most of the time it doesn't matter where the user puts your application's windows, but every now and then you really need to know - or even decide this for yourself. Classic VB Corner Working with Multiple Monitors ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |