Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 팁&트릭
Delphi Programming Tip&Tricks
[83] [delphi] 화면을 캠춰하자
박정모 [] 5956 읽음    2001-12-08 00:29

Bitmap에다가 화면을 캡쳐하는 함수 입니당... ^^

procedure TForm1.ScreenShot(x : integer; y : integer; Width : integer; Height : integer; bm : TBitMap);
var
  dc: HDC;
  lpPal : PLOGPALETTE;
begin
  if ((Width = 0) OR (Height = 0)) then
     exit;

  bm.Width := Width;
  bm.Height := Height;

{get the screen dc}
  dc := GetDc(0);
  if (dc = 0) then
     exit;

{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;


+ -

관련 글 리스트
83 [delphi] 화면을 캠춰하자 박정모 5956 2001/12/08
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.