[Information previously posted on microsoft.public.livecomm]
I need urgent help. Done OK for a newbie getting automation of Windows
Messenger into a Winform C# app but have three problems that I
urgently need pointers to. Point 1 and 2 are the same issue, I think.
Point 3 might relate to a threading issue:
1. I have written a C# Winform application that uses Windows messenger
automation.
When I attempt to send a file through the window messenger object,
there is some horrid screen flicking because a file selection dialog
briefly shows (and I use send keys to auto select the file). Also
there is another flick because the instant messenger chat window pops
up (and then I need to close within code). There seems no way to set
any visible property or use a "hide" method. to prevent all of this.
Does anyone have any ideas how to prevent the quick flashes that
occur. It might be that I need some API handling of the windows and
send messages?? My code below:
---------------------------------------------------------------
msn = new MessengerAPI.MessengerNativeClass();
//MessengerAPI.IMessengerWindow messengerWindow = null;
//messengerWindow = (MessengerAPI.IMessengerWindow)msn.Window;
//messengerWindow.Close();
msn.SendFile(m_user.EmailAddress , "C:\\MyTest.zip");
System.Windows.Forms.SendKeys.Send("{ENTER}"); //to select the file
selection dialog that pops and close it
MessengerAPI.IMessengerConversationWnd InstmessengerWindow =null;
InstmessengerWindow = (MessengerAPI.IMessengerConversationWnd)
msn.InstantMessage(m_user.EmailAddress);
InstmessengerWindow.Close(); //to close the Instant messenger chat
window
---------------------------------------------------------------
2. I am trying to accept invites for file transfer from a remote user
(again using Windows Messenger object).
The messenger objects 'OnFileTransferInviteReceived' event is raised
(and code enters my event handler method) but I am not able to accept
the file transfer programatically. The instant messenger chat window
opens
prompting me to Accept the file tranfer. How can this be achieved
programatically without Windows messenger client user interfaces
appearing?
Again this might be some API level coding - like getting a handle on
the Instant messenger object AND then the chat window that has been
created (but is not visible until the eventhandler has been exited??
3. When a text message has been received and the code enters my event
handler method to handle this, if I try and load a property grid
control with the data in the message, I get the error "Unable to
populate a control created in another thread". If I re-send the
message a second time, this populates the grid no problem. Although
thre must be some lower level issue as down the line when working with
the app, it freezes. Looking at the threads
information(Debug/Windows/Threads) when I am in the method to handle
the event, the thread is different to that for the main form. Any
ideas how to handle this. From within the method, can I do something
like a thread join??
Hope someone can assist me with these urgent problems.
Thanks
Grant