spiegel-keyman/windows/src/engine/tsysinfo/UframeAttachedFiles.pas
Marc Durdin b65b982584 Keyman Desktop and Keyman Developer open source 10.0 alpha seed (#121)
* Keyman for Windows 10.0 Open Source

* Squashed 'windows/src/ext/jedi/jedi/' content from commit f444ad2

git-subtree-dir: windows/src/ext/jedi/jedi
git-subtree-split: f444ad2da4693851e523f1ea6bd541f701904c24

* Squashed 'windows/src/ext/jedi/jcl/' content from commit d63d3c9fd

git-subtree-dir: windows/src/ext/jedi/jcl
git-subtree-split: d63d3c9fd9ff84efdd8159084ec6a60313644243

* Squashed 'windows/src/ext/jedi/jvcl/' content from commit bee19f3b4

git-subtree-dir: windows/src/ext/jedi/jvcl
git-subtree-split: bee19f3b46909fde2fa92c06cd2706f41d99f6c3

* Add required .res files

* Add required .res files

* Add docbook files (forced)

* Add required libxslt

* Add required jedi files

* Add installation files

* Tweak .gitignore for open

* CI

* Remove KMW from Developer source (#122)

* Remove KMW from Developer source (copies during build)

* Remove KMW from Developer source (copies during build)

* Remove KMW from Developer source (copies during build)

* Fixup release build and copy license, readme from kmw during build

* Remove obsolete build help documentation

* Keyman Engine 10 on Windows regression for shift states (#129)

* Improve #128 -- cleaner debug messages

* Fixes #127, shift state now resets correctly; and more work for #128

* Fixes #130 (#131)
2017-07-25 10:53:06 +07:00

141 lines
3.8 KiB
ObjectPascal

(*
Name: UframeAttachedFiles
Copyright: Copyright (C) SIL International.
Documentation:
Description:
Create Date: 23 Apr 2009
Modified Date: 1 Jan 2013
Authors: mcdurdin
Related Files:
Dependencies:
Bugs:
Todo:
Notes:
History: 23 Apr 2009 - mcdurdin - I1941 - Collect minidump files, diagnostic log files and zip them with the diagnostic report
08 Jun 2012 - mcdurdin - I3349 - V9.0 - Consolidate all process creation into TUtilExecute
01 Jan 2013 - mcdurdin - I3672 - V9.0 - tsysinfo attached files seem to be missing
*)
unit UframeAttachedFiles;
interface
uses
System.Types,
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, si_base, Grids, Menus;
type
TframeAttachedFiles = class(TForm) // I3672
gridFiles: TStringGrid;
PopupMenu1: TPopupMenu;
cmdOpen: TMenuItem;
cmdOpenContainingFolder: TMenuItem;
procedure FormResize(Sender: TObject);
procedure cmdOpenClick(Sender: TObject);
procedure cmdOpenContainingFolderClick(Sender: TObject);
procedure gridFilesMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
function SelectedDir: string;
function SelectedFile: string;
{ Private declarations }
public
{ Public declarations }
procedure AddFiles(Files: TStrings);
end;
implementation
uses
ShellApi, shlobj, utilexecute, utilsystem, sysinfo_util;
{$R *.dfm}
{ TframeAttachedFiles }
procedure TframeAttachedFiles.AddFiles(Files: TStrings);
var
i: Integer;
f: TSearchRec;
s: string;
begin
gridFiles.Cells[0,0] := 'Filename';
gridFiles.Cells[1,0] := 'Size';
gridFiles.Cells[2,0] := 'File Type';
gridFiles.Cells[3,0] := 'Path';
gridFiles.RowCount := Files.Count + 1;
gridFiles.ColWidths[0] := 150;
gridFiles.ColWidths[1] := 75;
gridFiles.ColWidths[2] := 75;
gridFiles.ColWidths[3] := gridFiles.ClientWidth - 303;
for i := 0 to Files.Count - 1 do
begin
gridFiles.Cells[0,i+1] := ExtractFileName(Files[i]);
if FindFirst(Files[i], 0, f) = 0 then
begin
gridFiles.Cells[1,i+1] := FileSizeKB(f.Size);
FindClose(f);
end
else
gridFiles.Cells[1,i+1] := 'unknown';
gridFiles.Cells[3,i+1] := ExtractFileDir(Files[i]);
s := LowerCase(ExtractFileExt(Files[i]));
if (s = '.log') or (s = '.errlog') then
gridFiles.Cells[2, i+1] := 'Log file'
else if (s = '.tmp') then
gridFiles.Cells[2, i+1] := 'Crash dump file'
else
gridFiles.Cells[2, i+1] := 'Other file';
end;
end;
function TframeAttachedFiles.SelectedFile: string;
begin
Result := gridFiles.Cells[3,gridFiles.Row]+'\'+gridFiles.Cells[0,gridFiles.Row];
end;
function TframeAttachedFiles.SelectedDir: string;
begin
Result := gridFiles.Cells[3,gridFiles.Row];
end;
procedure TframeAttachedFiles.cmdOpenClick(Sender: TObject);
begin
if not TUtilExecute.Shell(Handle, SelectedFile, SelectedDir) then // I3349
ShowMessage(SysErrorMessage(GetLastError));
end;
procedure TframeAttachedFiles.cmdOpenContainingFolderClick(Sender: TObject);
begin
OpenContainingFolder(SelectedFile);
end;
procedure TframeAttachedFiles.FormResize(Sender: TObject);
begin
inherited;
gridFiles.ColWidths[3] := gridFiles.ClientWidth - 303;
end;
procedure TframeAttachedFiles.gridFilesMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
ACol: Integer;
ARow: Integer;
begin
inherited;
if Button = mbRight then
begin
gridFiles.MouseToCell(X, Y, ACol, ARow);
if (ARow > 0) then
begin
gridFiles.Row := ARow;
with gridFiles.ClientToScreen(Point(X,Y)) do
PopupMenu1.Popup(X, Y);
end;
end;
end;
end.