Swap Posted January 18, 2003 Posted January 18, 2003 (edited) Hi, I'm trying to create a custom msn messenger in VB.net. For this I'm using a library I found (http://www.msnfanatic.com/article.php?sid=29), and I based myself on an example wich was supplied to (in C# though). Loggin in works, and a few other functionalitys to, but by far not all. The problem i am having now is that when the messenger-object generates a conversation, i want to open a new form. Opening this form with a button works great, but when i want to open it from the event (set of by the messenger object) the forms opens and simply doesn't respond anymore (stops reacting, to close it you get the 'stop program' window). the code i use to open the form is: Private Sub conversationCreated(ByVal sender As messenger, ByVal e As ConversationEventArgs) Handles messenger.ConversationCreated If openConversatie() Then MessageBox.Show("Conversation form opened nicely") Else MessageBox.Show("Conversation form did not open nicely at all") End If 'newForm.acceptConversatie(sender, e.Conversation) End Sub Private Function openConversatie() As Boolean Try Dim newForm As FormConversatie = New FormConversatie() newForm.Show() Catch e As Exception Return False End Try Return True End Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If openConversatie() Then MessageBox.Show("Conversation form opened nicely") Else MessageBox.Show("Conversation form did not open nicely at all") End If End Sub However, since i doubt that the error is in this, i attached the entire file as well. I tried to give most of the variables english names, but sometimes there will be a dutch one in between. My humble apologies for that... Don't worry about using the hotmail account supplied in the program to test this program. It's one I created to test this program with, so i could communicate between this account and my regular one (wich is the only one in the list). Please don't change the password to this account, I don't use it anyway and it would save me the trouble of making yet another one. any help would be greatly appriciated Edited January 18, 2003 by divil Quote
*Gurus* divil Posted January 18, 2003 *Gurus* Posted January 18, 2003 I deleted your original attachment because it contained some binaries. However, I did fix your problem, and I have attached a zip file with the working solution in. I tested it with my own MSN Messenger account and I was able to talk to and from it just fine. Your problem was a threading issue. The event was being raised by the dotMSN dll on a different thread than your UI components. It's very important to have all UI components on the same thread, so you have to use the Control.Invoke method to invoke a delegate on the correct thread. You will see I've done this in your main form, by defining a delegate and calling it with parameters. All that was required then was to uncomment the code you'd already written in your Conversatie form and it all worked.dotmsnzelf.zip Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Swap Posted January 18, 2003 Author Posted January 18, 2003 Thanks. I've had VB.net as a course since spetember now and I haven't even heard of threads (only in my Java course, last year, but that's waay different). Anyway, thanks a lot... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.