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;