[fpc-pascal]CRT unit (was: Beep in Windows)

Jeff Wormsley daworm9 at home.com
Thu Aug 2 21:26:35 CEST 2001


On 08/02/2001 at 7:33 PM Andreas K. Foerster wrote:

>- Anything is done by calling API codes. That's why it is so slow! 
>As far as I understand it, Windows uses a buffer that's built up equal to
>the screenbuffer as it is directly used under DOS, so that you can write
>directly to that buffer as in Dos. Just with the difference, that you have

>to fetch the starting point and size from the API.

If you have Delphi or the Win32.hlp file, take a look at the following:

TCharInfo - This holds the equivalent of the old screen buffer's
combination of a character/attribute pair.  I found a bug when working with
this, probably due to alignment issues, such that I needed to define a
dummy version of this structure called TFixedCharInfo, like so:

 TFixCharInfo   = Record
                   AsciiChar  : Char;
                   Dummy      : Byte;
                   Attributes : Word;
                  End;

I used this to define these structures:

VirtualScreen  : Array[0..24, 0..79] of TFixCharInfo; // Screen
Buff           : Array[0..79] of TFixCharInfo;		// Line

TConsoleCursorInfo, GetConsoleCursorInfo, SetConsoleCursorInfo - You can
use these to turn on and off the cursor

ReadConsoleOutputAttribute, WriteConsoleOutputAttribute,
WriteConsoleOutputCharacter, WriteConsoleOutput, ReadConsoleOutput - Uses
these in place of the direct memory reads and writes to the screen buffer.

GetStdHandle - Used to get the handle to the screen

Using these I converted a BP7 windowing unit to Win32 Console, with little
loss of speed.

Jeff.







More information about the fpc-pascal mailing list