Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

OSR Windows and Browser size

Post Reply
dilfich
Posts: 331
Joined: Thu Nov 30, 2017 1:17 am

OSR Windows and Browser size

Post by dilfich »

Hi!
How can I specify the size of the browser and window? :?:
Test - https://browsersize.com/
OSR
Current:
Browser window size: 0 x 366
Screen size: 0 x 0
Real browser
Current:
Browser window size: 1488 x 751
Screen size: 1920 x 1080
User avatar
salvadordf
Posts: 4082
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: OSR Windows and Browser size

Post by salvadordf »

Hi,

If I remember correctly, you need to use the TChromium.OnGetViewRect and TChromium.OnGetScreenInfo events.

I would use all the events in the SimpleOSRBrowser demo and then take out what you don't really need.
User avatar
salvadordf
Posts: 4082
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: OSR Windows and Browser size

Post by salvadordf »

Demo
Current:
Browser window size: 366 x 366
Screen size: 366 x 366
Screen size not?
I tested this in the official CEF3 application (cefclient) and it has the same behavior when it uses the OSR mode.
The real screen size is ignored and it shows the window size instead... or almost the same if you resize the form violently.
dilfich
Posts: 331
Joined: Thu Nov 30, 2017 1:17 am

Re: OSR Windows and Browser size

Post by dilfich »

OSR is good.. And it is possible as that on visual to set the size of a window and the browser?
User avatar
salvadordf
Posts: 4082
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: OSR Windows and Browser size

Post by salvadordf »

If you ignore the TChromium.OnPaint event or you replace TBufferPanel then you can set any size in the TChromium.OnGetViewRect and TChromium.OnGetScreenInfo events.

The window and browser sizes are not important if you give a custom size in the TChromium.OnGetViewRect and TChromium.OnGetScreenInfo events.
dilfich
Posts: 331
Joined: Thu Nov 30, 2017 1:17 am

Re: OSR Windows and Browser size

Post by dilfich »

salvadordf wrote: Sun Jul 08, 2018 8:48 pm If you ignore the TChromium.OnPaint event or you replace TBufferPanel then you can set any size in the TChromium.OnGetViewRect and TChromium.OnGetScreenInfo events.

The window and browser sizes are not important if you give a custom size in the TChromium.OnGetViewRect and TChromium.OnGetScreenInfo events.

Code: Select all

procedure TFormGL.Chromium1GetScreenInfo(Sender: TObject; const browser: ICefBrowser; var screenInfo: TCefScreenInfo; out Result: Boolean);
var
  TempRect : TCEFRect;
begin
  if (GlobalCEFApp <> nil) then
    begin
      TempRect.x      := 0;
      TempRect.y      := 0;
      TempRect.width  := 1080;
      TempRect.height := 1680;

      screenInfo.device_scale_factor := GlobalCEFApp.DeviceScaleFactor;
      screenInfo.depth               := 0;
      screenInfo.depth_per_component := 0;
      screenInfo.is_monochrome       := Ord(False);
      screenInfo.rect                := TempRect;
      screenInfo.available_rect      := TempRect;

      Result := True;
    end
   else
    Result := False;
end;

procedure TFormGL.Chromium1GetViewRect(Sender: TObject; const browser: ICefBrowser; var rect: TCefRect; out Result: Boolean);
begin
  if (GlobalCEFApp <> nil) then
    begin
      rect.x      := 0;
      rect.y      := 0;
      rect.width  := 1000;
      rect.height := 600;
      Result      := True;
    end
   else
    Result := False;
end;
What's wrong with not working?
browsersize.com
Result
Browser window size: 531 x 409
Screen size: 1920 x 1080
User avatar
salvadordf
Posts: 4082
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: OSR Windows and Browser size

Post by salvadordf »

Those events are used in OSR mode only.
Remember that you need to convert the logical and device units with DeviceToLogical in case you have a high DPI monitor.

Use the SimpleOSRBrowser demo as a template for your application.
Post Reply