当前位置:主页>销售管理软件> 列表

DOS窗口是用什么控件?Memo1 还是 RichEdit 找财务记账软件哪个好

财务软件版1楼: 想仿照DOS做个输入界面。是选择 Memo1 还是 RichEdit1 ?
DOS窗口在 > 之前的内容都不能修改 。每次光标都在 > 后闪烁 。
并且只能在 > 后输入命令 。有谁知道原理?

2楼: New -> Consol Application 如速达财务软件售后

3楼: 如楼上:New -> Consol Application
本来就有一个终端程序模板的。
miniQQ就是delphi开发的模拟DOS程序

4楼: 当然是可以用Memo1 了,最简单,把底色改成黑色就可以了
如果想做的再逼真一点,那就把光标和提示符都改一下就可以了
RichEdit1是牛刀,你的需求是杀鸡:)
不知道这样回答行吗?

5楼: [red]在 > 之前的内容都不能修改 。每次光标都在 > 后闪烁 。
并且只能在 > 后输入命令[/red]
主要是上面这些要求。既然是仿DOS窗口。
我是用管道CreatePipe和CreateProcess 取得命令的返回值。
想在同一个窗口输入命令 只能在 > 后面输入命令
取得返回的东西显示在此窗口后面加 ''> ''。‘>’之前的内容只能看不能改和删除。
明白我的意思没有?是用在远程维护上的 。想做的更像DOS一些

6楼: 刚刚为你写的,仅供参考:

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TCommandProc=procedure (Sender:TObject;cmd:string)of object;
TDosWindow=class(TCustomEdit)
private
FLines: TStrings;
FAlignment: TAlignment;
FScrollBars: TScrollStyle;
FWordWrap: Boolean;
FWantReturns: Boolean;
FWantTabs: Boolean;
FPath:string;
FPrompt:string;
FCommand: TCommandProc;
procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE;
procedure WMNCDestroy(var Message: TWMNCDestroy); message WM_NCDESTROY;
procedure SetPath(const Value: string);
procedure SetPrompt(const Value: string);
protected
function GetCaretPos: TPoint; virtual;
procedure SetCaretPos(const Value: TPoint); virtual;
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWindowHandle(const Params: TCreateParams); override;
procedure KeyPress(var Key: Char); override;
procedure Loaded; override;
procedure SetAlignment(Value: TAlignment);
procedure SetLines(Value: TStrings);
procedure SetScrollBars(Value: TScrollStyle);
procedure SetWordWrap(Value: Boolean);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function GetControlsAlignment: TAlignment; override;
published
property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify;
property CaretPos: TPoint read GetCaretPos write SetCaretPos;
property Command: TCommandProc read FCommand write FCommand;
property Lines: TStrings read FLines write SetLines;
property Path: string read FPath write SetPath;
property Prompt: string read FPrompt write SetPrompt;
property ScrollBars: TScrollStyle read FScrollBars write SetScrollBars default ssNone;
property WantReturns: Boolean read FWantReturns write FWantReturns default True;
property WantTabs: Boolean read FWantTabs write FWantTabs default False;
property WordWrap: Boolean read FWordWrap write SetWordWrap default True;
end;
TDosBox = class(TStrings)
private
DosWindow: TDosWindow;
protected
function Get(Index: Integer): string; override;
function GetCount: Integer; override;
function GetTextStr: string; override;
procedure Put(Index: Integer; const S: string); override;
procedure SetTextStr(const Value: string); override;
procedure SetUpdateState(Updating: Boolean); override;
public
procedure Clear; override;
procedure Delete(Index: Integer); override;
procedure Insert(Index: Integer; const S: string); override;
end;

// 动态加载测试 Form
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
DosBox:TDosWindow;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}



function TDosBox.GetCount: Integer;
begin
Result := 0;
if DosWindow.HandleAllocated or (DosWindow.WindowText <> nil) then
begin
Result := SendMessage(DosWindow.Handle, EM_GETLINECOUNT, 0, 0);
if SendMessage(DosWindow.Handle, EM_LINELENGTH, SendMessage(DosWindow.Handle,
EM_LINEINDEX, Result - 1, 0), 0) = 0 then Dec(Result);
end;
end;

function TDosBox.Get(Index: Integer): string;
var
Text: array[0..4095] of Char;
begin
Word((@Text)^) := SizeOf(Text);
SetString(Result, Text, SendMessage(DosWindow.Handle, EM_GETLINE, Index,
Longint(@Text)));
end;

