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.

Toggle Device Bar

Post Reply
thefunkyjoint
Posts: 458
Joined: Thu Aug 10, 2017 12:40 pm

Toggle Device Bar

Post by thefunkyjoint »

Is it possible to simulate Devtools 'Toggle Device Toolbar', using CEF4Delphi ? If so, how ?

I mean that button on Chrome Devtools where you can simulate other devices, like phones.
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Toggle Device Bar

Post by salvadordf »

thefunkyjoint
Posts: 458
Joined: Thu Aug 10, 2017 12:40 pm

Re: Toggle Device Bar

Post by thefunkyjoint »

:|
thefunkyjoint
Posts: 458
Joined: Thu Aug 10, 2017 12:40 pm

Re: Toggle Device Bar

Post by thefunkyjoint »

Besides change the user agent, what else this option does ? It seems there are more things involved that simply changing the user agent, as i could not replicate 100% this feature by only changing the user agent... :?:
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Toggle Device Bar

Post by salvadordf »

I'm not an expert but I guess the browser resolution and browser scale should be different too.

I haven't tried but --device-scale-factor seems to be used to force the renderer to use a fixed scale factor.

If that factor is calculated using the same formula as the scale factor in OSR mode then you have to do this : new_scale_factor = custom_DPI / 96
thefunkyjoint
Posts: 458
Joined: Thu Aug 10, 2017 12:40 pm

Re: Toggle Device Bar

Post by thefunkyjoint »

Thank you, will try this !
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Toggle Device Bar

Post by salvadordf »

Instead of a normal browser that would get the real screen resolution in your PC, try a browser in OSR mode.

Set the fake screen resolution in the TChromium.OnGetScreenInfo event and use the same size in the TChromium.OnGetViewRect event.
You can set the fake scale in those events too.

You will need to modify the TChromium.OnGetScreenPoint event too to use the fake resolution and scale.

Other events would have to be modified too. For example, you would need to convert the mouse coordinates to the new fake scale.
Post Reply