找到一个,但是有行代码过不去。说第58行有问题:
[dcc32 Error] Unit7.pas(58): E2003 Undeclared identifier: 'SyncBoxes'
https://www.coder.work/article/7598186
[Delphi] 纯文本查看 复制代码 unit Unit7;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants,
System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs,
Vcl.StdCtrls, Vcl.ExtCtrls;
type
TForm7 = class(TForm)
编码转换与快搜: TPanel;
BZS: TPanel;
PBZS_db: TPanel;
ListBoxX: TListBox;
ListBoxY: TListBox;
ListBoxZ: TListBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure ListBoxXClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
SyncBoxes: TArray<TListBox>;
end;
type
TListBox = class(Vcl.StdCtrls.TListBox)
strict private
procedure Sync;
protected
procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL;
procedure CNCommand(var Message: TWMCommand); message CN_COMMAND;
procedure WMMouseWheel(var Message: TWMMouseWheel); message WM_MOUSEWHEEL;
end;
var
Form7: TForm7;
implementation
{$R *.dfm}
procedure TListBox.CNCommand(var Message: TWMCommand);
begin
inherited;
if Message.NotifyCode = LBN_SELCHANGE then
Sync;
end;
procedure TListBox.Sync;
var
LB: TListBox;
begin
for LB in SyncBoxes do
if LB <> Self then
LB.TopIndex := Self.TopIndex;
end;
procedure TListBox.WMMouseWheel(var Message: TWMMouseWheel);
begin
inherited;
Sync;
end;
procedure TListBox.WMVScroll(var Message: TWMVScroll);
begin
inherited;
Sync;
end;
procedure TForm7.FormCreate(Sender: TObject);
begin
SyncBoxes := [ListBoxX, ListBoxY, ListBoxZ];
end;
procedure TForm7.Button1Click(Sender: TObject);
begin
ListBoxX.Items.LoadFromFile('X:\0.自创工具for delphi10.4.1\61.Delphi版音速启动\Win32\Release\ListX.txt');
ListBoxY.Items.LoadFromFile('X:\0.自创工具for delphi10.4.1\61.Delphi版音速启动\Win32\Release\ListY.txt');
ListBoxZ.Items.LoadFromFile('X:\0.自创工具for delphi10.4.1\61.Delphi版音速启动\Win32\Release\ListZ.txt');
end;
procedure TForm7.ListBoxXClick(Sender: TObject);
begin
//ShowMessage(ListBoxX.Items[ListBoxX.ItemIndex]);
if ListBoxX.Selected[ListBoxX.ItemIndex] = True then
begin
// ListBoxY.ScrollBy(ListBoxX.ItemIndex, ListBoxX.ItemIndex);
// ListBoxZ.ScrollBy(ListBoxX.ItemIndex, ListBoxX.ItemIndex);
ListBoxY.Selected[ListBoxX.ItemIndex] := True;
ListBoxZ.Selected[ListBoxX.ItemIndex] := True;
ListBoxY.ItemIndex := ListBoxX.ItemIndex;
ListBoxZ.ItemIndex := ListBoxX.ItemIndex;
ListBoxX.TopIndex
end;
end;
end.
|