Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Screen Resolution and Tlistbox (https://www.delphipraxis.net/129053-screen-resolution-tlistbox.html)

Razor 11. Feb 2009 19:48


Screen Resolution and Tlistbox
 
I got a problem i can generate supported resolution modes in a ilstbox,right..
Then i got this after calling the enumdisplaysettings.This is in a listbox.

640X480 8 bit
640X480 8 bit
640X480 8 bit
640X480 8 bit
640X480 16 bit
640X480 16 bit
640X480 16 bit
640X480 16 bit

Can i somehow filter(remove) the items that have the same name.Couse i dont need that many items that are the same its confusing!

Bernhard Geyer 11. Feb 2009 19:50

Re: Screen Resolution and Tlistbox
 
Write the items first in a TStringList with
Delphi-Quellcode:
MyStringList.Duplicates := dupIgnore;
set and then assign it to the ListBox with
Delphi-Quellcode:
MyListBox.Items.Assign(MyStringList);

Meflin 11. Feb 2009 19:55

Re: Screen Resolution and Tlistbox
 
How do you call enumdisplaysettings? It doens't return duplicate entries.

Razor 11. Feb 2009 19:56

Re: Screen Resolution and Tlistbox
 
Delphi-Quellcode:
procedure tform4.res;

var
  i      : Integer;
  DevMode : TDeviceMode;
begin
  i:=0;


  while EnumDisplaySettings(nil,i,DevMode) do begin
    with Devmode do
      ListBox1.Items.Add(Format('%dx%d %d Colors',[dmPelsWidth,dmPelsHeight,1 shl dmBitsperPel]));
    Inc(i);
  end;

end;
[edit=mkinzler]Better readable with Delphi-Tags Mfg, mkinzler[/edit]

Meflin 11. Feb 2009 20:00

Re: Screen Resolution and Tlistbox
 
Hm, so I guess this is due to different refresh rates? Anyway, adding a mode only if it's not already in the list is preferable rather than removing duplicate entries afterwards.

By the way, you can find a complete implementation here (that ignores the duplicates):
http://burks.brighton.ac.uk/burks/la...s/fullscrn.htm

Razor 11. Feb 2009 20:01

Re: Screen Resolution and Tlistbox
 
Crap i always do something wrong...

Satty67 11. Feb 2009 20:11

Re: Screen Resolution and Tlistbox
 
Here my way :
Delphi-Quellcode:
var
  i      : Integer;
  DevMode : TDeviceMode;
  s : String;
begin
  i:=0;


  while EnumDisplaySettings(nil,i,DevMode) do begin
    with Devmode do
      s := Format('%dx%d %d Colors',[dmPelsWidth,dmPelsHeight,1 shl dmBitsperPel]);
    if ListBox1.Items.IndexOf(s) < 0 then ListBox1.Items.Add(s);

    Inc(i);
  end;

end;


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:36 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz