سلام
چطوری میشه از صفحه desktop (یا یک پنجره خاص) عکس گرفت. نه با کلید print sceern با دستور نوشتن توی دلفی
با تشکر
Printable View
سلام
چطوری میشه از صفحه desktop (یا یک پنجره خاص) عکس گرفت. نه با کلید print sceern با دستور نوشتن توی دلفی
با تشکر
GetDesktopWindow
سلام
اگه توضیحاتشم میخوای از Windows SDK Help بخون
بای
مرسی
ولی این دستور هندل به من میده. این رو چطوری میتونم به عکس تبدیل کنم؟
procedure TForm1.ScreenShot(x: integer; y: integer; Width: integer; Height: integer; bm: TBitmap);
var
dc: HDC;
lpPal: PLOGPALETTE;
begin
{test width and height}
if ((Width = 0) or (Height = 0)) then
begin
exit;
end;
bm.Width := Width;
bm.Height := Height;
{get the screen dc}
dc := GetDc(0);
if (dc = 0) then
begin
exit;
end;
{do we have a palette device?}
if (GetDeviceCaps(dc, RASTERCAPS) and RC_PALETTE = RC_PALETTE) then
begin
{allocate memory for a logical palette}
GetMem(lpPal, sizeof(TLOGPALETTE) + (255 * sizeof(TPALETTEENTRY)));
{zero it out to be neat}
FillChar(lpPal^, sizeof(TLOGPALETTE) + (255 * sizeof(TPALETTEENTRY)), #0);
{fill in the palette version}
lpPal^.palVersion := $300;
{grab the system palette entries}
lpPal^.palNumEntries := GetSystemPaletteEntries(dc, 0, 256, lpPal^.palPalEntry);
if (lpPal^.PalNumEntries <> 0) then
begin
{create the palette}
bm.Palette := CreatePalette(lpPal^);
end;
FreeMem(lpPal, sizeof(TLOGPALETTE) + (255 * sizeof(TPALETTEENTRY)));
end;
{copy from the screen to the bitmap}
BitBlt(bm.Canvas.Handle, 0, 0, Width, Height, Dc, x, y, SRCCOPY);
{release the screen dc}
ReleaseDc(0, dc);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
bm : TBitmap;
begin
bm := TBitmap.Create;
ScreenShot(0, 0, Screen.Width, Screen.Height, bm);
bm.SaveToFile('c:\Test.bmp');
Image1.Picture.Bitmap:=bm;
bm.free;
end;
مرسی :thnx: :thnx: :thnx: :thnx:
program GetScrnJpg;
uses
Windows, Graphics, jpeg;
{$R *.RES}
var
B: TBitmap;
S: string;
begin
B := TBitmap.Create;
B.Width := GetSystemMetrics(SM_CXSCREEN); {Screen.Width}
B.Height := GetSystemMetrics(SM_CYSCREEN); {Screen.Height}
BitBlt(B.Canvas.handle, 0, 0, B.Width, B.Height, GetDc(0), 0, 0, SRCCOPY);
if ParamStr(1) <> '' then
S := ParamStr(1) + '.jpg'
else
S := 'Screen.jpg';
with TJPEGImage.Create do
begin
Assign(B);
CompressionQuality := 75;
SaveToFile(S);
free;
end;
B.Free;
end.