Web browser in SAP Form
DREAN Sébastien
Hi,We want to open a web browser in a SAP form with the WebBrowser C# Object, with this code
[CODE]System.Windows.Forms.WebBrowser wb = new System.Windows.Forms.WebBrowser();[/CODE]
But we have this error :
[color=#ff0000]Impossible d'instancier le contrôle ActiveX '8856f961-340a-11d0-a96b-00c04fd705a2', car le thread actuel n'est pas un thread cloisonné (STA, Single-Threaded Apartment).[/color]
(translation should be : "ActiveX control 'GUID' cannot be instantiated because the current thread is not in a single-threaded apartment")
Any ideas about how to solve this ?
Best Regards,
Sébastien DREAN
Anders Olsson
Hi Sébastien,Since I helped you via email and you got it working I thought I will post the solution here in case someone else needs to do the same:
In the Extended code of customize, add this class:
[CODE]
public class BrowserForm : SwissAddonFramework.UI.Components.Windows.SAPDotNetForm
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
public BrowserForm()
: base(false, "COR_BROWSER", SwissAddonFramework.Utils.UniqueStringGenerator.Next())
{
}
protected override void InitComponents()
{
InitializeComponent();
this.Text = "coresuite Browser";
System.Windows.Forms.WebBrowser browser = new System.Windows.Forms.WebBrowser();
browser.Size = new System.Drawing.Size(1024, 768);
browser.Url = new Uri("http://www.coresystems.ch/");
this.Controls.Add(browser);
}
}
[/CODE]
Next, create a function button rule on any form with this code:
[CODE]
BrowserForm form = new BrowserForm();
form.Size = new System.Drawing.Size(1024, 768);
form.LoadToSap();
[/CODE]
DREAN Sébastien
Hi All,
In the same sense, is it possible to open an Excel workbook in a SAP Form ?
The idea is to open it with only the sheets, and not the ribbon.
Best Regards,
Sébastien DREAN
0
Please sign in to leave a comment.
Comments
0 comments