Hi, I have a Drag and Drop registration problem (See http://www.thescripts.com/forum/thread434707.html for similar problem post), can anyone out thereadvise on the best solution?
I have a .NET 2.0 application (actually in C#) called from a third party piece of software via VBScript. The VB script passes an object as a parameter which my application applies changes to.
My C# application dynamically creates a form, which includes controls extended from the RichTextBoxControl. These controls need to support drag and drop.
I also need to ensure that the calling application can not receive mouse/keyboard events until my application stops.
If I call my application directly from the VB script I get a drag and Drop registration exception.
I have tried starting my application via a bridging application which starts the app as a separate process (and waits for it to exit) - my app works OK but I can't pass the required parameter using this method.
I have also tried the following code to create my form in a new STA thread:
//public method called via VB script
public void launchApp(object oParam)
{
Thread t = new Thread(new ParameterizedThreadStart(formCreator));
t.SetApartmentState(ApartmentState.STA);
t.Start(oParam);
}
//Form creator in separate thread to avoid Drag Drop registration problems
static public void formCreator(object oParam)
{
frmMyDynamicForm frm = new frmMyDynamicForm(oParam);
frm.ShowDialog();
}
This has two problems.
1. Although I don't get Drag and Drop regestration exception, drag and drop still does not work. Another form allows a drag operation to start OK, and my DragEnter event handler on my extended richTextBoxControl is called but the code " e.Effect = DragDropEffects.Link;" line is ignored and the "Can't drop" icon is displayed.
2. The calling application can get focus.
I am tearing my hair out (I have only documented a 2 of many attempted solutions), can anyone offer advice?
Any suggestions would be much appreciated. Thanks!