The method of realizing Windows multi-monitor programming with VC _c language

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.