Search code examples
c#winformsvstoexcel-addinswinforms-interop

Winforms and VSTO Excel ShowDialog() partly modal


The strangest thing ever!

I'm working on an Excel add-in, the ribbon has some buttons that pop some modal dialogs. all of those dialogs are initiated in the same way from the button click event in the ribbon:

SampleForm sample = new SampleForm();
sample.ShowDialog();

so far everything works great - when the modal form appears I can't change cells selection and click the ribbon until the form is closed.

except for one form. when showing this form only the upper part of excel isn't active (i.e. not responding to mouse clicks) but I still can select cells in the worksheet. plus, I can't hear the beep sounds when the modal open and I click on the ribbon items - as I hear when the other modal windows open.

when this bad form is open I can see that this.modal = true plus since the ribbon clicks are disabled (without making a sound) it's actually partly modal.

My questions are: does it sound familiar? where to look for an answer? what can be the cause for that behavior?


Solution

  • What made the modal window to become partly modal is changing the cursor state of excel.

    excelApp.Cursor = XlMousePointer.xlWait;
    

    Removing this call fixed the issue