We're now seeing a new issue that occurs on newer extremely high resolution screen laptops - this web browser control is rendering the pages in a way where they appear small and disproportional. Internet Explorer itself renders the pages just fine but similarly to the last question we posted this custom web control does not seem to be working as Internet Explorer does and manifests these rendering issues. Is there an update or a newer version of this wrapper code available that can help alleviate these issues?
We've been using this code for some time, and we've been experiencing general issues when IE11 is installed on a user's system, where certain websites either don't render correctly or don't function correctly. These same issues are typically not present in IE11 itself, and are only present in this custom web browser on a system that has IE11 installed. Is there a way to allow this custom control to behave like IE11 itself and have the redundancy that IE11 has for properly rendering web pages?
This is a control window drawing is completed in order to have to wait for it to operate, how you can not return the window drawing directly, for example:
private void TestURL(string url)
//Not loaded until the vesting
while (cEXWB1.ReadyState != IfacesEnumsStructsClasses.tagREADYSTATE.READYSTATE_COMPLETE)
//Finished loading operation
if (cEXWB1.ReadyState == IfacesEnumsStructsClasses.tagREADYSTATE.READYSTATE_COMPLETE)
string document = cEXWB1.DocumentSource;
Thanks for the great code example here.
I am attempting to automate a series of steps which results in a file (csv) being downloaded.
I have got to the point where I can login and enter various parameters using the document completed event.
However there is a button I invoke which runs anohter PHP script which and then downloads a file.
When I invoke the button, the File Download dialog comes up to save the CSV file.
I do not have a URL to the file download.
Is there a way I can trap this event and automate the download to a specified location?
Wow! Very impressive work - I've been looking for something like this for a while and it was like a dream came trough when I found it. I will be using the control, more or less as is in a commercial application within a totally different field.
I also like the demo app which I will have a look at and probably use as a model for my own main application (in which the control will reside).
Thank you so much for sharing this wonderful control and demo app.
I am facing an rendering issue. In my app a background thread dowing its work after its completion i have to open a dialog, Also at the same time browser is loading.
Some time a situation occurs where backgroung thread completion and browser navigation occurs at same time. Focus is moved to the dialog open after thread completion. Behind the same browser is loaded but with white screen. This is the only time when issue can be reproduce, otherwise if works great.
After closing the dialog, if you move the mouse over browser it starts rendering.
Browser navigation completed event is properly occurs without any error. Please help how to solve this.
I am developing an MFC/C++ application and find that web browser controls keeps stealing the focus from other windows. I downloaded this sample app and changed IProtectFocus.AllowFocusChange so it always sets pfAllow to "false", however I am still seeing the same problem with this sample app. To recreate this behavior, create a simple web page that has the auto-refresh flag set in its head section, like this:
<meta http-equiv="refresh" content="10" />
Is it possible to prevent the web browser from stealing the input focus every time the page, or an element inside the page, refreshes?
Hi, your code is amazing.
I was wondering to know how can I block downloading of specific images or js files
there is a downloadbegin event but it dose not clear which file will be download and you have filter images but I couldn't find where you found it.
In simple way, I want to know when and which file being downloading and cancel it if I want.
I'm attempting to attach an event to a RadioButton in order to be notified when the "checked" property has been changed. I've been successful at doing this with Text Input Boxes & Select Boxes (for focus & blur) using the following:
HTMLInputTextElementEvents _html_input_text_element_events = new HTMLInputTextElementEvents();
HTMLSelectElementEvents _html_select_element_events = new HTMLSelectElementEvents();
if (element is mshtml.IHTMLInputElement)
_html_input_text_element_events.elemonfocus += new HTMLInputTextElementEventHandler(_html_input_text_element_events_elemonfocus);
_html_input_text_element_events.elemonblur += new HTMLInputTextElementEventHandler(_html_input_text_element_events_elemonblur);
bool connect = _html_input_text_element_events.ConnectToHtmlElementEvents(element );
elseif (element is mshtml.IHTMLSelectElement)
_html_select_element_events.selectonfocus += new HTMLSelectElementEventHandler(_html_select_element_events_selectonfocus);
_html_select_element_events.selectonblur += new HTMLSelectElementEventHandler(_html_select_element_events_selectonblur);
bool connect = _html_select_element_events.ConnectToHtmlSelectElementEvents(element );
When I attempt to do the same with a Radio Button (I've tried with HTMLElementEvents, HTMLInputTextElementEvents, and HTMLSelectElementEvents) like so:
HTMLElementEvents hee = new HTMLElementEvents();
hee.elemonclick += new HTMLElementEventHandler(hee_elemonactivate);
Do I need to cast as something else? Is this possible?
Is there a way to retrieve the selected element. I'm new to mshtml interop and have a need to retrieve the selected element(s), if any. Also, how do you discern (programmatically) if any elements are selected? I've found the iSelectionServices interface but am unclear how to proceed. HTMLEditHelper does not appear to wrap or provide this functionality. Thx.
I want to try this new csExWB class out. But I do not see a clear path on how to encorporate it into a hello-world like project. If one has say a VS2010 hello-world project, where thet made a simple form-based app that had the WebBrowser control in it. What would one have to do to use csExWB instead of the WebBrowser control?
I figure in the form_Load method, one would instantiate an instance of the csExWB class and pass the WebBrowser control to it, so the csExWB class could override it, but I do not see anything in csExWB to do this.
Also, what would one add as a reference to the hello-world project? Would they add a reference to csExWB.dll? What about Interop.CSEXWBDLMANLib.dll? Would one need to add that as well. Also, what about that csExWBDLMan.dll?
First of all csExWB must have been a monumental effort and Mike deserves enormous credit for his oevre ....
It is possible to incorporate csExWB into one's own project, but it requires some tenanicty. I had an application which included a WebBrowser control (effectively this is IE) and had got almost to the completion of my project when I git a problem which I could not overcome (downloading a file without the irritating "File Download" pop-up"). After 2 weeks of frustration I decided the only answer was a webbrowser like csExWB which does (I think) everything WebBrowser/IE does ... but also with a 'silent' and 'automatic' (or at least semi-automatic) file download capability. Perfect.
I did hit a few glitches though:
1. My original application had to be changed to build from 'Any CPU' down to 'X86'
2. I had to get the DemoApp working completely and then .... very slowly ... take components out of it until I had a barebones frmMain form which was JUST the browser window.
3. Could not get this barebones browser to work with 'Visible = false' (it just doesn't seem to want to 'go') so I reduced the browser window down to Size = (0,0) as a workaround )
4. Had to register the CSEXWBLDMANLib.dll library in the C:\Windows\SysWOW64 directory rather than C:\Windows\System32 before the program would build
5. Had to hack IN code to delete csExWB browser cookies and cache entries before I could get 'consistent' access to my target website
Apart from that, lots more grey hairs and many wrinkles, everything in my application is a thousand times better than using WebBrowser/IE
Hey folks! I got it encorporated. Here is what I had to do!
I had a VS2010 hello-world app. The app added the csExWB.dll and csExWBDLMANLib.dll as references. Supposedly this should also take care of registering csExWBDLMANLib.dll, albeit in my test, I had already manually run RegSvr32 on it ahead of time.
In my app, I added the old WebBrowser, so I could have something to work with the GUI of VS2010's form editor, and I named it "WebBrowser_Main".
Then I simply declared a cEXWB in my app's main form as a data member;
public csExWB.cEXWB cEXWB_This = null;
And in the MyForm's Constructor I instatiated it as such:
then in the MyForm_Load I added the event handler like this:
public void MyForm_Load(object objSender, EventArgs EventArgs_Param)
cEXWB_This.BeforeNavigate2 += new csExWB.BeforeNavigate2EventHandler(cEXWB_This_BeforeNavigate2);
cEXWB_This.NavigateComplete2 += new csExWB.NavigateComplete2EventHandler(cEXWB_This_NavigateComplete2);
cEXWB_This.DocumentComplete += new csExWB.DocumentCompleteEventHandler(cEXWB_This_DocumentComplete);
cEXWB_This.ProgressChange += new csExWB.ProgressChangeEventHandler(cEXWB_This_ProgressChange);
as far as i understand this should be done on the ProtocolHandlerOnBeginTransaction event.
i'm using the m_AdditionalHeadersToAdd field - but it does not seem to work, the server side still responds as if this header did not exist.
i've tried the BeforeNavigate2 event with headers field as well
this is working well when i use HttpWebRequest class or ordinary framework's web browser control with the invoke:
this.webBrowser1.Navigate(@"https://www.xxx.xx/xx", "", null, "X-header: header");
Use Visual Studio's configuration manager to set it to compile to an x86 platform. I am on Windows 7 64bit and using C# 2008 Express.
Instructions are from here:
1. G in to the menu option Tools>Options and the in the dialog box tick the box in the bottom right corner to "Show all settings"
2. Once the settings expand go to "Projects and Settings" expand it and click on "General"
3. Check the option which is called "Show advanced build configurations", then close the dialog box
4. Now if you right click on the solution explorer, chose properties
5. Goto "Configuration Properties", now you should be able to see the platform drop down. This will probably have only "Any CPU" selected; if so click on "Configuration Manager"
6. Chose the option "New" under the "Active Solution Platform" drop down box
7. Chose the new platform of x86 and copy your settings from "Any CPU"
8. Then just make sure that your projects in your solution refer to x86 as the platform rather that "Any CPU"
On a 64-bit Windows installation, the path C:\Windows\SysWow64 may also be an option. Note: Counter-intuitively, on x64 Operating System, "System32" contains 64-bit system libraries and tools, while "SysWow64" contains 32-bit libraries and tools. e.g. Regedit.exe and Odbcad32.exe. "Wow" stands for "Windows-On-Windows", which is the virtual machine or backwards-compatibility that allows 32-bit processes to execute hosted on a x64 Operating System. In the same way that NTVDM hosts 16-bit processes in a x86 Operating System.
I noticed your code works for script errors and i have tried using it but not having alot of luck. I implemented all the requirements for the script error to run but do i require CBT hook? I would appreciate to know what code is required that handles the script errors.
I want two csExwb processes (not threads but csExwb of two programs,program A and program B). Program A log in the website and pass the cookie and session information to Process B and then Process B can visit the website without loging in. Reason to run programs like this is you can terminate process B any time you want and release the momery of Process B. Something like IE8 and Chrome.
Any idea? Many thanks!