on 04-26-2006 10:17 AM - last edited on 02-04-2024 6:05 AM by postmig_api_4
I am developing an Addon for SAP Businnes One using Visual.Net. I need to include Windows forms but it gives me this error - the form is drawn without cantrols and hanged.
my code is:
This is the code:
Private Sub SBOapp_MenuEvent(ByRef pVal As SAPbouiCOM.MenuEvent, ByRef BubbleEvent As Boolean) Handles SBOapp.MenuEvent
If pVal.BeforeAction Then
If pVal.MenuUID = "modUSER" Then
Dim myFORM As New frmIMAGEN
myFORM.TopMost = True
myFORM.Show()
.....
Does anybody knows how to solve this problem?
This is very important an urgent for me, Somebody can help me?
thanks
Hi Carmen,
You must open the windows form in a new thread:
Imports System.Threading
....
....
Dim myThread As Thread
Dim myform1 As New form1
myThreadFic = New Thread(New ThreadStart(AddressOf myform1.Form1Main))
myThread.Start()
In the form1 you must add the Form1Main procedure:
Public Sub Form1Main()
Me.Show()
Do
System.Windows.Forms.Application.DoEvents()
Loop
End Sub
Regards
Blas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Blas! You put me on the right way.
Anyway in my case it gave me this error:
Cross thread operation not valid: Control "XXXXXXXXXX" accessed from a thread other than the thread it was created.
So I add to make some changes:
In my public void SBO_Application_MenuEvent I wrote:
//open the form on a different thread
var thread = new Thread(MyForm.StartForm);
thread.Start();
and in my class MyForm I wrote:
//start the form creating a new instance of it
public static MyForm fMyForm;
public static void StartForm()
{
fMyForm = new MyForm();
fMyForm.Show();
while(true)
Application.DoEvents();
}
Hope it can help someone!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
110 | |
12 | |
11 | |
6 | |
5 | |
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.