Showing non-modal WPF forms from Excel is tricky.
I think by default Excel captures all keyboard messages from child windows, and WPF does not have built-in behaviour to override this.
This is not something I’ve dealt with myself, so I’m only suggesting from what I’ve seen elsewhere.
There are three things you can try:
The CTP can be floated too, and I think if that works it’s the easiest integration.
(If needed you might need to set up a call to EnableModelessKeyboardInterop somehow ?)
See this answer for a snippet on how to start the extra thread: https://stackoverflow.com/a/5884085/44264
Please let us know if you make any progress.
-Govert
--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/20ed42bb-c4f1-4b99-9d8f-de10c0210a9en%40googlegroups.com.
Hi James,
The problem is likely that you are talking to the Excel COM object model from your new WPF thread.
You might need to change what happens inside here:
calcScreen.Calculate(excel_application);
Maybe you could publish a small sample project that we can try to fix up to get the patterns right.
-Govert
From: exce...@googlegroups.com <exce...@googlegroups.com> On Behalf Of James Stevenson
Sent: Friday, May 3, 2024 1:19 PM
To: Excel-DNA <exce...@googlegroups.com>
Subject: [ExcelDna] Re: ExcelDNA with WPF - Textbox Input
Hello,
Thaks for your response but the suggested changes didnt work.
I will keep looking and trying other suggestions. At this point it seems the only option is to only have my WPF window as the active one and disable input into excel until my window is closed.
On Friday, May 3, 2024 at 4:07:05 AM UTC+8 Brian Satola wrote:
My thoughts:
- The code I posted was modified from async, and I missed a couple of things:
- Change .Invoke(async () => to .Invoke(() =>
- Change .BeginInvokeShutdown(DispatcherPriority.Background); to .InvokeShutdown();
If that does not work:
- Comment out the Calculate and Close lines added to the closed event to see if those are causing an issue. At the very least, the added Close call seems redundant as the window is already in the process of closing.
- Add a log entry after InvokeShutdown to make sure that it reached this point.
And if that does not work, no clue.
On Thursday, May 2, 2024 at 11:27:11 AM UTC-4 James Stevenson wrote:
I have followed this and can get it running, entering data in textboxes and between excel cells works great.
However, the result is my excel add in keeps getting disabled. I think this is in part to a zombie thread. When I look in processes after closing down excel it is still listed.
Once I reopen Microsoft Excel my add-in becomes disabled. I have tested by running the add-in within the main excel thread (albeit without the inputting of data functionality) and my add-in loads ok when excel is opened/closed.
--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/exceldna/9ebd96c0-bac2-4baf-977c-db14e64332den%40googlegroups.com.