Modify the resolution and color of the display in the VC

zhaozj2021-02-11  171

Modify the resolution and color of the display in the VC

In daily procedural development, sometimes we want to make our program running at a certain resolution and color number of the display. How to make the program automatically modify the current display settings? This first comes from the working principle of the display. First, related principles We know, the content displayed by the display corresponds to the memory, the minimum unit on the display is pixels (Pixel, only logical pixels), the minimum unit of memory is bit (BITS). The features of the display work are mainly reflected in both color numbers and resolutions. The number of colors displayed by the display depends on the number of times (bits) used by the unit pixel. In the memory, if the 8-bit memory (ie, a byte of a byte is used) corresponds to a pixel on the display, then the number of colors displayed in the display is 28 = 256 colors; the same, if the current color For 16 bits, the number of colors shown in the display is 216 = 65536 colors. The resolution of the display refers to the horizontal resolution and vertical resolution, often said 800x600, means that the pixel shown in the horizontal aspect is 800, and the pixels shown in vertical aspect are 600. A function of modifying a display device (such as a display, printer, etc., this article only on the display) attribute is provided in the VC: ChangeDisplaySettings, which can make a corresponding modification of the display device according to your needs. Its function has declared as follows: long changeisplaySettings (LPDEVMode LPDEVMODE, DWORD DWFLAGS); the meaning of its parameters is as follows: lpdevmode: a pointer to the DEVMODE data structure, DEVMODE's data structure describes the various types of properties to set the display. Normally, the parameters used are: DMSIZE: The size of the DEVMODE data structure (in bytes) DMBITSPERPEL: The number of memory bits (BITS) DMPELSWIDTH PIXEL WIDTH: Horizontal resolution (points) DMPELSHEIGHT PIXEL HEIGHT : Vertical resolution (points) DMDisplayFrequency mode Frequency: Display refresh rate, with Herz-based DMFields: Normally, different display devices (such as printers) are different, such as setting printers, you Will not use the DMDisplayFrequency property. So, when you use the DEVMODE data structure, you should indicate that you specifically used valid data members, and the use of DMFields is here. If only DMPELSWIDTH (horizontal resolution) and DmpelSheight (vertical resolution) are used in the program, then this value should be DM_PELSWIDTH | DM_PELSHEIGHT. DWFLAGS: Indicates the modification of the display device.

转载请注明原文地址:https://www.9cbs.com/read-5483.html

New Post(0)