cancel
Showing results for 
Search instead for 
Did you mean: 

Form cannot reopen when I choose it from Menu

Former Member
0 Kudos

Hi all,

I have created a menu & submenu and I open a form (PRMain) ONLY the first I choose it. If I close it and reopen it doesn't open again. Any Idea?

Here is the Code:

Private Sub SBO_Application_MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean) Handles SBO_Application.MenuEvent

If pVal.BeforeAction = False Then

Select Case pVal.MenuUID

Case "SM_VID_F1"

If (pVal.MenuUID = "SM_VID_F1") And (pVal.BeforeAction = False) Then

Try

Dim f As SAPbouiCOM.Form

f = SBO_Application.Forms.Item("PRMain")

f.Select()

Catch ex As Exception

Drawform()

End Try

End If

Case "SM_VID_F2"

RunExpert()

End Select

End If

End Sub

Thanks in advance.

Vangelis

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Try this.

Your Main subroutine should be like this. Application.run() keeps the main thread alive.


  Public Sub Main()
        objAddOn = New clsAddOn
       System.Windows.Forms.Application.Run()
    End Sub

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Vangelis

Form is opened and you can't create because it exist.

Try to change form uid's.

Look this thread "[Problem when i have the same form open two time at the same time|]".

HTH

Regards

Sierdna S.

Former Member
0 Kudos

Hi,

Use this code to launch a form designed by screen painter.

Public Function LaunchForm(ByVal strFormType As String, ByVal strXMLPath As String, ByVal strUniqueId As String, Optional ByVal bFocusExistingForm As Boolean = False, Optional ByVal strMsgIfExists As String = "Form Already Exists!") As SAPbouiCOM.Form

Dim oForm As SAPbouiCOM.Form

Try

Try

oForm = objSbo.SBO_Application.Forms.Item(strUniqueId)

Try

'Form already exists

If bFocusExistingForm Then

'Set Focus to the existing form

oForm.Select()

Else

Call objSbo.SBO_Application.MessageBox(strMsgIfExists)

End If

Catch e As Exception

End Try

Catch e As Exception

Dim strPath As String

Dim fcp1 As SAPbouiCOM.FormCreationParams

fcp1 = objSbo.SBO_Application.CreateObject(SAPbouiCOM.BoCreatableObjectType.cot_FormCreationParams)

fcp1.BorderStyle = BorderStyle.FixedSingle

fcp1.FormType = strFormType

fcp1.UniqueID = strUniqueId

fcp1.XmlData = LoadFromXML(strXMLPath)

oForm = objSbo.SBO_Application.Forms.AddEx(fcp1)

End Try

Catch ex As Exception

' Call WriteLogFile(ex.Message, "LaunchForm")

End Try

Return oForm

End Function

Former Member
0 Kudos

Hi Geetha,

I tried

fcp1.XmlData = LoadFromXML("PRM_MAIND.srf")

where

Private Sub LoadFromXML(ByRef FileName As String)

Dim oXmlDoc As Xml.XmlDocument

oXmlDoc = New Xml.XmlDocument

'// load the content of the XML File

Dim sPath As String

sPath = IO.Directory.GetParent(Application.StartupPath).ToString

oXmlDoc.Load(sPath & "\" & FileName)

'// load the form to the SBO application in one batch

SBO_Application.LoadBatchActions(oXmlDoc.InnerXml)

End Sub

but no success

Any Idea?

Former Member
0 Kudos

Hi Vangelis,

please try:

Public Function LoadFromXML(ByVal FileName As String) As String

Try

Dim oXmlDoc As Xml.XmlDocument

oXmlDoc = New Xml.XmlDocument

' load the content of the XML File

Dim sPath As String

'sPath = IO.Directory.GetParent(Application.StartupPath).ToString & "\"

sPath = (Application.StartupPath).ToString & "\"

oXmlDoc.Load(sPath & FileName)

Return (oXmlDoc.InnerXml)

Catch e As Exception

Call objSbo.SBO_Application.MessageBox(e.Message)

End Try

End Function