Getting blank screenshots in WebBrowser under Mac


Below is the piece of code on Firemonkey to capture WebBrowser canvas. It perfectly works in Windows, however in Mac OS I’m getting a blank screenshot.

TBitmap* TForm1::getScreenshotWebBrowser() {
TBitmap *BitmapBuffer;
TBitmap *bmp_Scrhot = new TBitmap;

TRectF SourceRect(0, 0, WebBrowser1->Width, WebBrowser1->Height);
TRect Rect_bmp(0, 0, WebBrowser1->Width, WebBrowser1->Height);

BitmapBuffer = new TBitmap(SourceRect.Width(), SourceRect.Height());
try {

if (BitmapBuffer->Canvas->BeginScene())
try {

WebBrowser1->PaintTo(BitmapBuffer->Canvas, SourceRect);
__finally {

BitmapBuffer->SaveToFile(GetHomePath() +”/screenshot1.png”);
bmp_Scrhot->Width = Rect_bmp.Width();
bmp_Scrhot->Height = Rect_bmp.Height();
bmp_Scrhot->CopyFromBitmap(BitmapBuffer, Rect_bmp, 0, 0);
bmp_Scrhot->SaveToFile(GetHomePath() +”/screenshot2.png”);
__finally {
delete BitmapBuffer;
return bmp_Scrhot;

P.S. Experimenting I found out that If I capture the whole form containing WebBrowser canvas, then the screenshot is not entirely blank. It has form controls like buttons, separators, etc. But the browser canvas among them is still blank.

Comments are closed.