type logPal =
record
lpal : TLogPalette;
dummy :
array[1..255]
of TPaletteEntry;
end;
procedure TForm1.takeScreenShot;
var
sysPal : logPal;
aImage: TImage;
// Unit ExtCtrls!
hPal: HPalette;
aHDC: HDC;
aCanvas: TCanvas;
aRect: TRect;
// Source Rect
Datum:
String;
// Dateiname = Datum
begin
Datum:= DateToStr(Now) + '
.bmp';
aHDC := GetWindowDC(0);
sysPal.lPal.palVersion:=$300;
sysPal.lPal.palNumEntries:=256;
GetSystemPaletteEntries(aHDC,0,256,SysPal.lpal.PalpalEntry);
hPal:=CreatePalette(sysPal.lpal);
aCanvas := TCanvas.Create;
aCanvas.Handle := aHDC;
aRect := Rect(0,0,Screen.Width,Screen.Height);
aImage:=TImage.Create(Self);
with aImage
do
begin
Height:= LenRect;
Width:= LenRect;
Canvas.CopyRect(aRect,aCanvas,aRect);
ReleaseDC(GetDeskTopWindow,aHDC);
Picture.Bitmap.Palette:=hPal
end;
aImage.Picture.SavetoFile(Datum);
aImage.Free;
ReleaseDC(GetDeskTopWindow, aHDC);
ReleaseDC(aHDC, aCanvas.Handle);
end;