unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var   DevMode:   TDeviceMode;
begin
    if   EnumDisplaySettings(nil,   0,   DevMode)   then   begin
        DevMode.dmFields   :=   DM_BITSPERPEL;
        //   8   -   256色,16   -   16位增强色,32   -   32位真彩色
        DevMode.dmBitsPerPel   :=   8;
        if   ChangeDisplaySettings(DevMode,0)   <>   DISP_CHANGE_SUCCESSFUL   then
            ShowMessage( '无法更改! ');
    end;
end;

procedure TForm1.Button4Click(Sender: TObject);
var   DevMode:   TDeviceMode;
begin
    if   EnumDisplaySettings(nil,   0,   DevMode)   then   begin
        DevMode.dmFields   :=   DM_BITSPERPEL;
        //   8   -   256色,16   -   16位增强色,32   -   32位真彩色
        DevMode.dmBitsPerPel   :=   32;
        if   ChangeDisplaySettings(DevMode,0)   <>   DISP_CHANGE_SUCCESSFUL   then
            ShowMessage( '无法更改! ');
    end;
end;

procedure TForm1.Button3Click(Sender: TObject);
var   DevMode:   TDeviceMode;
begin
    if   EnumDisplaySettings(nil,   0,   DevMode)   then   begin
        DevMode.dmFields   :=   DM_BITSPERPEL;
        //   8   -   256色,16   -   16位增强色,32   -   32位真彩色
        DevMode.dmBitsPerPel   :=   16;
        if   ChangeDisplaySettings(DevMode,0)   <>   DISP_CHANGE_SUCCESSFUL   then
            ShowMessage( '无法更改! ');
    end;

procedure TForm1.Button2Click(Sender: TObject);
begin
case   GetDeviceCaps(GetDC(GetDesktopWindow),   BITSPIXEL)   of
        8:     ShowMessage( '256色 ');
        16:   ShowMessage( '16位增强色 ');
        32:   ShowMessage( '32位真彩色 ');
    end;
end;
end;

 

posted on 2010-06-25 21:41  zeroengine  阅读(338)  评论(0编辑  收藏  举报