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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

Setting screen and windows dimentions in old CEF

Post Reply
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Setting screen and windows dimentions in old CEF

Post by andreykrasnodar »

There are OnGetViewRect and OnGetScreenInfo events in newer versions, but there is only 1st event in my version.
Using Demo code, I can set equal screen resolution and window's dimensions.
How can I set different resolution and dimension?
Thanks.
User avatar
salvadordf
Posts: 4575
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Setting screen and windows dimentions in old CEF

Post by salvadordf »

Using TChromium.OnGetViewRect you can configure CEF to use a surface with different dimmensions than your form to draw the web contents.

Read this page for more information about those events :
https://magpcss.org/ceforum/apidocs3/pr ... ndler.html
dilfich
Posts: 368
Joined: Thu Nov 30, 2017 1:17 am

Re: Setting screen and windows dimentions in old CEF

Post by dilfich »

salvadordf wrote: Wed Aug 12, 2020 7:10 am Using TChromium.OnGetViewRect you can configure CEF to use a surface with different dimmensions than your form to draw the web contents.
This only works in the OSR version, doesn't it?)

For the normal version only by script(
viewtopic.php?f=8&t=1382&p=5744#p5744
User avatar
salvadordf
Posts: 4575
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Setting screen and windows dimentions in old CEF

Post by salvadordf »

That's correct. All those events only work in OSR mode.
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: Setting screen and windows dimentions in old CEF

Post by andreykrasnodar »

You are right, I am using OSR component. And want to set the size of screen and window.
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: Setting screen and windows dimentions in old CEF

Post by andreykrasnodar »

Please help me
User avatar
salvadordf
Posts: 4575
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Setting screen and windows dimentions in old CEF

Post by salvadordf »

If the CEF version you use doesn't have the OnGetScreenInfo event then you can't set a custom screen resolution.

You need to use a newer CEF version.
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: Setting screen and windows dimentions in old CEF

Post by andreykrasnodar »

dilfich wrote: Wed Aug 12, 2020 8:30 am For the normal version only by script(
viewtopic.php?f=8&t=1382&p=5744#p5744
It was my know-how
dilfich
Posts: 368
Joined: Thu Nov 30, 2017 1:17 am

Re: Setting screen and windows dimentions in old CEF

Post by dilfich »

Code: Select all

// Screen resolution
procedure GetScreenInfo(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  := ScreenWidth[FCefID];
      TempRect.height := ScreenHeight[FCefID];

      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;

// Browser's resolution
procedure GetViewRect(Sender : TObject;   const browser : ICefBrowser;  var   rect    : TCefRect);
begin
  if (GlobalCEFApp <> nil) then
    begin
      rect.x      := 0;
      rect.y      := 0;
      rect.width  := BrowsrWidth[FCefID];
      rect.height := BrowsrHeight[FCefID];
    end;
end;
After installation, use Chromium.WasResized;
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: Setting screen and windows dimentions in old CEF

Post by andreykrasnodar »

Thanks, it works.
Post Reply