[fpc-pascal]Reading the screen under win32

Jeff Wormsley daworm at cdc.net
Mon Oct 2 15:30:31 CEST 2000


Hello Martin,

Sorry, I had a bit of Programmer's One problem there...

Replace the push and pull as shown below, and add this at the very beginning of your program

 AllocConsole; {this may not be needed ???}
 hOut := GetStdHandle(STD_OUTPUT_HANDLE); {This is DEFINITATELY needed}

Sorry about the mixup.

Jeff.


{ Win_Push ------------------------------------------------------------------ }
{ This code grabs a region of the screen and saves it in a buffer }
{ Screen region is defined by the coordinates in Win_MinX, Win_MinY, }
{ Win_MaxX, Win_MaxY. }

Procedure Win_Push;

Var
 Y                : Byte;
Begin
 DestRect.Left   := 0;
 DestRect.Top    := 0;
 DestRect.Right  := Pred(Win_Width);
 DestRect.Bottom := Pred(Win_Height);
 BuffSize.X      := Win_Width;
 BuffSize.Y      := Win_Height;
 BuffCoord.X     := 0;
 BuffCoord.Y     := 0;
 ReadConsoleOutput(hOut, @Win_Save, BuffSize, BuffCoord, DestRect);
End;

{ Win_Pull ------------------------------------------------------------------ }
{ This code puts the buffer back onto the screen }
{ Screen region is defined by the coordinates in Win_MinX, Win_MinY, }
{ Win_MaxX, Win_MaxY. }

Procedure Win_Pull;

Var
 Y                : Byte;

Begin
 DestRect.Left   := 0;
 DestRect.Top    := 0;
 DestRect.Right  := Pred(Win_Width);
 DestRect.Bottom := Pred(Win_Height);
 BuffSize.X      := Win_Width;
 BuffSize.Y      := Win_Height;
 BuffCoord.X     := 0;
 BuffCoord.Y     := 0;
 WriteConsoleOutput(hOut, @Win_Save, BuffSize, BuffCoord, DestRect);
End;






More information about the fpc-pascal mailing list