Delphi XE2:TListView 作为平铺视图在 Windows XP 中不起作用

发布于 2025-01-03 20:13:55 字数 2731 浏览 1 评论 0原文

我有一个在 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 中运行该应用程序,它显示:

在此处输入图像描述

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

在此处输入图像描述

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

Delphi 2007/XE2 应用程序都在 Windows 7 中显示平铺视图子项

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

<?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 中不显示平铺视图?

I have a code that use LV_VIEW_TILE on TListView control:

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;

Compile and build the code with Delphi 2007 and run the application in Windows XP, it shows:

enter image description here

Compile the same code with Delphi XE2 and run in Windows XP, it shows:

enter image description here

The subitems doesn't shows when compile in Delphi XE2.

Both Delphi 2007/XE2 applications shows the tiled view subitems in Windows 7.

I have tried embed manifest in the application's resource or as external files:

<?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>

Any ideas why Delphi XE2 compiled application doesn't show tiled view in Windows XP?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不醒的梦 2025-01-10 20:13:55

Delphi XE2 中的单元 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 中使用。

Unit Winapi.CommCtrl.pas in Delphi XE2 define:

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

  piColFmt: PInteger;

end;

But MSDN API define as:

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

piColFmt shouldn't be used in Windows XP platform. Remove the piColFmt should works in Windows XP.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文