Programming on Windows Multi-Monitor

Source: Internet
Author: User
Tags bit set home screen
Summary
This document describes how to configure and use multiple monitors in Windows XP in multiple steps.

In Windows XP, you can use multiple monitors to increase your desktop productivity. A computer can be connected to up to ten independent monitors. With these monitors, your desktop can have enough space to accommodate a large number of programs or windows. By moving a project from one monitor to another or extending it to multiple monitors, you can easily execute multiple tasks at the same time. You can edit images or text on one monitor and view web activity on another monitor. Alternatively, you can open multiple pages of a long document and drag these pages to multiple monitors to easily view text la S and images. You can also drag a Microsoft Excel worksheet between two monitors so that you can view the information of multiple columns without using the scroll bar.

Connect multiple monitors

Use a monitor as the primary monitor. After you start your computer, the "Log on" dialog box is displayed. In addition, most programs will display the program window on the main monitor when you open it for the first time. You can select different screen resolution and color quality settings for each monitor. You can connect multiple monitors to their respective video adapters or a separate video adapter that supports multiple outputs. To connect and configure multiple monitors, follow these steps:

1. Click Start, and then click Control Panel ".
2. Click Appearance and topic, and then click display ".
3. On the settings tab, click recognition to display a large number on each monitor. This number indicates the icon corresponding to each monitor.
4. Click the monitor icon and drag it to a different location. The location distribution represents how you want to move projects between two monitors. Click OK or apply to view the changes.

Note:: The icon position determines how you move the project between two monitors. For example, if you are using two monitors and want to move the project from one monitor to another by dragging left and right, release the icons in parallel. If you want to move the project between two monitors by dragging them down, discharge the icons up and down. The icon location does not need to match the monitor's physical location. Even if your monitor is placed side by side, the icons can be arranged up and down.

 

Change master Monitor


1. On the "Settings" tab of the "Display Properties" dialog box, click the icon that represents the monitor to be specified as the main monitor.
2. Click the "use this device as the primary monitor" check box. Note: If the selected monitor icon is currently set as the primary monitor, this check box is unavailable.

View the same desktop in multiple monitors


1. On the "Settings" tab of the "show properties" dialog box, click the icon that represents other monitors that need to be used besides the main monitor.
2. Click the "extend Windows desktop to this monitor" check box. After this feature is enabled, you can drag the project to another monitor on the screen or resize the window to expand the window to multiple monitors.

Move projects between multiple monitors


1. On the "Settings" tab of the "show properties" dialog box, click "recognize" to display a large number on each monitor. This number indicates the icon corresponding to each monitor.
2. Click the monitor icon and drag it to a different location. The location distribution represents the way you want to move projects between the two monitors. Click OK or apply ".
3. Drag the project on the desktop on the screen until it appears on another monitor. You can also adjust the window size to extend the window to multiple monitors.

Use dual-Screen

On most portable computers and some desktop computers (one video card has two video ports), you can use dual-screen display to extend the display area to another monitor. The features of Dual-screen display are very similar to those of multiple monitors. The difference is that you cannot select the primary monitor. On a portable computer, the main monitor is always an LCD display screen. On a desktop computer, the first video output port is connected to the main monitor. After you connect to the second monitor and turn on the computer, use the "display" tool in the "control panel" to configure your settings. The steps are the same as configuring multiple monitors. You can use a dual-screen on a laptop with or without a port.

 

From [how to configure and use multiple monitors in Windows XP]
Http://support.microsoft.com/kb/307873/zh-cn

After Windows 98, multi-Monitor (Multiple display) is supported ). Windows Multi-display is divided into two types: one is a single video card with multiple monitors, the other is a multi-video card with multiple monitors. The previous multi-display relies on multiple graphics card interfaces, General graphics card D-sub interface + DVI-I interface (related information please see the graphics card interface article ). The latter is achieved through different monitors connected to different video cards. The situation of multiple monitors makes it difficult to compile some guis, but multiple monitors also bring benefits. You can combine multiple monitors into a large area Screen and watch a movie, the cost is higher.

