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.

Scale Problem

Post Reply
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Scale Problem

Post by salvadordf »

Please, use a different host for the images. I can't see them.

Add some minimal example with code to see if I can reproduce this issue somehow. I don't have a windows tablet and I can't test any demo in that platform.
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Scale Problem

Post by salvadordf »

If that tablet has a high DPI screen then add this before the GlobalCEFApp.StartMainProcess call in the DPR file.

Code: Select all

GlobalCEFApp.EnableHighDPISupport := True;
The TRect parameter in TFMXChromium.CreateBrowser needs to have the dimensions of the TFMXWindowParent.
In your case, you would have to do this :

Code: Select all

  TempClientRect := aWindow.ClientRect;
  BrowserRect.Left   := round(TempClientRect.Left);
  BrowserRect.Top    := round(TempClientRect.Top);
  BrowserRect.Right  := round(TempClientRect.Right);
  BrowserRect.Bottom := round(TempClientRect.Bottom);
      
  TempHandle := WindowHandleToPlatform(aWindow.Handle).Wnd;  
  FBrowser.DefaultUrl := FUrl;
  if FBrowser.CreateBrowser(TempHandle, BrowserRect) then
   ....      
If you need a smaller browser, resize TFMXWindowParent.
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Scale Problem

Post by salvadordf »

I just edited the previous post.

Notice that I added FBrowser.DefaultURL before the FBrowser.CreateBrowser to load the first URL.

FBrowser.CreateBrowser is asynchronous and you have to wait until the FBrowser.OnAfterCreated event is triggered before using the browser.
FBrowser.OnAfterCreated is executed in a different thread and the SimpleFMXBrowser demo sends a message to the main form to do some final initialization tasks in the main thread.
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Scale Problem

Post by salvadordf »

Use the TFMXChromium.OnAfterCreated event and copy all related code from SimpleFMXBrowser to your application.
Send a CEF_AFTERCREATED message inside that event and modify your custom application service to call the DoBrowserCreated procedure in your main form.
Then call aWindow.UpdateSize inside DoBrowserCreated.

In theory, every time you call aWindow.SetBounds() the TFMXWindowParent.Resize is called and it should call TFMXWindowParent.UpdateSize; but I see that I added {$IFDEF MSWINDOWS} before TFMXWindowParent.UpdateSize.

Could you check if UpdateSize is executed when you resize TFMXWindowParent in your tablet ?
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Scale Problem

Post by salvadordf »

I tested the SimpleFMXBrowser demo in Windows 7 and Windows 10 again and it worked correctly when I resized the form.

Please, put a breakpoint in the DeferWindowPos call in the uFMXWindowParent.pas file while you run your application or the demo in the tablet.
It looks like TFMXWindowParent.UpdateSize is never called for some reason.

Add aWindow.UpdateSize inside TSimpleFMXBrowserFrm.DoBrowserCreated.
Post Reply