Welcome Guest Search | Active Topics | Sign In | Register

WinForm NewWindowEvent PopUp Size Issue Options
AMG Tech
Posted: Wednesday, November 14, 2018 11:18:20 AM
Rank: Newbie
Groups: Member

Joined: 3/23/2017
Posts: 4
I am handling the NewWindowsEven but when I set the new forms ClientSize, I get only the standard forms control buttons (Minimize, Maximize, Close). I have to manually drag to a size so I can see the content in the webview (or I can hit Maximize, but not every popup needs to be maximized). This is my code for the event:

Code: C#
private void webBrowser_NewWindow(object sender, NewWindowEventArgs e)
        {
            e.Accepted = true;

            EO.WinForm.WebControl webControlPopUp = new EO.WinForm.WebControl
            {
                Dock = DockStyle.Fill,
                WebView = e.WebView
            };
            webControlPopUp.WebView.NewWindow += webBrowser_NewWindow;

            Form frmPopUp = new Form
            {
                ClientSize = new System.Drawing.Size(Convert.ToInt32(e.Width), Convert.ToInt32(e.Height)),
                Text = e.WindowName
            };
            frmPopUp.Controls.Add(webControlPopUp);
            frmPopUp.FormClosed += frmPopUp_Closed;

            frmPopUp.Show();
        }


Thanks for the help!
eo_support
Posted: Wednesday, November 14, 2018 1:01:27 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
Hi,

Your code looks fine. You can try to set webControlPopUp's Dock property to Fill after you added the control frmPopup's Controls collection and see if that resolves the issue for you.

Thanks!
AMG Tech
Posted: Wednesday, November 14, 2018 1:22:21 PM
Rank: Newbie
Groups: Member

Joined: 3/23/2017
Posts: 4
Attempted the suggested and it still did not work. Looked at the variable via debug and they are being returned as null. Both e.Width and e.Height.

Thanks
eo_support
Posted: Wednesday, November 14, 2018 1:28:38 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
Ah. That makes sense. Did you set width and height when you open the popup from your JavaScript code?
AMG Tech
Posted: Wednesday, November 14, 2018 1:39:35 PM
Rank: Newbie
Groups: Member

Joined: 3/23/2017
Posts: 4
It is not my JavaScript/ website code. Based on your comment, I would assume they are not. I will need to figure something else out. Maybe just set some standard size. Thanks for the help on that.

Another quick questions: If I click on an export button on the page, it opens a FileDialog box to save, but it also opens a new blank window from the event. When I click save that new window stays open. How would I catch that the NewWindowEvent is performing a FileDialog open so I can close the new window form after the FileDialog has closed?
eo_support
Posted: Wednesday, November 14, 2018 3:04:59 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
Hi,

This has to do with your page. From the browser engine point of view, the FileDialog does not have anything to do with new window. It is common for a web page to open a new window and then use that window to pull a separate resource. The site developer would then program both the server/client side accordingly so that this separate resource will be served as a download, while the initial page/window that triggers the download won't be navigated away. However the fact that the programmers uses a separate window to trigger a download does not mean there is any fixed relationship between the new window and the download. It's just the programmer decides to use them together this way. So consequentially, there is nothing from the browser engine/EO.WebBrowser would be able to tell you that these two are working together. As such you must address such issue either from the web page or somehow in your own code.

Thanks!
AMG Tech
Posted: Wednesday, November 14, 2018 3:19:56 PM
Rank: Newbie
Groups: Member

Joined: 3/23/2017
Posts: 4
Ok, I was just trying to make this as close to their Chrome experience without giving them chrome for this internal website. When you click the export button on the webpage that is displayed using regular Chrome, it opens a new tab/popup and then it closed immediately and the File Dialog box appears. You click save in the FileDialog box and you are back to the page you clicked the Export button from. Thought since this was based on Chromium/Chrome there was a way to make this happen here. The way it is now, they have to finish with the FileDialog box and then close the new blank tab/popup window.
eo_support
Posted: Wednesday, November 14, 2018 3:26:09 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,221
In that case the most likely scenario is the new WebView is closed through JavaScript but you did not close your host form. You can try to handle the new WebView's Closed event and then close your form in that event handler --- think this as the opposite of the NewWindow event. Inside NewWindow event, the browser engine creates a new WebView for you and you must create a new Form to show it. So when the browser engine closes this new WebView, you may want to close the new Form as well.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.