procedure TDosBox.Put(Index: Integer; const S: string);
var
SelStart: Integer;
DosString:string;
begin
DosString:=DosWindow.FPath+DosWindow.FPrompt+S;
SelStart := SendMessage(DosWindow.Handle, EM_LINEINDEX, Index, 0);
if SelStart >= 0 then
begin
SendMessage(DosWindow.Handle, EM_SETSEL, SelStart, SelStart +
SendMessage(DosWindow.Handle, EM_LINELENGTH, SelStart, 0));

SendMessage(DosWindow.Handle, EM_REPLACESEL, 0, Longint(PChar(DosString)));
end;
end;

procedure TDosBox.Insert(Index: Integer; const S: string);
var
SelStart, LineLen: Integer;
Line: string;
DosString:string;
begin
DosString:=DosWindow.FPath+DosWindow.FPrompt+S;
if Index >= 0 then
begin
SelStart := SendMessage(DosWindow.Handle, EM_LINEINDEX, Index, 0);
if SelStart >= 0 then Line := DosString else
begin
SelStart := SendMessage(DosWindow.Handle, EM_LINEINDEX, Index - 1, 0);
if SelStart < 0 then Exit;
LineLen := SendMessage(DosWindow.Handle, EM_LINELENGTH, SelStart, 0);
if LineLen = 0 then Exit;
Inc(SelStart, LineLen);
Line := #13#10 + DosString;
end;
SendMessage(DosWindow.Handle, EM_SETSEL, SelStart, SelStart);
SendMessage(DosWindow.Handle, EM_REPLACESEL, 0, Longint(PChar(Line)));
end;
end;

procedure TDosBox.Delete(Index: Integer);
const
Empty: PChar = '''';
var
SelStart, SelEnd: Integer;
begin
SelStart := SendMessage(DosWindow.Handle, EM_LINEINDEX, Index, 0);
if SelStart >= 0 then
begin
SelEnd := SendMessage(DosWindow.Handle, EM_LINEINDEX, Index + 1, 0);
if SelEnd < 0 then SelEnd := SelStart +
SendMessage(DosWindow.Handle, EM_LINELENGTH, SelStart, 0);
SendMessage(DosWindow.Handle, EM_SETSEL, SelStart, SelEnd);
SendMessage(DosWindow.Handle, EM_REPLACESEL, 0, Longint(Empty));
end;
end;

procedure TDosBox.Clear;
begin
DosWindow.Clear;
end;

procedure TDosBox.SetUpdateState(Updating: Boolean);
begin
if DosWindow.HandleAllocated then
begin
SendMessage(DosWindow.Handle, WM_SETREDRAW, Ord(not Updating), 0);
if not Updating then
begin
DosWindow.Perform(CM_SHOWINGCHANGED,0,0);
DosWindow.Refresh;
end;
end;
end;

function TDosBox.GetTextStr: string;
begin
Result := DosWindow.Text;
end;

procedure TDosBox.SetTextStr(const Value: string);
var
NewText: string;
begin
NewText := AdjustLineBreaks(Value);
if (Length(NewText) <> DosWindow.GetTextLen) or (NewText <> DosWindow.Text) then
begin
if SendMessage(DosWindow.Handle, WM_SETTEXT, 0, Longint(NewText)) = 0 then
exit;
DosWindow.Perform(CM_TEXTCHANGED, 0, 0);
end;
end;

constructor TDosWindow.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Width := 185;
Height := 89;
FPath := GetCurrentDir;
FPrompt := ''>'';
Color:=clBlack;
// Font.Name:=''Fixedsys'';
Font.Color:=clWhite;
AutoSize := False;
FWordWrap := True;
FWantReturns := True;
FLines := TDosBox.Create;
TDosBox(FLines).DosWindow := Self;
ParentBackground := False;
end;

destructor TDosWindow.Destroy;
begin
FLines.Free;
inherited Destroy;
end;

procedure TDosWindow.CreateParams(var Params: TCreateParams);
const
Alignments: array[Boolean, TAlignment] of DWORD =
((ES_LEFT, ES_RIGHT, ES_CENTER),(ES_RIGHT, ES_LEFT, ES_CENTER));
ScrollBar: array[TScrollStyle] of DWORD = (0, WS_HSCROLL, WS_VSCROLL,
WS_HSCROLL or WS_VSCROLL);
WordWraps: array[Boolean] of DWORD = (0, ES_AUTOHSCROLL);
begin
inherited CreateParams(Params);
with Params do
begin
Style := Style and not WordWraps[FWordWrap] or ES_MULTILINE or
Alignments[UseRightToLeftAlignment, FAlignment] or ScrollBar[FScrollBars];
end;
end;

procedure TDosWindow.CreateWindowHandle(const Params: TCreateParams);
begin
with Params do
begin
if SysLocale.FarEast and (Win32Platform <> VER_PLATFORM_WIN32_NT) and
((Style and ES_READONLY) <> 0) then
begin
WindowHandle := CreateWindowEx(ExStyle, WinClassName, '''',
Style and (not ES_READONLY),
X, Y, Width, Height, WndParent, 0, HInstance, Param);
if WindowHandle <> 0 then
SendMessage(WindowHandle, EM_SETREADONLY, Ord(True), 0);


