Dynamic adjustment display resolution

xiaoxiao2021-03-06  59

Delphi provides functions that can dynamically change the screen resolution, which is enumdisplaySettings () and ChangeDisplaySettings (). With them, you can change the resolution at any time when programming. The following crtreset function can facilitate this feature:

implementation function CRTReset (X, Y: Word): Boolean; var lpDevMode: TDeviceMode; begin Result: = EnumDisplaySettings (nil, 0, lpDevMode); // Get the display mode if Result then begin lpDevMode.dmFields: = DM_PELSWID TH Or DM_PELSHEIGHT; lpDevMode.dmPelsWidth: = X; lpDevMode.dmPelsHeight: = Y; // set the width and height of the screen Result: = ChangeDisplaySettings (lpDevMode, 0) = DISP_CHANGE_SUCCESSFUL; // change the screen resolution and returns a success or not end; end;

Procedure TFORM1.BUTTON1CLICK (Sender: Tobject); Begin IF CRTRESET (800, 600) Then ShowMessage ('Now IS 800 * 600'); // Call function, set resolution 800 × 600 end;

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

New Post(0)