In WinForms my Panel size is 560x371. Some pages fit into this size without adding horizontal scroll bar but some pages do not fit and horizontal scroll bar adds. How to make all pages fit (without exception) and without adding horizontal scroll bar?
For example: google.com fit into Panel without adding horizontal scroll bar, but yahoo.com does not fit and adds horizontal scroll bar
Here is my code
public ChromiumWebBrowser chrome;
public CefSettings settings;
string main_site = "https://yahoo.com";
public Form1()
{
InitializeComponent();
InitBrowser();
}
public void InitBrowser()
{
settings = new CefSettings()
{
LogFile = "Debug.log", //You can customise this path
LogSeverity = LogSeverity.Default // You can change the log level
};
string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
settings.CachePath = path;
Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);
chrome = new ChromiumWebBrowser(main_site);
this.panel1.Controls.Add(chrome);
chrome.MenuHandler = new DevToolsMenuHandler();
chrome.AddressChanged += Chrome_AddressChanged;
chrome.LifeSpanHandler = new MyCustomLifeSpanHandler();
}
My new addintion (26.04.2022)
I also added code below
private async void OnBrowserFrameLoadEnd(object sender, FrameLoadEndEventArgs args)
{
var client = chrome.GetDevToolsClient();
await client.Emulation.SetDeviceMetricsOverrideAsync(500, 1000, 0, false);
}
chrome.FrameLoadEnd += OnBrowserFrameLoadEnd;
You can see in the screenshot below, the code above trims the page. But i need to fit all content into Panel without loss of content