WebBrowser Control in Customization

I have a UDForm that I have assigned to a new menu. In that UDForm there is a very basic customization:

private void UD30Form_Load(object sender, EventArgs args)
	// Hide the EpiTreeViewPanel
	Ice.Lib.Framework.EpiTreeViewPanel tree;
	object treeViewPanel = typeof(Ice.UI.App.UD30Entry.UD30Form).InvokeMember("epiTreeViewPanel1", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic, null, UD30Form, null);
	tree = (Ice.Lib.Framework.EpiTreeViewPanel)treeViewPanel;
	tree.Visible = false;

	// Hide the panels (Detail and List)
	object dockManager = typeof(Ice.UI.App.UD30Entry.UD30Form).InvokeMember("baseDockManager", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic, null, UD30Form, null);
	Infragistics.Win.UltraWinDock.UltraDockManager dock = (Infragistics.Win.UltraWinDock.UltraDockManager)dockManager;

	EpiUltraComboPlus navControl = ((EpiUltraComboPlus)(csm.GetNativeControlReference("cb27bd11-f6d2-44a0-8686-16db4b4cd048")));
	navControl.Visible = false;
	WebBrowser web = new System.Windows.Forms.WebBrowser();
	web.Dock = System.Windows.Forms.DockStyle.Fill;
	Ice.UI.App.UD30Entry.MainPanel mainPanel1 = ((Ice.UI.App.UD30Entry.MainPanel)(csm.GetNativeControlReference("1dff11bc-3024-4d17-acfc-b7af287e274b")));

@josecgomez @rbucek - I told you that the next customization I do would be in C#. If nothing else, at least I am a man of my word :slight_smile:

Basically, hide all of the default controls and containers, and then add a WebBrowser Control to the form.

All of that works perfectly…the SuperSecretURL loads right up, links are clickable, right-click context menu is there, etc. However, there is one issue that I am having. Modifier Keys do not work. My users are complaining that they cannot highlight some text in the WebBrowser control and use CTRL-C /V to Copy/Paste. Right click and selecting copy/paste does work though.

Anyone have any ideas what I may be missing?

I have also taken this same approach in Visual Studio, programmatically adding the WebBrowser control and showing it on the form, and the modifier keys work that way, so to me this says there is something in the way that Epicor is capturing my keystrokes and not sending all of them to the control.

Based on what I’ve seen in Epicor, I’d expect this is Epicor misbehavior and not your Customization.

Epicor doesn’t consistently handle the standard CTRL-C and CTRL-V keystrokes. In some areas these work, in other areas they don’t and the right-click copy or paste is needed.

I don’t have a list of where the CTRL-C and -V keystrokes are ignored by Epicor and where they aren’t; haven’t tried to compile one.

I just have a conditioned sequence that I follow : if CTRL-C or -V doesn’t work, use the right-click menu. With CTRL-C, of course, go back into Epicor to use the right-click menu to copy the text I thought I’d copied.

Just another ERP annoyance.

Ken Brunelli

1 Like

Well that is just annoying, heh.

Quick question. Does this browser page contain all text or are there images on there as well?

Mark W.

It contains a few images. I’m curious as to what effect that would play on the control, or if it is more of an Epicor glitch.

Neither. When I hear copy/paste by the users, I wondered if you could just make the http call in the background, parse the results and put them into fields on your form so they didn’t need to copy/paste them. (or at least be able to copy/paste from a different type of control.)

Mark W.

How does right mouse copy/past behave?

The Right-Click context menu for Copy/Paste works great.


The context menu seems to be the same context menu from Internet Explorer, which would make sense.


It is weird that the control handles all other keystrokes just fine (Up/Down,Page Up/Down, Home, End, etc). I can even type in the forms that are on the page and press Enter to submit the form. Epicor for some reason is just saying “Too bad, we are not giving you modifier keys on that control”.

How about mapping hot-keys? or changing the defaults

I tried mapping hotkeys which didn’t work, so it boils down to the user having to ‘deal with it’ for right now.

You can try creating your own keydown event handler on the form. In the form load event handler code put this:

UD30Form.KeyDown += new EventHandler(UD30FormKD)

outside of the load method put this:

private void UD30FormKD(object sender, KeyEventArgs e)
_ {_
_ if (e.KeyCode == Keys.C && e.Modifiers == Keys.Control) {_

_ IHTMLDocument2 htmlDocument = web.Document.DomDocument as IHTMLDocument2;

_IHTMLSelectionObject currentSelection= htmlDocument.selection;_

_ if (currentSelection!=null) _
_ {_
_ IHTMLTxtRange range= currentSelection.createRange() as IHTMLTxtRange;_

_ if (range != null)_
_ {_
_ MessageBox.Show(range.text);_
_ }_
_ }_
_ }_
_ }_

Add reference for above code to work
Add reference to “C:\Program Files\Microsoft.NET\Primary Interop Assemblies\Microsoft.mshtml.dll”

Then at the very top add
using mshtml;

I have done this in C# windows form applications never in Epicor but I believe it should work.


1 Like

And instead of the message box you would use