1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2025-09-30 21:28:55 +02:00

Added transparency test code to SimpleOSRBrowser in QT

This commit is contained in:
Salvador Díaz Fau
2025-09-21 17:15:22 +02:00
parent ed15f1cca3
commit 4a33371558
3 changed files with 45 additions and 11 deletions

View File

@@ -12,6 +12,11 @@ uses
{$IFDEF LCLQT6}qt6,{$ENDIF}
uCEFBufferPanel, uCEFChromium, uCEFInterfaces, uCEFTypes;
const
// Set this constant to True and load "file:///<path-to-CEF4Delphi>/bin/transparency.html" to test a
// transparent browser.
TRANSPARENT_BROWSER = True;
type
{ TMainForm }
@@ -219,6 +224,13 @@ begin
GlobalCEFApp.DisableZygote := True;
GlobalCEFApp.WindowlessRenderingEnabled := True;
GlobalCEFApp.OnContextInitialized := @GlobalCEFApp_OnContextInitialized;
// If you need transparency leave the GlobalCEFApp.BackgroundColor property
// with the default value or set the alpha channel to 0
if TRANSPARENT_BROWSER then
GlobalCEFApp.BackgroundColor := CefColorSetARGB($00, $00, $00, $00)
else
GlobalCEFApp.BackgroundColor := CefColorSetARGB($FF, $FF, $FF, $FF);
end;
function StartMainProcess: boolean;
@@ -614,8 +626,13 @@ begin
UpdatePanelOffset;
// opaque white background color
// If you need transparency leave the Chromium1.Options.BackgroundColor property
// with the default value or set the alpha channel to 0
if TRANSPARENT_BROWSER then
Chromium1.Options.BackgroundColor := CefColorSetARGB($00, $00, $00, $00)
else
Chromium1.Options.BackgroundColor := CefColorSetARGB($FF, $FF, $FF, $FF);
Chromium1.DefaultURL := UTF8Decode(AddressCb.Text);
Chromium1.CreateBrowser;

View File

@@ -12,6 +12,11 @@ uses
{$IFDEF LCLQT6}qt6,{$ENDIF}
uCEFBufferPanel, uCEFChromium, uCEFInterfaces, uCEFTypes;
const
// Set this constant to True and load "file:///<path-to-CEF4Delphi>/bin/transparency.html" to test a
// transparent browser.
TRANSPARENT_BROWSER = True;
type
{ TMainForm }
@@ -219,6 +224,13 @@ begin
GlobalCEFApp.SetCurrentDir := True;
GlobalCEFApp.DisableZygote := True;
GlobalCEFApp.OnContextInitialized := @GlobalCEFApp_OnContextInitialized;
// If you need transparency leave the GlobalCEFApp.BackgroundColor property
// with the default value or set the alpha channel to 0
if TRANSPARENT_BROWSER then
GlobalCEFApp.BackgroundColor := CefColorSetARGB($00, $00, $00, $00)
else
GlobalCEFApp.BackgroundColor := CefColorSetARGB($FF, $FF, $FF, $FF);
end;
function StartMainProcess: boolean;
@@ -614,8 +626,13 @@ begin
UpdatePanelOffset;
// opaque white background color
// If you need transparency leave the Chromium1.Options.BackgroundColor property
// with the default value or set the alpha channel to 0
if TRANSPARENT_BROWSER then
Chromium1.Options.BackgroundColor := CefColorSetARGB($00, $00, $00, $00)
else
Chromium1.Options.BackgroundColor := CefColorSetARGB($FF, $FF, $FF, $FF);
Chromium1.DefaultURL := UTF8Decode(AddressCb.Text);
Chromium1.CreateBrowser;

View File

@@ -2,7 +2,7 @@
"UpdateLazPackages" : [
{
"ForceNotify" : true,
"InternalVersion" : 791,
"InternalVersion" : 792,
"Name" : "cef4delphi_lazarus.lpk",
"Version" : "140.1.14"
}