Example 1
{...}type
TForm1 = class(TForm)
Button1: TButton;
ListView1: TListView;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
{ 05/31/99 - added TListView.OnDblClick event }
procedure ListView1DblClick(Sender: TObject);
private
{ Private declarations }
{ 05/31/99 - moved here for4m TButton.OnClick
event as an array so we can use
the array to get the TDevMode for
the selected one from the TListView }
DevMode : array[0..20] of TDevMode;
public
{ Public declarations }
end; {...}procedure TForm1.FormCreate(Sender: TObject);
begin
{ set viewstyle to vsReport }
ListView1.ViewStyle := vsReport; { set rowselect to TRUE }
ListView1.RowSelect := TRUE; {add our columns ans set their values }
ListView1.Columns.Add;
ListView1.Columns.Add;
ListView1.Columns[0].Caption := 'Width x Height';
ListView1.Columns[0].Width := 100;
ListView1.Columns[1].Caption := 'Colors';
ListView1.Columns[1].Width := 100;
end;procedure TForm1.Button1Click(Sender: TObject);
var
{ moved to be a private array so we can use
the array to get the TDevMode for the
selected one from the TListView }
{ DevMode : TDevMode; }
tmpStr1,
tmpStr2 : String;
tmpDC : HDC;
x,
Selection,
cxScreen,
cyScreen,
Resolution : Integer;
begin
{ get our color mode }
tmpDC := getDC(Handle);
try
cxScreen := GetSystemMetrics(SM_CXSCREEN);
cyScreen := GetSystemMetrics(SM_CYSCREEN);
Resolution := GetDeviceCaps(tmpDC, BITSPIXEL);
finally
ReleaseDC(Handle, tmpDC);
end; ListView1.Items.Clear;
x := 0; { 05/31/99 - changed DevMode to an array to
hold all the TDevMode values to be
easily selected on a TListView
OnDblClick event }
{ enumerate all possible display settings }
while EnumDisplaySettings(nil,x,DevMode[x]) do
begin { screen width and height }
tmpStr1 := IntToStr(DevMode[x].dmPelsWidth)+
'x'+
IntToStr(DevMode[x].dmPelsHeight); { colors }
case DevMode[x].dmBitsPerPel of
4 : tmpStr2 := '16 Colors';
8 : tmpStr2 := '256 Colors';
16 : tmpStr2 := 'High Color (16 Bit)';
32 : tmpStr2 := 'True Color (32 Bit)';
end; { add resolution to out tlistbox }
with ListView1.Items.Add do
begin
Caption := tmpStr1;
SubItems.Add(tmpStr2);
end; { compare our settings to the one being added
and set a variable to be used to visually
set out display settings in our tlistview }
if ( cxScreen = DevMode[x].dmPelsWidth ) and
( cyScreen = DevMode[x].dmPelsHeight ) and
( Resolution = DevMode[x].dmBitsPerPel ) then
Selection := x; { inc to the next display setting in the array }
inc(x); { 05/31/99 - make sure we do not over
run our array }
if x = 20 then
Break;
end; { set our tlistview to select our current setting
according the the compare done within the above
loop }
ActiveControl := ListView1;
ListView1.Selected := ListView1.Items.Item[Selection];
end;{ 05/31/99 }
procedure TForm1.ListView1DblClick(Sender: TObject);
var
tmpDevMode : TDevMode;
begin
{ get our selected TDevMode structure }
tmpDevMode := DevMode[ListView1.Items.IndexOf(ListView1.Selected)]; { tell windows what seetings in the TDevMode structure to us, we
do this by setting the TDevMode.dmFields flag }
tmpDevMode.dmFields := DM_BITSPERPEL or
DM_PELSWIDTH or
DM_PELSHEIGHT or
DM_DISPLAYFLAGS or
DM_DISPLAYFREQUENCY; { use the CDS_TEST flag first to test that the selected display
setting will work properly, then actually set the new dusplay
settings }
if ChangeDisplaySettings(tmpDevMode,
CDS_TEST) = DISP_CHANGE_SUCCESSFUL then
ChangeDisplaySettings(tmpDevMode,
CDS_UPDATEREGISTRY);
end;{...}
{...}type
TForm1 = class(TForm)
Button1: TButton;
ListView1: TListView;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
{ 05/31/99 - added TListView.OnDblClick event }
procedure ListView1DblClick(Sender: TObject);
private
{ Private declarations }
{ 05/31/99 - moved here for4m TButton.OnClick
event as an array so we can use
the array to get the TDevMode for
the selected one from the TListView }
DevMode : array[0..20] of TDevMode;
public
{ Public declarations }
end; {...}procedure TForm1.FormCreate(Sender: TObject);
begin
{ set viewstyle to vsReport }
ListView1.ViewStyle := vsReport; { set rowselect to TRUE }
ListView1.RowSelect := TRUE; {add our columns ans set their values }
ListView1.Columns.Add;
ListView1.Columns.Add;
ListView1.Columns[0].Caption := 'Width x Height';
ListView1.Columns[0].Width := 100;
ListView1.Columns[1].Caption := 'Colors';
ListView1.Columns[1].Width := 100;
end;procedure TForm1.Button1Click(Sender: TObject);
var
{ moved to be a private array so we can use
the array to get the TDevMode for the
selected one from the TListView }
{ DevMode : TDevMode; }
tmpStr1,
tmpStr2 : String;
tmpDC : HDC;
x,
Selection,
cxScreen,
cyScreen,
Resolution : Integer;
begin
{ get our color mode }
tmpDC := getDC(Handle);
try
cxScreen := GetSystemMetrics(SM_CXSCREEN);
cyScreen := GetSystemMetrics(SM_CYSCREEN);
Resolution := GetDeviceCaps(tmpDC, BITSPIXEL);
finally
ReleaseDC(Handle, tmpDC);
end; ListView1.Items.Clear;
x := 0; { 05/31/99 - changed DevMode to an array to
hold all the TDevMode values to be
easily selected on a TListView
OnDblClick event }
{ enumerate all possible display settings }
while EnumDisplaySettings(nil,x,DevMode[x]) do
begin { screen width and height }
tmpStr1 := IntToStr(DevMode[x].dmPelsWidth)+
'x'+
IntToStr(DevMode[x].dmPelsHeight); { colors }
case DevMode[x].dmBitsPerPel of
4 : tmpStr2 := '16 Colors';
8 : tmpStr2 := '256 Colors';
16 : tmpStr2 := 'High Color (16 Bit)';
32 : tmpStr2 := 'True Color (32 Bit)';
end; { add resolution to out tlistbox }
with ListView1.Items.Add do
begin
Caption := tmpStr1;
SubItems.Add(tmpStr2);
end; { compare our settings to the one being added
and set a variable to be used to visually
set out display settings in our tlistview }
if ( cxScreen = DevMode[x].dmPelsWidth ) and
( cyScreen = DevMode[x].dmPelsHeight ) and
( Resolution = DevMode[x].dmBitsPerPel ) then
Selection := x; { inc to the next display setting in the array }
inc(x); { 05/31/99 - make sure we do not over
run our array }
if x = 20 then
Break;
end; { set our tlistview to select our current setting
according the the compare done within the above
loop }
ActiveControl := ListView1;
ListView1.Selected := ListView1.Items.Item[Selection];
end;{ 05/31/99 }
procedure TForm1.ListView1DblClick(Sender: TObject);
var
tmpDevMode : TDevMode;
begin
{ get our selected TDevMode structure }
tmpDevMode := DevMode[ListView1.Items.IndexOf(ListView1.Selected)]; { tell windows what seetings in the TDevMode structure to us, we
do this by setting the TDevMode.dmFields flag }
tmpDevMode.dmFields := DM_BITSPERPEL or
DM_PELSWIDTH or
DM_PELSHEIGHT or
DM_DISPLAYFLAGS or
DM_DISPLAYFREQUENCY; { use the CDS_TEST flag first to test that the selected display
setting will work properly, then actually set the new dusplay
settings }
if ChangeDisplaySettings(tmpDevMode,
CDS_TEST) = DISP_CHANGE_SUCCESSFUL then
ChangeDisplaySettings(tmpDevMode,
CDS_UPDATEREGISTRY);
end;{...}
解决方案 »
- 做一个销售库存管理,最多30个客户端(分店),用什么方案好?
- 各位大吓,小妹在这请教Delphi中的bold是什么呀?还有怎么用
- 关于TIdHttp的用法(在线)
- delphi能不能LOAD默认(default)的设计环境--(发现ctr+z,x,c,v用不了)
- {500分}怎么做输出PAGEMAKER的报表,要求可以分栏,图文混排
- DELPHI与ACCESS联接,当去查询日期型的数据时,没有记录(数据表里有记录)怎样解决。谢谢。
- 急急急急。。一个新西兰留学生的问题
- 如何限制附件容量??
- 数据同步的问题,有三层数据库开发经验的老手,欢迎加入。
- 高分求救!Delphi5.0+Access(Ado)?
- 我需要一个实例证明XML在Web Service中的应用,谁帮帮我呀??高分。
- 请问,Delphi中有类似VC的静态变量吗?
修改窗体的SCALED属性为FALSE 并且设置TFONT属性的字符集为CHINESE
你的问题说分辨率都是800*600,我怀疑是这个因素.