WebBrowser Control - auf Form?
Matthias Müller
Hallo zusammen,mal wieder eine Spezialität:
Kann man ein WebBrowser-Control auf eine eigens erstellte Form bringen?
Viele Grüße
Matthias
Sascha Balke
Dieser Frage schließe ich mich doch glatt an.Anders Olsson
Hi Matthias,The SwissAddonFramework.UI.Components.Windows.SAPDotNetForm class can be used to display a form that can host .NET controls in Business One. The SAPDotNetForm class is abstract so you must create a class that derives from it. This can be made in "Global methods and variables" under coresuite customize -> Extended code.
We can add the following simple class:
public class CustomDotNetForm : SwissAddonFramework.UI.Components.Windows.SAPDotNetForm
{
public CustomDotNetForm()
: base(true, "myCustomForm", SwissAddonFramework.Utils.UniqueStringGenerator.Next())
{
}
}
With this in place, we can reference the CustomDotNetForm from any customize rule. Note that SAPDotNetForm derives from UserControl, so you can add controls to it etc.
Example:
CustomDotNetForm customDotNetForm = new CustomDotNetForm();
customDotNetForm.Size = new System.Drawing.Size(1024, 768);
customDotNetForm.Text = "This is the window title";
// Add code to place controls to the form...
// Dispay the form inside SAP
customDotNetForm.LoadToSap();
Refer to the coresuite framework documentation/samples for further info about SAPDotNetForm.
Kind regards,
Anders Olsson
Matthias Müller
Hi Anders,thank you so much for this helpful information - now i will see how to set up.
Kind regards,
Matthias
Sascha Balke
Hi Anders,Thank you for this example.
maybe you have even an extended code?
with
string website = "www.google.de";
System.Diagnostics.Process.Start("iexplore.exe", website);
I can directly open the browser with the url.
I just do not know how I open the browser in the form :(
Matthias Müller
Hi Anders,thanks a lot - is working fine - but how can i add an item such as a TextEdit or better a WebbrowserControl?
Best regards
Matthias
Anders Olsson
Hi guys,Adding a .NET TextBox control is straight-forward enough:
customDotNetForm.Controls.Add(new System.Windows.Forms.TextBox());
But if you try to do the same with a WebBrowser control
customDotNetForm.Controls.Add(new System.Windows.Forms.WebBrowser());
... you will get an error: "ActiveX control 'GUID' cannot be instantiated because the current thread is not in a single-threaded apartment."
I can't give you a straight answer as to how to solve that, but if you need a solution please contact coresystems support and we can help you look into that further.
Regards,
Anders Olsson
Matthias Müller
Hi Anders,this morning i found this solution as well. And i stopped exact at this point....
I have tried so many things to "create" the correct thread...
Regards,
Matthias
Anders Olsson
See this post:[url="http://forum.coresystems.ch/index.php?/topic/5588-web-browser-in-sap-form/page__hl__browser__fromsearch__1"]http://forum.coresys...__fromsearch__1[/url]
0
Please sign in to leave a comment.
Comments
0 comments