gpt4 book ai didi

德尔福XE2 : TListView as tile view not working in Windows XP

转载 作者:行者123 更新时间:2023-12-03 03:18:15 29 4
gpt4 key购买 nike

我有一个在 TListView 控件上使用 LV_VIEW_TILE 的代码:

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

procedure TileView(aListView: TListView);
var
ti: TLVTILEINFO;
Order: array of Integer;
tvi: TLVTILEVIEWINFO;
i: integer;
begin
ListView_SetView(aListView.Handle, LV_VIEW_TILE);

for i := 0 to aListView.Items.Count - 1 do begin
FillChar(ti, SizeOf(ti), 0);
ti.cbSize := SizeOf(ti);
// First item
ti.iItem := i;
// Specifying the order for three columns
ti.cColumns := 4;
// Array initialization
SetLength(order, ti.cColumns);
// The order is 2nd, 3rd and 4th columns
order[0] := 1;
order[1] := 2;
order[2] := 3;
order[3] := 4;
ti.puColumns := PUINT(order);
ListView_SetTileInfo(aListView.Handle, ti);
end;

tvi.cbSize := Sizeof(tvi);
tvi.dwMask := LVTVIM_COLUMNS;
// Requesting space to draw the caption + 3 subitems
tvi.cLines := aListView.Columns.Count;
ListView_SetTileViewInfo(aListView.Handle, tvi);
end;

procedure TForm3.FormCreate(Sender: TObject);
var V: TListView;
A: TListItem;
begin
V := TListView.Create(Self);
V.Parent := Self;
V.Align := alClient;

V.Columns.Add;

A := V.Items.Add;
A.Caption := 'Item A';
A.SubItems.Add('Sub A');

A := V.Items.Add;
A.Caption := 'Item B';
A.SubItems.Add('Sub B');

TileView(V);
end;

使用Delphi 2007编译并构建代码并在Windows XP中运行该应用程序,它显示:

enter image description here

用Delphi XE2编译相同的代码并在Windows XP中运行,显示:

enter image description here

在Delphi XE2中编译时不显示子项。

两个 Delphi 2007/XE2 应用程序都显示 Windows 7 中的平铺 View 子项。

我尝试将 list 嵌入应用程序的资源中或作为外部文件:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
type="win32"
name="DelphiApplication"
version="1.0.0.0"
processorArchitecture="*"/>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="*"/>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="asInvoker"
uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

知道为什么 Delphi XE2 编译的应用程序在 Windows XP 中不显示平铺 View 吗?

最佳答案

Delphi XE2中的Unit Winapi.CommCtrl.pas定义:

tagLVTILEINFO = record
cbSize: UINT;
iItem: Integer;
cColumns: UINT;
puColumns: PUINT;

piColFmt: PInteger;

end;

但是MSDN API定义为:

typedef struct LVTILEINFO {
UINT cbSize;
int iItem;
UINT cColumns;
PUINT puColumns;
#if (_WIN32_WINNT >= 0x0600)
int *piColFmt;
#endif
} LVTILEINFO, *PLVTILEINFO;

piColFmt 不应该在 Windows XP 平台上使用。删除 piColFmt 应该可以在 Windows XP 中使用。

关于德尔福XE2 : TListView as tile view not working in Windows XP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9221835/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com