on 09-09-2008 2:28 PM
Hello guys, I'm trying to add an instance os Internet Explorer ActiveX into a SBO form using C#, the code I'm using is the following:
SAPbouiCOM.Form oGenericForm = null;
SAPbouiCOM.FormCreationParams oGenericFormCreationParams = null;
SAPbouiCOM.Item oGenericItem = null;
SAPbouiCOM.ActiveX oActive = null;
SHDocVw.InternetExplorer oSHDocVw = null;
System.Object nullObject = 0;
string str = "";
System.Object nullObjStr = str;
try
{
oGenericForm = oSBOApplication.Forms.Item("_BrowserForm1");
}
catch
{
try
{
// Main form creation
oGenericFormCreationParams = (SAPbouiCOM.FormCreationParams)oSBOApplication.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams);
oGenericFormCreationParams.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Sizable;
oGenericFormCreationParams.FormType = "fBrowserForm1";
oGenericFormCreationParams.UniqueID = "_BrowserForm1";
oGenericForm = oSBOApplication.Forms.AddEx(oGenericFormCreationParams);
oGenericForm.Visible = false;
oGenericForm.AutoManaged = false;
oGenericForm.Top = 20;
oGenericForm.Left = 280;
oGenericForm.Width = 640;
oGenericForm.Height = 480;
oGenericForm.Title = "SBO Internet Browser";
// Web browser activeX component creation
oGenericItem = oGenericForm.Items.Add("brs", SAPbouiCOM.BoFormItemTypes.it_ACTIVE_X);
oGenericItem.Top = 5;
oGenericItem.Left = 5;
oGenericItem.Width = oGenericForm.Width - 10;
oGenericItem.Height = oGenericForm.Height - 10;
oActive = ((SAPbouiCOM.ActiveX)(oGenericItem.Specific));
oActive.ClassID = ((SAPbouiCOM.ActiveX)(oGenericItem.Specific)).ClassID = "Interop.SHDocVw";
oSHDocVw = ((SHDocVw.InternetExplorer)(oActive.Object));
oSHDocVw.Navigate("http:///sdn.sap.com", ref nullObject, ref nullObjStr, ref nullObjStr, ref nullObjStr);
}
catch (Exception er)
{
oSBOApplication.MessageBox(er.Message, 0, "Ok", "", "");
}
}
oGenericForm.Visible = true;
When I run that code I got the following error message:
Invalid class sequenca (HRESULT: 0x800401F3) (CO_E_CLASSTRING))
Does anyone knows what I'm missing?
I'm probably doing some bad cast, do you have any idea on how to fiz that?
Thanks in advance.
Dear Gabriel Izar,
Please try to change following code to solve the issue:
from
oActive.ClassID = ((SAPbouiCOM.ActiveX)(oGenericItem.Specific)).ClassID = "Interop.SHDocVw";
to
oActive.ClassID = "Interop.SHDocVw";
If the issue still exists, could you debug the code and find out which code line cause the error?
Best Regards
Jane Jing
SAP Business One
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
For me it only works when I changed the following line:
oActive.ClassID = ((SAPbouiCOM.ActiveX)(oGenericItem.Specific)).ClassID = "Interop.SHDocVw";
To:
oActive.ClassID = "Shell.Explorer.2";
Elad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Jane Jing, thank you so much for your reply.
To fix the problem I was having I just did the following:
Where I had:
oActive.ClassID = ((SAPbouiCOM.ActiveX)(oGenericItem.Specific)).ClassID = "Interop.SHDocVw";
Now I have:
oActive.ClassID = "{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}";
Now the program is working well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
99 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.