This article describes the VC implementation of Windows multi-monitor programming method. Share to everyone for your reference. Specifically as follows:
When you access multiple monitors in Windows, you can set up to copy and extend the screen.
1, set to copy the screen, the resolution of multiple monitors is the same, location for 0~ resolution value
2, when set to expand the screen, the relationship between the monitor is more complex. First, the Windows system recognizes a primary display that can be changed in the screen resolution. The position relationship between multiple monitors can also be changed in the screen resolution. Where the primary monitor is located (0,0) to (width,height), other display locations are determined by the location of the primary monitor, negative on the left side of the main monitor, minus 0 in width, and at the bottom right, by the resolution of the primary monitor plus the width. The same is true when driven or handled with Mouse_event, the main monitor is 0~65535 and the other monitors are based on the relative position of the main display.
Second, the relevant procedures and APIs are as follows:
1, get the resolution of the current monitor
M_icurscrwidth =:: GetSystemMetrics (Sm_cxscreen);
M_icurscrheight =:: GetSystemMetrics (Sm_cyscreen);
2. Move the window position
MoveWindow (0, 0, m_icurscrwidth, m_icurscrheight);
Mobile window
ModifyStyle (ws_caption,0,0);
Remove title bar
3, get the number of monitors
Copy Code code as follows:
GetSystemMetrics (sm_cmonitors);
4, to obtain the relative position of the display in the resolution
void Getscreenrect (int screenno)
{
BOOL flag;
Display_device DD;
ZeroMemory (&DD, sizeof (DD));
DD.CB = sizeof (DD);
Flag = EnumDisplayDevices (NULL, Screenno, &DD, 0);
if (!flag) return;
DEVMODE DM;
ZeroMemory (&DM, sizeof (DM));
dm.dmsize = sizeof (DM);
Flag = EnumDisplaySettings (dd. Devicename,enum_current_settings, &DM);
M_scrrect[screenno].left = dm.dmposition.x;
M_scrrect[screenno].top = DM.DMPOSITION.Y;
M_scrrect[screenno].right = Dm.dmpelswidth;
M_scrrect[screenno].bottom = dm.dmpelsheight;
}
I hope this article on the VC program for everyone to help.