Advertisement
Guest User

Untitled

a guest
May 6th, 2021
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. function WindowSnap(windowHandle: HWND; bmp: TBitmap): boolean;
  2. var
  3. r: TRect;
  4. begin
  5. GetWindowRect(windowHandle, r) ;
  6. bmp.Width := r.Right - r.Left;
  7. bmp.Height := r.Bottom - r.Top;
  8. bmp.Canvas.Lock;
  9. try
  10. result := PrintWindow(windowHandle, bmp.Canvas.Handle, 0) ;
  11. finally
  12. bmp.Canvas.Unlock;
  13. end;
  14. end; (*WindowSnap*)
  15.  
  16. procedure TForm1.Button1Click(Sender: TObject);
  17. var
  18. Handle : Hwnd;
  19. bmp: tbitmap;
  20.  
  21. begin
  22. handle := FindWindow('IEFrame', nil);
  23. handle := FindWindowEx(handle, 0, 'Frame Tab', nil);
  24. handle := FindWindowEx(handle, 0, 'TabWindowClass', nil);
  25. handle := FindWindowEx(handle, 0, 'Shell DocObject View', nil);
  26. handle := FindWindowEx(handle, 0, 'Internet Explorer_Server', nil);
  27. if handle > 0 then
  28. begin
  29. bmp := tbitmap.Create;
  30. try
  31. WindowSnap(handle, bmp);
  32. bmp.SaveToFile('c:\temp\test.bmp');
  33. finally
  34. bmp.Free;
  35. end;
  36. end;
  37. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement