0

I wrote an Add-In for the VBE-Development enviroment like described here: How to write a Add-in for the development enviroment: "Microsoft Visual Basic for Applications"

In there I created a settingsDialog (which is a common Forms-dialog with some TextBoxes) which I open like this:

var dlg = new SettingsDlg(m_Settings);
dlg.StartPosition = FormStartPosition.CenterParent;
dlg.Show(new HwndWrapper(m_VBE.MainWindow.HWnd));

But inside SettingsDlg Copy&paste is not working. When I try to post text into a text box, nothing happens.

Gener4tor
  • 414
  • 3
  • 12
  • 40

1 Answers1

0

I fixed the problem by starting the form in an extra thread. Like this:

        var thread = new Thread(() =>
        {
            var dlg = new SettingsDlg(m_Settings);
            dlg.StartPosition = FormStartPosition.CenterParent;
            dlg.Show(new HwndWrapper(m_VBE.MainWindow.HWnd));
            Dispatcher.Run();
        });

        thread.SetApartmentState(ApartmentState.STA);
        thread.Start();
Gener4tor
  • 414
  • 3
  • 12
  • 40