Adjust the resolution of the display with VC

xiaoxiao2021-03-06  14

The code for adjusting the resolution is as follows:

DEVMODE dm; dm.dmSize = sizeof (DEVMODE); EnumDisplaySettings (NULL, ENUM_CURRENT_SETTINGS, & dm); if (!! Dm.dmPelsHeight = 1024 || dm.dmPelsWidth = 1280) {if (AfxMessageBox ( "To achieve the best display Effect, it is recommended that you use 1280 * 1024 resolution, ok? ", MB_YESNO) == iDYES) {long result; dm.dmbitsperpel = 32; dm.dmpelsheight = 1024; dm.dmpelswidth = 1280; dm.dmfields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT; Result = ChangeDisplaySettings (& DM, 0);}}

If you are automatically adjusted to the appropriate resolution when the program is started, you can add it to the View's OnInitialUpdate () and record the value of DM.dmpelSheight and DM.dmpelswidth.

To automatically adjust back to the original resolution at the end of the program, you can change it back to the original value with the above code in the mainframe on Onclose ().

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

New Post(0)