Here it is anyway!


//********************************************************************
{Whoops! Delphi imports this function incorrectly, so we must manually
 import it}
function ChangeDisplaySettings(lpDevMode: PDeviceMode;
                               dwFlags: DWORD): Longint; stdcall;
var
  Form1: TForm1;
  DevModeArray: TList;    // holds a list of device mode information
structures

implementation

uses Math;

{$R *.DFM}

{import the function}
function ChangeDisplaySettings; external user32 name
'ChangeDisplaySettingsA';

procedure TForm1.FormCreate(Sender: TObject);
var
  DevModeCount: Integer;            // tracks the number of display modes
  DevModeInfo: ^TDevMode;           // a pointer to display mode information
begin
  {create the list to hold display mode information structures}
  DevModeArray := TList.Create;

  {initialize the counter}
  DevModeCount := 0;

  {dynamically allocate memory to hold display mode information}
  GetMem(DevModeInfo, SizeOf(TDevMode));

  {begin enumerating display modes}
  while EnumDisplaySettings(NIL, DevModeCount, DevModeInfo^) do
  begin
    {add the information to the list}
    DevModeArray.Add(DevModeInfo);

    {increment the counter}
    Inc(DevModeCount);

    {display the resolution of the enumerated display mode}
    ListBox1.Items.Add(IntToStr(DevModeInfo^.dmPelsWidth)+'x'+
                       IntToStr(DevModeInfo^.dmPelsHeight)+', '+
                       IntToStr(Trunc(IntPower(2,
DevModeInfo^.dmBitsPerPel)))+
                       ' colors');

    {allocate another slot for device mode information}
    GetMem(DevModeInfo, SizeOf(TDevMode));
  end;

  {the above loop always exits with one extra, unused block of memory,
   so delete it}
  FreeMem(DevModeInfo, SizeOf(TDevMode));

  {select the first item in the list box}
  ListBox1.ItemIndex := 0;
end;

procedure TForm1.FormDestroy(Sender: TObject);
var
  iCount: Integer;         // a general loop counter
begin
  {free all memory pointed to by each item in the list}
  for iCount := 0 to DevModeArray.Count-1 do
    FreeMem(DevModeArray.Items[iCount], SizeOf(TDevMode));

  {free the list}
  DevModeArray.Free;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  ModeChange: Longint;        // indicates if a Windows reboot is necessary
begin
  {change the display mode}
  ModeChange:=ChangeDisplaySettings(DevModeArray[ListBox1.ItemIndex],
                                    CDS_UPDATEREGISTRY);

  {indicate if a dynamic change was successful or if Windows must be
rebooted}
  if ModeChange=DISP_CHANGE_SUCCESSFUL then
    ShowMessage('Dynamic display mode change successful.');
  if ModeChange=DISP_CHANGE_RESTART then
    ShowMessage('Change successful; Windows must be restarted for the
changes '+
                'to take effect');
end;





-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Rohit Gupta
Sent: Friday, 9 June 2000 2:28 p.m.
To: Multiple recipients of list delphi
Subject: RE: [DUG]: Screen Size


We looked at that, the problem is that devmode structure requires
a whole lot of info which is hard to obtain.  For instance the
enumdisplaysettings does not get you the current settings to feed
to devmode.  Instead it gives you settings for all display modes of
the card.

To:                     Multiple recipients of list delphi <[EMAIL PROTECTED]>
Send reply to:          [EMAIL PROTECTED]
From:                   James Sugrue <[EMAIL PROTECTED]>
Subject:                RE: [DUG]:  Screen Size
Date sent:              Thu, 8 Jun 2000 16:01:10 +1200

> ChangeDisplaySettings
>
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, 8 June 2000 15:49
> To: Multiple recipients of list delphi
> Subject: [DUG]: Screen Size
>
>
> I can get the screen size with getsystemmetrics, but how do I
> change the screen size ?  Does anyone know ?
>
>
> Rohit
>
> ======================================================================
> CFL - Computer Fanatics Ltd.  21 Barry's Point Road, AKL, New Zealand
> PH    (649) 489-2280
> FX    (649) 489-2290
> email [EMAIL PROTECTED]  or  [EMAIL PROTECTED]
> ======================================================================
>
> --------------------------------------------------------------------------
-
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
>
>
>
> CAUTION - This message may contain privileged and confidential information
intended only for the

> use of the addressee(s) named above.  If you are not the intended
recipient of this message you a
re
> hereby notified that any use, dissemination, distribution or reproduction
of this message is proh
ibited.
> If you have received this message in error please notify Progressive
Enterprises Ltd. immediately
 via
> email at [EMAIL PROTECTED]  Any views expressed in
this message are those of
the
> individual sender and may not necessarily reflect the views of Progressive
Enterprises Ltd.
>
> This footnote also confirms that Progressive Enterprises Ltd. has swept
this email message for th
e
> presence of computer viruses.  This does not guarantee this message is
virus free.
>
> --------------------------------------------------------------------------
-
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz



Rohit

======================================================================
CFL - Computer Fanatics Ltd.  21 Barry's Point Road, AKL, New Zealand
PH    (649) 489-2280
FX    (649) 489-2290
email [EMAIL PROTECTED]  or  [EMAIL PROTECTED]
======================================================================

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to