cancel
Showing results for 
Search instead for 
Did you mean: 

show winform in an Activex Control

Former Member
0 Kudos

hi all,

usually their is an option to show web Form in an activex Control with the help of the code mentioned below.

Dim oForm As SAPbouiCOM.Form
        Dim creationPackage As SAPbouiCOM.FormCreationParams = SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)

        Try
            creationPackage.UniqueID = "MFormIEID"
            creationPackage.FormType = "sdf"
            creationPackage.BorderStyle = SAPbouiCOM.BoFormBorderStyle.fbs_Sizable

            '// Add the form to the SBO application
            oForm = SBO_Application.Forms.AddEx(creationPackage)
        Catch ex As Exception
            SBO_Application.SetStatusBarMessage(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, True)

            Try
                oForm = SBO_Application.Forms.Item("MFormIEID")
            Catch ex2 As Exception
                SBO_Application.SetStatusBarMessage(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, True)
                Exit Sub
            End Try
        End Try

        oForm.Visible = True

        Dim oItemX As SAPbouiCOM.Item
        Dim oActX As SAPbouiCOM.ActiveX
        Dim oWebX As SHDocVw.WebBrowser
        Try
            oForm.Width = 700 ' get or create some form before
            oForm.Height = 500
            oItemX = oForm.Items.Add("xyz", SAPbouiCOM.BoFormItemTypes.it_ACTIVE_X)
            oItemX.Height = oForm.Height - 28
            oItemX.Width = oForm.Width - 8

            oActX = oItemX.Specific
            oActX.ClassID = "Shell.Explorer.2" 'or use the GUID "{8856F961-340A-11D0-A96B-00C04FD705A2}"
            oWebX = oActX.Object
            ' go "Home"
            oWebX.GoHome()
            ' or go to SMP
            oWebX.Navigate("http:\\www.google.com")
        Catch ex As Exception
            SBO_Application.MessageBox(ex.ToString)
        End Try

in the same way i need to show a windowform (vbform) in to ActiveX Control.

can anyone give me the sample...?

regards,

Rob

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

hi,

i am not able to understand the Activex code which you have given in link.

here is my task.

i did a treelist view control in vb form.

and i created a sapb1 form.

now i want to integrate this vb form in to sap form.

can i get any solution

regards,

sm

Former Member
0 Kudos

Hi,

You'd better create a .net ActiveX control and embed your win form into it, then you can add it into B1 form in the usual way.

There is an article about how to create a ActiveX in .net.

http://www.codeproject.com/KB/cs/CreateActiveXDotNet.aspx

C# sample code of embedding a form into a user control (your ActiveX control):


//insert the following code into the user control class constructor
WinForm form = new WinForm();
form.TopLevel = false;            
form.BackColor = Color.Black;
form.Size = new Size(200, 80);
form.Location = new Point(10, 10);
form.FormBorderStyle = FormBorderStyle.None;         //to hide the title bar
this.Controls.Add(form);
form.Show();

Have a try and good luck!

Cheers,

Tedy