delphi4arab منتديات دلفي للعرب
ShellApi كيف افتح امتداد من listbox - نسخة قابلة للطباعة

+- delphi4arab منتديات دلفي للعرب (https://delphi4arab.net/forum)
+-- قسم : منتديات دلفي للعرب التعليمية (https://delphi4arab.net/forum/forumdisplay.php?fid=3)
+--- قسم : سؤال و جواب حول دلفي (https://delphi4arab.net/forum/forumdisplay.php?fid=15)
+--- الموضوع : ShellApi كيف افتح امتداد من listbox (/showthread.php?tid=12969)



ShellApi كيف افتح امتداد من listbox - عَمر - 05-09-2025

السلام عليكم


ShellApi كيف افتح امتداد من listbox
او مع اي اداة اخرى

كود :
ShellExecute(Handle,'open',***********, nil, nil, SW_SHOWNORMAL) ;



RE: ShellApi كيف افتح امتداد من listbox - larbiparadox - 05-09-2025

(05-09-2025, 02:29 PM)عَمر كتب : السلام عليكم


ShellApi كيف افتح امتداد من listbox
او مع اي اداة اخرى

كود :
ShellExecute(Handle,'open',***********, nil, nil, SW_SHOWNORMAL) ;

إقتباس :procedure TForm1.ListBox1KeyPress(Sender: TObject; var Key: Char);
var
SelectedFile: string;
FileExt: string;
begin
if (Key = #13) and (ListBox1.ItemIndex >= 0) then // Enter key
begin
SelectedFile := ListBox1.Items[ListBox1.ItemIndex];
FileExt := LowerCase(ExtractFileExt(SelectedFile));

case FileExt of
'.txt', '.log':
ShellExecute(Handle, 'open', 'notepad.exe', PChar(SelectedFile), nil, SW_SHOWNORMAL);
'.pdf':
ShellExecute(Handle, 'open', PChar(SelectedFile), nil, nil, SW_SHOWNORMAL);
'.exe':
ShellExecute(Handle, 'open', PChar(SelectedFile), nil, nil, SW_SHOWNORMAL);
else
ShellExecute(Handle, 'open', PChar(SelectedFile), nil, nil, SW_SHOWNORMAL);
end;
end;
end;

او بالضغط مرتين على الملف المحدد

إقتباس :procedure TForm1.ListBox1DblClick(Sender: TObject);
var
SelectedFile: string;
begin
if ListBox1.ItemIndex >= 0 then
begin
SelectedFile := ListBox1.Items[ListBox1.ItemIndex];
ShellExecute(Handle, 'open', PChar(SelectedFile), nil, nil, SW_SHOWNORMAL);
end;
end;

أو تحديد موقع الملف

إقتباس :procedure TForm1.Button1Click(Sender: TObject);
var
FilePath: string;
begin
if ListBox1.ItemIndex >= 0 then
begin
FilePath := ListBox1.Items[ListBox1.ItemIndex];
// فتح المجلد وتحديد الملف
ShellExecute(Handle, 'open', 'explorer.exe',
PChar('/select,' + FilePath), nil, SW_SHOWNORMAL);
end;
end;



RE: ShellApi كيف افتح امتداد من listbox - عَمر - 06-09-2025

جميل


كود :
procedure TForm1.ListBox1Click(Sender: TObject); var SelectedFile: string; begin if ListBox1.ItemIndex >= 0 then begin SelectedFile := ListBox1.Items[ListBox1.ItemIndex]; ShellExecute(Handle, 'open', PChar(SelectedFile), nil, nil, SW_SHOWNORMAL); end;