P
penwater191
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure ScreenCap(LeftPos,TopPos,RightPos,BottomPos:integer);
begin
bmpstream := Tmemorystream.Create;
RectWidth:=RightPos-LeftPos;
RectHeight:=BottomPos-TopPos;
SourceDC:=CreateDC('DISPLAY','','',nil);
DestDC:=CreateCompatibleDC(SourceDC);
Bhandle:=CreateCompatibleBitmap(SourceDC,RectWidth,RectHeight);
SelectObject(DestDC,Bhandle);
BitBlt(DestDC,0,0,RectWidth,RectHeight,SourceDC,LeftPos,TopPos,SRCCOPY);
Bitmap:=TBitmap.Create;
Bitmap.Handle:=BHandle;
BitMap.SaveToStream(BmpStream);
BmpStream.Position:=0;
LeftSize:=BmpStream.Size;
Bitmap.Free;
DeleteDC(DestDC);
ReleaseDC(Bhandle,SourceDC);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
w:=screen.Width;
h:=screen.Height;
form1.AutoSize:=true;
screencap(0,0,w,h);
image1.AutoSize:=true;
image1.Picture.Bitmap.LoadFromStream(bmpstream);
bmpstream.Free;
end;
begin
bmpstream := Tmemorystream.Create;
RectWidth:=RightPos-LeftPos;
RectHeight:=BottomPos-TopPos;
SourceDC:=CreateDC('DISPLAY','','',nil);
DestDC:=CreateCompatibleDC(SourceDC);
Bhandle:=CreateCompatibleBitmap(SourceDC,RectWidth,RectHeight);
SelectObject(DestDC,Bhandle);
BitBlt(DestDC,0,0,RectWidth,RectHeight,SourceDC,LeftPos,TopPos,SRCCOPY);
Bitmap:=TBitmap.Create;
Bitmap.Handle:=BHandle;
BitMap.SaveToStream(BmpStream);
BmpStream.Position:=0;
LeftSize:=BmpStream.Size;
Bitmap.Free;
DeleteDC(DestDC);
ReleaseDC(Bhandle,SourceDC);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
w:=screen.Width;
h:=screen.Height;
form1.AutoSize:=true;
screencap(0,0,w,h);
image1.AutoSize:=true;
image1.Picture.Bitmap.LoadFromStream(bmpstream);
bmpstream.Free;
end;