Einzelnen Beitrag anzeigen

PeterKiers

Registriert seit: 15. Mär 2005
Ort: Wuppertal
42 Beiträge
 
#1

Wie kann ich die Memo.Lines auf ein Cavas zeichnen?

  Alt 13. Jan 2006, 12:49
Hi,

Wie kann ich die Memo.Lines auf ein Cavas zeichnen?


Code:

const
    CR = #13;
    LF = #10;
var
    Start, Stop : Integer;
begin
    if Memo.Lines.Count = 0 then
        Memo.Lines.Add('');

    Start := 1;
    Stop := Pos(CR, Msg);
    if Stop = 0 then
        Stop := Length(Msg) + 1;
    while Start <= Length(Msg) do begin
        Memo.Lines.Strings[Memo.Lines.Count - 1] :=
            Memo.Lines.Strings[Memo.Lines.Count - 1] +
            Copy(Msg, Start, Stop - Start);
        if Msg[Stop] = CR then begin
            Memo.Lines.Add('');
            SendMessage(Memo.Handle, WM_KEYDOWN, VK_UP, 1);
        end;
        Start := Stop + 1;
        if Start > Length(Msg) then
            Break;
        if Msg[Start] = LF then
           Start := Start + 1;
        Stop := Start;
        while (Msg[Stop] <> CR) and (Stop <= Length(Msg)) do
            Stop := Stop + 1;
    end;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnDemoForm.ConnectButtonClick(Sender: TObject);
begin
    TnCnx.Host     := HostEdit.Text;
    TnCnx.Port     := PortEdit.Text;
    TnCnx.TermType := 'VT100';
    TnCnx.LocalEcho := FALSE;
    TnCnx.Connect;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnDemoForm.DisconnectButtonClick(Sender: TObject);
begin
    TnCnx.Close;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnDemoForm.TnCnxSessionConnected(Sender: TTnCnx; Error: Word);
begin
    if Error <> 0 then begin
        DisplayMemo.Lines.Add('Unable to connect. Error #' + IntToStr(Error));
        Exit;
    end;

    DisplayMemo.Clear;
    InfoLabel.Caption       := 'Connected';
    DisplayMemo.Enabled     := TRUE;
    ConnectButton.Enabled   := FALSE;
    DisconnectButton.Enabled := TRUE;
    ActiveControl           := DisplayMemo;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnDemoForm.TnCnxSessionClosed(Sender: TTnCnx; Error: Word);
begin
    InfoLabel.Caption       := 'Disconnected';
    DisplayMemo.Enabled     := FALSE;
    ConnectButton.Enabled   := TRUE;
    DisconnectButton.Enabled := FALSE;
    ActiveControl           := ConnectButton;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnDemoForm.TnCnxDataAvailable(
    Sender: TTnCnx; Buffer : Pointer; Len: Integer);
begin
    MemoAddLines(DisplayMemo, StrPas(Buffer));
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnDemoForm.DisplayMemoKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
    Key := 0;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnDemoForm.DisplayMemoKeyPress(Sender: TObject; var Key: Char);
begin
    TnCnx.Send(@Key, 1);
    if Key = #13 then begin
        { Send a LF after CR key }
        Key := #10;
        TnCnx.Send(@Key, 1);
    end;
    Key := #0;
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure TTnDemoForm.SendButtonClick(Sender: TObject);
begin
    if TnCnx.State = wsConnected then
        TnCnx.SendStr(DataEdit.Text + #13#10)
    else
    DisplayMemo.Lines.Add('*** NOT CONNECTED ***');
end;


{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}

end.
Gruß

Peter Kiers
  Mit Zitat antworten Zitat