end
else
WindowHandle := CreateWindowEx(ExStyle, WinClassName, '''', Style,
X, Y, Width, Height, WndParent, 0, HInstance, Param);
SendMessage(WindowHandle, WM_SETTEXT, 0, Longint(Caption));
end;
FLines.Clear;
FLines.Add('''');
end;

function TDosWindow.GetCaretPos: TPoint;
begin
Result.X := LongRec(SendMessage(Handle, EM_GETSEL, 0, 0)).Hi;
Result.Y := SendMessage(Handle, EM_LINEFROMCHAR, Result.X, 0);
Result.X := Result.X - SendMessage(Handle, EM_LINEINDEX, -1, 0);
end;

procedure TDosWindow.SetCaretPos(const Value: TPoint);
var
CharIdx: Integer;
begin
CharIdx := SendMessage(Handle, EM_LINEINDEX, Value.y, 0) + Value.x;
// if CharIdx SendMessage(Handle, EM_SETSEL, CharIdx, CharIdx);
end;

function TDosWindow.GetControlsAlignment: TAlignment;
begin
Result := FAlignment;
end;

procedure TDosWindow.Loaded;
begin
inherited Loaded;
Modified := False;
end;

procedure TDosWindow.SetAlignment(Value: TAlignment);
begin
if FAlignment <> Value then
begin
FAlignment := Value;
RecreateWnd;
end;
end;

procedure TDosWindow.SetLines(Value: TStrings);
begin
FLines.Assign(Value);
end;

procedure TDosWindow.SetScrollBars(Value: TScrollStyle);
begin
if FScrollBars <> Value then
begin
FScrollBars := Value;
RecreateWnd;
end;
end;

procedure TDosWindow.SetWordWrap(Value: Boolean);
begin
if Value <> FWordWrap then
begin
FWordWrap := Value;
RecreateWnd;
end;
end;

procedure TDosWindow.WMGetDlgCode(var Message: TWMGetDlgCode);
begin
inherited;
if FWantTabs then Message.Result := Message.Result or DLGC_WANTTAB
else Message.Result := Message.Result and not DLGC_WANTTAB;
if not FWantReturns then
Message.Result := Message.Result and not DLGC_WANTALLKEYS;

end;

procedure TDosWindow.WMNCDestroy(var Message: TWMNCDestroy);
begin
inherited;
end;

procedure TDosWindow.KeyPress(var Key: Char);
var
n:integer;
begin
inherited KeyPress(Key);
if (Key = Char(VK_RETURN)) then //and not FWantReturns then Key := #0;
begin
n:=FLines.Count-1;
if Assigned(FCommand) then
FCommand(Self,Copy(FLines[n],Length(FPath+FPrompt),Length(FLines[n])));
Key:=#0;
FLines.Add('''');
end;
end;

procedure TDosWindow.SetPath(const Value: string);
begin
FPath := Value;
end;

procedure TDosWindow.SetPrompt(const Value: string);
begin
FPrompt := Value;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
DosBox:=TDosWindow.Create(Self);
DosBox.Parent:=Self;
DosBox.Align:=alClient;
end;

end.

财务软件版7楼: 改了改,把窗口弄成黑的了,字体改为白的了。还有就是限制写入点的位置,你自己改吧。

8楼: TO 小雨哥
谢谢很像DOS窗口。


constructor TDosWindow.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Width := 185;
Height := 89;
FPath := GetCurrentDir;
FPrompt := ''>'';
AutoSize := False;
FWordWrap := True;
FWantReturns := True;
FLines := TDosBox.Create;
TDosBox(FLines).DosWindow := Self;
[red]ParentBackground := False;[/red]
end;
红色部分出错。注释红色的这句。> 前面的内容可以被删除 。红色部分是保证
> 之前的内容为只读的吗?ParentBackground 没有定义呀

9楼: sorry,我只是把 Memo 重新改写了一下,写这个代码用了仅仅不到10分钟,里面除了增加
了命令行提示符外,我什么都没改,比如限制写入点,命令解析等等,你自己改吧,上面
代码就是一个意思而已。

10楼: TO 小雨哥
谢谢你的代码。其他我都写好了。用你的代码也能够得到 > 后面的命令。
现在的问题就是还可以把 > 之前的内容修改。我需要把 > 之前的内容设为只读。
如何设为只读?

11楼: 好吧,好吧,好人做到底。不过声明啊,有错误你自己改,再有需求,也要你自己动手了。
下面我把你要求的只读做好了:

unit Unit1;



interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TCommandProc=procedure (Sender:TObject;cmd:string)of object;
TDosWindow=class(TCustomEdit)
private
FLines: TStrings;
FAlignment: TAlignment;
FScrollBars: TScrollStyle;
FWordWrap: Boolean;
FWantReturns: Boolean;
FWantTabs: Boolean;
FPath:string;
FPrompt:string;
FCommand: TCommandProc;
FDescribe:string;
procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE;
procedure WMNCDestroy(var Message: TWMNCDestroy); message WM_NCDESTROY;
procedure SetPath(const Value: string);
procedure SetPrompt(const Value: string);
protected
function GetCaretPos: TPoint; virtual;
procedure SetCaretPos(const Value: TPoint); virtual;
procedure CreateParams(var Params: TCreateParams); override;
procedure CreateWindowHandle(const Params: TCreateParams); override;

procedure KeyPress(var Key: Char); override;
procedure Loaded; override;
procedure SetAlignment(Value: TAlignment);
procedure SetLines(Value: TStrings);
procedure SetScrollBars(Value: TScrollStyle);
procedure SetWordWrap(Value: Boolean);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function GetControlsAlignment: TAlignment; override;
published
property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify;
property CaretPos: TPoint read GetCaretPos write SetCaretPos;
property Command: TCommandProc read FCommand write FCommand;
property Lines: TStrings read FLines write SetLines;
property Path: string read FPath write SetPath;
property Prompt: string read FPrompt write SetPrompt;
property ScrollBars: TScrollStyle read FScrollBars write SetScrollBars default ssNone;
property WantReturns: Boolean read FWantReturns write FWantReturns default True;
property WantTabs: Boolean read FWantTabs write FWantTabs default False;
property WordWrap: Boolean read FWordWrap write SetWordWrap default True;
end;
TDosBox = class(TStrings)
private
DosWindow: TDosWindow;
protected
function Get(Index: Integer): string; override;
function GetCount: Integer; override;
function GetTextStr: string; override;
procedure Put(Index: Integer; const S: string); override;
procedure SetTextStr(const Value: string); override;
procedure SetUpdateState(Updating: Boolean); override;
public
procedure Clear; override;
procedure Delete(Index: Integer); override;
procedure Insert(Index: Integer; const S: string); override;
end;

// 动态加载测试 Form
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
DosBox:TDosWindow;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

function TDosBox.GetCount: Integer;
begin
Result := 0;
if DosWindow.HandleAllocated or (DosWindow.WindowText <> nil) then
begin
Result := SendMessage(DosWindow.Handle, EM_GETLINECOUNT, 0, 0);
if SendMessage(DosWindow.Handle, EM_LINELENGTH, SendMessage(DosWindow.Handle,
EM_LINEINDEX, Result - 1, 0), 0) = 0 then Dec(Result);
end;
end;

function TDosBox.Get(Index: Integer): string;
var
Text: array[0..4095] of Char;
begin
Word((@Text)^) := SizeOf(Text);
SetString(Result, Text, SendMessage(DosWindow.Handle, EM_GETLINE, Index,
Longint(@Text)));
end;

procedure TDosBox.Put(Index: Integer; const S: string);
var
SelStart: Integer;
DosString:string;
begin
if S<>DosWindow.FDescribe then
DosString:=DosWindow.FPath+DosWindow.FPrompt+S
else DosString:=S+#13#10+#13#10;
SelStart := SendMessage(DosWindow.Handle, EM_LINEINDEX, Index, 0);
if SelStart >= 0 then
begin
SendMessage(DosWindow.Handle, EM_SETSEL, SelStart, SelStart +
SendMessage(DosWindow.Handle, EM_LINELENGTH, SelStart, 0));
SendMessage(DosWindow.Handle, EM_REPLACESEL, 0, Longint(PChar(DosString)));
end;
end;

procedure TDosBox.Insert(Index: Integer; const S: string);
var
SelStart, LineLen: Integer;
Line: string;
DosString:string;
begin
if S<>DosWindow.FDescribe then
DosString:=DosWindow.FPath+DosWindow.FPrompt+S
else DosString:=S+#13#10+#13#10;
if Index >= 0 then
begin
SelStart := SendMessage(DosWindow.Handle, EM_LINEINDEX, Index, 0);
if SelStart >= 0 then Line := DosString else
begin
SelStart := SendMessage(DosWindow.Handle, EM_LINEINDEX, Index - 1, 0);
if SelStart < 0 then Exit;
LineLen := SendMessage(DosWindow.Handle, EM_LINELENGTH, SelStart, 0);
if LineLen = 0 then Exit;
Inc(SelStart, LineLen);
Line := #13#10 + DosString;
end;
SendMessage(DosWindow.Handle, EM_SETSEL, SelStart, SelStart);
SendMessage(DosWindow.Handle, EM_REPLACESEL, 0, Longint(PChar(Line)));
end;
end;

procedure TDosBox.Delete(Index: Integer);
const
Empty: PChar = '''';
var
SelStart, SelEnd: Integer;
begin
SelStart := SendMessage(DosWindow.Handle, EM_LINEINDEX, Index, 0);
if SelStart >= 0 then
begin
SelEnd := SendMessage(DosWindow.Handle, EM_LINEINDEX, Index + 1, 0);
if SelEnd < 0 then SelEnd := SelStart +
SendMessage(DosWindow.Handle, EM_LINELENGTH, SelStart, 0);
SendMessage(DosWindow.Handle, EM_SETSEL, SelStart, SelEnd);
SendMessage(DosWindow.Handle, EM_REPLACESEL, 0, Longint(Empty));
end;
end;

procedure TDosBox.Clear;
begin
DosWindow.Clear;
end;

procedure TDosBox.SetUpdateState(Updating: Boolean);
begin
if DosWindow.HandleAllocated then
begin
SendMessage(DosWindow.Handle, WM_SETREDRAW, Ord(not Updating), 0);
if not Updating then
begin
DosWindow.Perform(CM_SHOWINGCHANGED,0,0);
DosWindow.Refresh;
end;
end;
end;



function TDosBox.GetTextStr: string;
begin
Result := DosWindow.Text;
end;

procedure TDosBox.SetTextStr(const Value: string);
var
NewText: string;
begin
NewText := AdjustLineBreaks(Value);
if (Length(NewText) <> DosWindow.GetTextLen) or (NewText <> DosWindow.Text) then
begin
if SendMessage(DosWindow.Handle, WM_SETTEXT, 0, Longint(NewText)) = 0 then
exit;
DosWindow.Perform(CM_TEXTCHANGED, 0, 0);
end;
end;

constructor TDosWindow.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Width := 185;
Height := 89;
FDescribe:=''Microsoft Windows Command Box.'';
FPath := GetCurrentDir;
FPrompt := ''>'';
Color:=clBlack;
Font.Name:=''Fixedsys'';
Font.Size:=9;
Font.Color:=$C0C0C0;
AutoSize := False;
FWordWrap := True;
FWantReturns := True;
FLines := TDosBox.Create;
TDosBox(FLines).DosWindow := Self;
end;

destructor TDosWindow.Destroy;


begin
FLines.Free;
inherited Destroy;
end;

procedure TDosWindow.CreateParams(var Params: TCreateParams);
const
Alignments: array[Boolean, TAlignment] of DWORD =
((ES_LEFT, ES_RIGHT, ES_CENTER),(ES_RIGHT, ES_LEFT, ES_CENTER));
ScrollBar: array[TScrollStyle] of DWORD = (0, WS_HSCROLL, WS_VSCROLL,
WS_HSCROLL or WS_VSCROLL);
WordWraps: array[Boolean] of DWORD = (0, ES_AUTOHSCROLL);
begin
inherited CreateParams(Params);
with Params do
begin
Style := Style and not WordWraps[FWordWrap] or ES_MULTILINE or
Alignments[UseRightToLeftAlignment, FAlignment] or ScrollBar[FScrollBars];
end;
end;

procedure TDosWindow.CreateWindowHandle(const Params: TCreateParams);
begin
with Params do
begin
if SysLocale.FarEast and (Win32Platform <> VER_PLATFORM_WIN32_NT) and
((Style and ES_READONLY) <> 0) then
begin
WindowHandle := CreateWindowEx(ExStyle, WinClassName, '''',
Style and (not ES_READONLY),
X, Y, Width, Height, WndParent, 0, HInstance, Param);
if WindowHandle <> 0 then
SendMessage(WindowHandle, EM_SETREADONLY, Ord(True), 0);
end
else
WindowHandle := CreateWindowEx(ExStyle, WinClassName, '''', Style,
X, Y, Width, Height, WndParent, 0, HInstance, Param);
SendMessage(WindowHandle, WM_SETTEXT, 0, Longint(Caption));
end;
FLines.Clear;
FLines.Add(FDescribe);
Flines.Add('''');
end;

function TDosWindow.GetCaretPos: TPoint;
begin
Result.X := LongRec(SendMessage(Handle, EM_GETSEL, 0, 0)).Hi;
Result.Y := SendMessage(Handle, EM_LINEFROMCHAR, Result.X, 0);
Result.X := Result.X - SendMessage(Handle, EM_LINEINDEX, -1, 0);
end;

procedure TDosWindow.SetCaretPos(const Value: TPoint);
var
CharIdx: Integer;
begin
CharIdx := SendMessage(Handle, EM_LINEINDEX, Value.y, 0) + Value.x;
SendMessage(Handle, EM_SETSEL, CharIdx, CharIdx);
end;

function TDosWindow.GetControlsAlignment: TAlignment;


begin
Result := FAlignment;
end;

procedure TDosWindow.Loaded;
begin
inherited Loaded;
Modified := False;
end;

procedure TDosWindow.SetAlignment(Value: TAlignment);
begin
if FAlignment <> Value then
begin
FAlignment := Value;
RecreateWnd;
end;
end;

procedure TDosWindow.SetLines(Value: TStrings);
begin
FLines.Assign(Value);
end;

procedure TDosWindow.SetScrollBars(Value: TScrollStyle);
begin
if FScrollBars <> Value then
begin
FScrollBars := Value;
RecreateWnd;
end;
end;

procedure TDosWindow.SetWordWrap(Value: Boolean);
begin
if Value <> FWordWrap then
begin
FWordWrap := Value;
RecreateWnd;
end;
end;

procedure TDosWindow.WMGetDlgCode(var Message: TWMGetDlgCode);
begin
inherited;
if FWantTabs then Message.Result := Message.Result or DLGC_WANTTAB
else Message.Result := Message.Result and not DLGC_WANTTAB;
if not FWantReturns then
Message.Result := Message.Result and not DLGC_WANTALLKEYS;
end;

procedure TDosWindow.WMNCDestroy(var Message: TWMNCDestroy);
begin
inherited;
end;

procedure TDosWindow.KeyPress(var Key: Char);
var
n,Start:integer;
begin
inherited KeyPress(Key);
if (Key = Char(VK_RETURN)) then
begin
n:=FLines.Count-1;
if Assigned(FCommand) then
FCommand(Self,Copy(FLines[n],Length(FPath+FPrompt),Length(FLines[n])));
Key:=#0;
FLines.Add('''');
exit;
end
else
begin
Start := GetCaretPos.X;
if Start end;
end;

procedure TDosWindow.SetPath(const Value: string);
begin
FPath := Value;
end;

procedure TDosWindow.SetPrompt(const Value: string);
begin
FPrompt := Value;
end;


// 测试:
procedure TForm1.FormCreate(Sender: TObject);
begin
DosBox:=TDosWindow.Create(Self);
DosBox.Parent:=Self;
DosBox.Align:=alClient;
end;
end.

12楼: 多谢各位朋友。 如财务记账软件哪个好