Пример создания FileListBox
Автор: Mikel
WEB-сайт: http://forum.vingrad.ru
{uses ShellApi}
procedure TForm1.ListBox1DblClick(Sender: TObject);
var
s: string;
begin
s := listbox1.Items[SendMessage(ListBox1.Handle, lb_GetCurSel, 0, 0)];
if edit1.Text[length(edit1.text)] <> '\' then
edit1.text := concat(edit1.text + '\');
if (not FileExists(edit1.text + s)) and (s[1] = '[') and (s[length(s)] = ']')
then
DlgDirList(handle,
PChar(edit1.text + copy(s, 2, length(s) - 2)),
ListBox1.Handle,
Edit1.Handle,
faAnyFile
);
if edit1.Text[length(edit1.text)] <> '\' then
edit1.text := concat(edit1.text + '\');
if FileExists(edit1.text + s) then
begin
caption := edit1.text + s;
ShellExecute(handle, 'open', PChar(edit1.text + s), '', 'c:\', sw_show);
end
end;
procedure TForm1.FormShow(Sender: TObject);
begin
edit1.Width := 1024 * 8 - 1;
edit1.Visible := false;
DlgDirList(handle,
PChar('c:\'),
ListBox1.Handle,
Edit1.Handle,
faAnyFile
);
listbox1.Sorted := false;
listbox1.Sorted := true;
end;
|