Use TOpenTextFileDialog instead of TOpenDialog for two places where we load SQL and text cell contents. That dialog has an additional "Encoding" dropdown, where the user can select the file's encoding, which can be required if the auto detection did not succeed. Fixes issue #2025.

This commit is contained in:
Ansgar Becker
2010-06-20 10:05:37 +00:00
parent bd3c391b39
commit d436df314a
5 changed files with 90 additions and 88 deletions

View File

@ -4,7 +4,7 @@ interface
uses
Windows, Classes, Graphics, Forms, Controls, StdCtrls, VirtualTrees,
ComCtrls, ToolWin, Dialogs, SysUtils, Menus,
ComCtrls, ToolWin, Dialogs, SysUtils, Menus, ExtDlgs,
helpers;
{$I const.inc}
@ -217,14 +217,16 @@ end;
procedure TfrmTextEditor.btnLoadTextClick(Sender: TObject);
var
d: TOpenDialog;
d: TOpenTextFileDialog;
begin
d := TOpenDialog.Create(Self);
d := TOpenTextFileDialog.Create(Self);
d.Filter := 'Textfiles (*.txt)|*.txt|All files (*.*)|*.*';
d.FilterIndex := 0;
d.Encodings.Assign(MainForm.FileEncodings);
d.EncodingIndex := 0;
if d.Execute then try
Screen.Cursor := crHourglass;
memoText.Text := ReadTextFile(d.FileName);
memoText.Text := ReadTextFile(d.FileName, MainForm.GetEncodingByName(d.Encodings[d.EncodingIndex]));
if (memoText.MaxLength > 0) and (Length(memoText.Text) > memoText.MaxLength) then
memoText.Text := copy(memoText.Text, 0, memoText.MaxLength);
finally