Generally, a PC is equipped with a video card and a monitor, but you can insert a video card on the motherboard, and then use two monitors. The added display is set as the primary display (main screen) by windows, and the other display is called secondary display (secondary screen ). The coordinates of the main screen are set to (0, 0), Open Control Panel-> display, open the display dialog box, enter the settings panel, you can see multiple monitors, you can also know which is the main screen, which is the secondary screen? You can drag the secondary screen with the mouse to adjust the position of the secondary screen relative to the primary screen. If there is only one video card, the video card has multiple output interfaces. You can connect different monitors to different output interfaces to implement multiple screens. In this case, the main screen cannot be selected, the main display on the notebook is an LCD screen, and the desktop is the display that connects the first output interface of the video card. Next I will discuss the problems I encountered in actual development. I will introduce the programming in the case of multiple monitors in combination with an article such as programming for multiple monitors in Windows 98. For ease of description, assume that the resolution of the coordinates of the original PC display is (1024*768), and then add a video card and display, the resolution is (800*600 ), in this way, the (800*600) monitor becomes the primary screen, and the (1024*768) monitor becomes the secondary screen. The following example describes how to replace a display with a screen for ease of understanding: 1. When a virtual desktop (virtual desktop) is a display, the virtual desktop is the desktop that you see. The coordinates are (0, 0 ), size (1024,768 ). When there are two monitors, the secondary screen coordinates are (1024, 0), the size is (768*1824,768), the virtual desktop coordinates (), the size ), at this time, the virtual desktop is not one of the two monitors you see. As shown in the following figure: virtual desktop is the result of splicing the two. Ii. Handle of api1. data-type hmonitor display monitorinfo display information monitorinfoex display information (extended above structure) typedef struct tagmonitorinfo {DWORD cbsize; rect rcmonitor; rect rcwork; DWORD dwflags;} monitorinfo, * lpmonitorinfo; typedef struct tagmonitorinfoexa {monitorinfo; tchar szdevice [cchdevicename];} monitorinfoex, * lpmonitorinfoex; 2. obtain the hmonitor monitorfrompoint (point PT, DWORD dwflags) on the screen where a vertex is located. PT indicates that the following value is obtained for the coordinate dwflags, indicating that no display contains the vertex. Monitor_defaulttonull (return NULL) monitor_defaulttoprimary (return home screen) monitor_defaulttonearest (return the screen closest to the target) 3. obtain the hmonitor monitorfromrect (lprect LPRC, DWORD dwflags) on the screen where the window is located. LPRC indicates the same hmonitor monitorfromwindow (hwnd, DWORD dwflags) as 2 ); hwnd indicates that the specified window dwflags has the same meaning as 2. The two interfaces return the screen with the most targets. If no screen contains targets, the specific value is returned based on the second parameter. 4. obtain the display information bool getmonitorinfo (hmonitor, lpmonitorinfo lpmi); hmonitor display handle lpmi monitorinfo or monitorinfoex structure pointer note that monitorinfoex is a superset of monitorinfo. You need to set its cbsize attribute first, make it equal to its own size. Monitorinfoex mix; mix. cbsize = sizeof (MIX); getmonitorinfo (hmonitor, (lpmonitorinfo) & mix); 5. get the display width and height getsystemmetrics (INT nindex); Use sm_cxscreen and sm_cyscreen to get the size of the main screen (800,600). To get the size of the virtual desktop, use sm_cxvirtualscreen, sm_cyvirtualscreen, the size obtained is (1824,768) 6. get workspace size bool systemparametersinfo (uint Uiaction, // System parameter to retrieve or set uint Uiparam, // Depends on action to be taken pvoid Pvparam, // Depends on action to be taken uint Fwinini// User profile update option); The above function makes improvements when the uiaction is spi_getworkarea and spi_setworkarea. In the past, operations were always performed on the home screen. To obtain attributes of other screens, you can use getmonitorinfo. to set other screens, you can use rect as pvparam when uiaction is spi_setworkarea. In this way, you can set the display containing the rect. 7. convenience related display bool winapi enumdisplaymonitors (HDC, lpcrect lprcclip, monitorenumproc lpfnenum, lparam dwdata ); HDC device environment lprcclip rectangular area lpfnenum callback function dwdata to the callback function parameter callback function requires the following form bool callback monitorenumproc (hmonitor, HDC hdcmonitor, LPRC lprcmonitor, DWORD dwdata ); the following is a reference to the original article programming for multiple monitors in Windows 98, which describes the monitorenumproc callback is called for each monitor that intersects the V Isible region of HDC and the lprcclip parameter. if the lprcclip parameter is null, then no additional clipping is already med. the dwdata parameter is for user-defined data and is passed through to the dwdata parameter in the callback function. monitorenumproc is a user-defined callback function that must have the following signature: bool callback monitorenumproc (hmonitor, HDC hdcmonitor, lp RC lprcmonitor, DWORD dwdata); If the HDC passed to enumdisplaymonitors was null, then hdcmonitor is null. otherwise, hdcmonitor contains a valid device context whose color attributes match the display monitor defined by hmonitor. if hdcmonitor is null, then lprcmonitor is in virtual-desktop coordinates. it is important to note that no application needs to use enumdisplaymonitors to handle monitors Of differing bit depths, since Windows automatically dithers high-color images on lower-color devices. you shoshould use this function only if you want to do custom dithering to ensure the best possible display. in order to help you understand exactly how enumdisplaymonitors is used, I will present a couple of code snippets using strating common usage scenarios. one use for enumdisplaymonitors is to mak E sure that images are drawn optimally on lower-color devices. the best way to do this is to change how your window's wndproc handles the wm_paint message. case wm_paint: HDC; HDC = beginpaint (hwnd, & paintstruct); enumdisplaymonitors (HDC, null, monitorenumpaintproc, 0); endpaint (& paintstruct); inside your callback, you query the passed device context to determine its capabilities and display area and Do your drawing events enumeration display device bool winapi enumdisplaydevices (pvoid unused, // reversed, set to nulldword idevnum, // index of monitor to query informationpdisplay_device lpdisplaydevice, // output informationdword dwflags ); // set to 0 where idevnum refers to the index of the query device, which is based on 0. If the device exists, it is filled with lpdisplaydevice, and true is returned. If the device does not exist, false is returned. If you want to enumerate all devices, you need to enable idevnum to call this function from 0 until false is returned. The structure of the third parameter is defined as follows: typedef struct _ display_device {dword cb; byte devicename [32]; // name of the device. same as value get by getmonitorinfobyte devicestring [128]; // firendly name of the devicedword stateflags; // unknown} display_device, * pdisplay_device, * lpdisplay_device; the parameter meaning of stateflags is unknown, however, we can see from its values that: # define display_device_attached_to_topics top0x00000001 # define display_device_multi_driver0x00000002 # define di Usage # define display_device_policing_driver0x00000008 # define definitions the original article "programming for multiple monitors in Windows 98" describes since enumdisplaydevices allows you to query devices that aren't part of the desktop, your application can use monitors in an exclusive manner, without having to share the screen with the desktop. to do this, Find a device that doesn' t have the display_device_attached_to_desktop bit set and call the Win32 API function createdc, passing the name returned in the devicename member of lpdisplaydevice. if you create a device context in this manner, you should delete it when you're done with it by calling deletedc.9. 3. Gui programming considerations GUI programming uses a display, if you do not consider multiple monitors, a display problem may occur. For example, you can drag and drop a task bar to the secondary screen and perform operations on the secondary screen. After running the program, the program appears on the primary screen, which makes the user feel that the program is not running, but this is not the main problem. After you drag and drop the window on the main screen to the secondary screen, click a button or menu. At this time, the program dynamically adjusts the position. The coordinates are (0, 0 ), then the window will run back to the main screen from the secondary screen. At this time, I think users will feel annoyed. You can obtain the screen information of the window when the window is created and when the window is moved, and record the origin of the current display. For example: cpoint M _ ptorg; // In. declare the variable in the H file // called during wm_move or window initialization, save the origin information hmonitor hwndmonitor = monitorfromwindow (getsafehwnd (), callback); monitorinfoex monitorinfo; If (hwndmonitor = NULL) return; monitorinfo. cbsize = sizeof (monitorinfoex); getmonitorinfo (hwndmonitor, & monitorinfo); m_ptorg.x = monitorinfo. leftm_ptorg.y = monitorinfo. top when setwindowpos is called, pay attention to the value of the origin of the rect passed at this time. 4. interesting things about multiple windows. Generally, the abscissa of the origin of the second window is the width of the first window, And the taskbar and desktop are displayed on the home screen. By default, the secondary screen is on the right of the home screen, and the mouse can move left out of the home screen. You can also drag the taskbar to the secondary screen. When there are multiple windows, the control panel remembers the last position and appears on the screen the next time it is opened. For example, if you open the control panel, it is displayed on the home screen. If you move it to the secondary screen, and close it, it will appear on the secondary screen when you open it again.

 

Related Article

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.