AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Cpp > Pas

Ein Thema von Nils_13 · begonnen am 28. Mär 2008 · letzter Beitrag vom 28. Mär 2008
 
Benutzerbild von turboPASCAL
turboPASCAL

Registriert seit: 8. Mai 2005
Ort: Sondershausen
4.274 Beiträge
 
Delphi 6 Personal
 
#8

Re: Cpp > Pas

  Alt 28. Mär 2008, 18:44
Zitat von Nils_13:
Code:
Sleep(5000); // Nötig ????
Delphi-Quellcode:
program STDINOUT_DMO;

uses
  Windows,
  Messages,
  SysUtils;

procedure Main;
var
  hStdout, hNewScreenBuffer: THANDLE;
  srctReadRect: TSMALLRECT;
  srctWriteRect: TSMALLRECT;
  chiBuffer: array [0..160] of TCHARINFO; // [2]*[80];
  coordBufSize: TCOORD;
  coordBufCoord: TCOORD;
  fSuccess: BOOL;
begin
    // Get a handle to the STDOUT screen buffer to copy from and
    // create a new screen buffer to copy to.

    hStdout := GetStdHandle(STD_OUTPUT_HANDLE);
    hNewScreenBuffer := CreateConsoleScreenBuffer(
       GENERIC_READ or // read/write access
       GENERIC_WRITE,
       0, // not shared
       nil, // default security attributes
       CONSOLE_TEXTMODE_BUFFER, // must be TEXTMODE
       nil); // reserved; must be NULL

    if (hStdout = INVALID_HANDLE_VALUE) or
       (hNewScreenBuffer = INVALID_HANDLE_VALUE) then
    begin
      WriteLn(format('CreateConsoleScreenBuffer (%d)', [GetLastError]));
      exit;
    end;

    // Make the new screen buffer the active screen buffer.

    if not SetConsoleActiveScreenBuffer(hNewScreenBuffer) then
    begin
      WriteLn(format('SetConsoleActiveScreenBuffer (%d)', [GetLastError]));
      exit;
    end;

    // Set the source rectangle.

    srctReadRect.Top := 0; // top left: row 0, col 0
    srctReadRect.Left := 0;
    srctReadRect.Bottom := 1; // bot. right: row 1, col 79
    srctReadRect.Right := 79;

    // The temporary buffer size is 2 rows x 80 columns.

    coordBufSize.Y := 2;
    coordBufSize.X := 80;

    // The top left destination cell of the temporary buffer is
    // row 0, col 0.

    coordBufCoord.X := 0;
    coordBufCoord.Y := 0;

    // Copy the block from the screen buffer to the temp. buffer.

    fSuccess := ReadConsoleOutput(
       hStdout, // screen buffer to read from
       @chiBuffer[0], // buffer to copy into
       coordBufSize, // col-row size of chiBuffer
       coordBufCoord, // top left dest. cell in chiBuffer
       srctReadRect); // screen buffer source rectangle
    if not fSuccess then
    begin
      WriteLn(format('SetConsoleActiveScreenBuffer (%d)', [GetLastError]));
      exit;
    end;

    // Set the destination rectangle.

    srctWriteRect.Top := 10; // top lt: row 10, col 0
    srctWriteRect.Left := 0;
    srctWriteRect.Bottom := 11; // bot. rt: row 11, col 79
    srctWriteRect.Right := 79;

    // Copy from the temporary buffer to the new screen buffer.

    fSuccess := WriteConsoleOutput(
        hNewScreenBuffer, // screen buffer to write to
        @chiBuffer[0], // buffer to copy from
        coordBufSize, // col-row size of chiBuffer
        coordBufCoord, // top left src cell in chiBuffer
        srctWriteRect); // dest. screen buffer rectangle
    if not fSuccess then
    begin
      WriteLn(format('WriteConsoleOutput (%d)', [GetLastError]));
      exit;
    end;
    Sleep(5000); // <--<<

    // Restore the original active screen buffer.

    if not SetConsoleActiveScreenBuffer(hStdout) then
    begin
      WriteLn(format('SetConsoleActiveScreenBuffer (%d)', [GetLastError]));
      exit;
    end;
end;

BEGIN
  AllocConsole;
  Main;
  FreeConsole;
END.
Für das Demo ja. Es dient zur visualisierung des Demos
Matti
Meine Software-Projekte - Homepage - Grüße vom Rüsselmops -Mops Mopser
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 09:49 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz