动态更改屏幕分辨率  

有许多小工具可以在不重新启动Windows的条件下,动态更改屏幕分辨率。你是不是也想自己动手做一个呢?请在interface段中加入下面一句

function Resolution(X,Y:word):boolean; 
 
   然后在implementation段中写入如下代码: 
 
   function Resolution(X,Y:word):boolean; 
 
   var 
 
   DevMode:TDeviceMode; 
 
   begin 
 
   Result:=EnumDisplaySettings(nil,0,DevMode); 
 
   if Result then 
 
   begin 
 
   DevMode.dmFields:=DM_PELSWIDTH Or DM_PELSHEIGHT; 
 
   DevMode.dmPelsWidth:=X; 
 
   DevMode.dmPelsHeight:=Y; 
 
   Result:=ChangeDisplaySettings(DevMode,0)=DISP_CHANGE_SUCCESSFUL; 
 
   end; 
 
   end;


  接着,在form中放个button,caption为“800×600”,然后在其OnClick事件中写下
  if Resolution(800,600) then ShowMessage('800×600模式!');
  好了,试一下吧!



Delphi中简单实现动态更改屏幕分辨率  

作者: invidentxp ]

function GetAnimation: Boolean;
 var
 Info: TAnimationInfo;
 begin
 Info.cbSize := SizeOf(TAnimationInfo);
 if SystemParametersInfo(SPI_GETANIMATION, SizeOf(Info), @Info, 0) then
 Result := Info.iMinAnimate <> 0 else
 Result := False;
 end;
 function DynamicResolution(X, Y,Freq: word): BOOL;
 var
 lpDevMode: TDeviceMode;
 begin
 Result := EnumDisplaySettings(nil, 0, lpDevMode);
 if Result then
 begin
 lpDevMode.dmFields := DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_DISPLAYFREQUENCY;
 lpDevMode.dmPelsWidth := X;
 lpDevMode.dmPelsHeight := Y;
 lpDevMode.dmDisplayFrequency:= Freq;
 Result := ChangeDisplaySettings(lpDevMode, CDS_UPDATEREGISTRY) = DISP_CHANGE_SUCCESSFUL;
 end;
 end;
 procedure SetAnimation(Value: Boolean);
 var
 Info: TAnimationInfo;
 begin
 Info.cbSize := SizeOf(TAnimationInfo);
 BOOL(Info.iMinAnimate) := Value;
 SystemParametersInfo(SPI_SETANIMATION, SizeOf(Info), @Info, 0);
 end;
 procedure ShowWinNoAnimate(Handle: HWnd; CmdShow: Integer);
 var
 Animation: Boolean;
 begin
 Animation := GetAnimation;
 if Animation then SetAnimation(False);
 ShowWindow(Handle, CmdShow);
 if Animation then SetAnimation(True);
 end;
 procedure HideDesktopAllWin(Sender: TObject);
 function EnumWindowsProc (Wnd: HWND; LParam: LPARAM): BOOL; stdcall;
 begin
 Result := True;
 if (IsWindowVisible(Wnd)) and
 (GetWindowLong(Wnd, GWL_HWNDPARENT) = 0) and
 (GetWindowLong(Wnd, GWL_EXSTYLE) and WS_EX_TOOLWINDOW = 0) then
 begin
 ShowWinNoAnimate(Wnd, SW_MINIMIZE);
 end;
 end;
 var
 Param : Longint;
 begin
 Param := 0;
 EnumWindows(@EnumWindowsProc , Param);
 SetForegroundWindow(FindWindow(PChar('ProgMan'), nil));
 SetActiveWindow(FindWindow(PChar('ProgMan'), nil));
 end;
 Example:
 On Any Events
 HideDesktopAllWin (Sender); //强制显示到桌面
 DynamicResolution (StrToInt (EditBoxX),StrToInt(EditBoxY),StrToInt(EditBoxFreq)); //更改屏幕分辨率