Try to add new attribute

85 views
Skip to first unread message

文源

unread,
Aug 22, 2024, 9:10:54 AM8/22/24
to Excel-DNA
Hi Govert,

I am trying to add new featrues for excel-dna, such as enum list. First of all, I'm trying to add a new attribute in ExcelDna.Integration, just like enum = true, when I write a new custom function with attribute eum ,the compiler did not report an error. Then I read the code for trying to get the eum information.However, I found the Instance "reginfo" which use ExcelIntegration.GetRegistrationInfo to get the function information, I print the information just get information bellow:

[3,0]:
[3,1]:f2
[3,2]:QEE
[3,3]:Addliuyu
[3,4]:input1,input2
[3,5]:
[3,6]:Test .NET 6 add-in
[3,7]:
[3,8]:
[3,9]:returns a 7x2 array of information about the IntelliSense server status
[3,10]:input1 to add
[3,11]:input2 to add.
[3,12]:
[3,13]:
[3,14]:
......

There is  no information about my custom attribute enum. When I wanted to know more about its implementation, I couldn't find the relevant code.
How can I get the information about my new attribute, should I register this parameter , if it is,which cs file should I read and change?How can I add the information into the "reginfo"?
Also, I read the code of Class RegistrationInfo,

            object[] registerParameters = new object[6];
            registerParameters[0] = ExcelDnaUtil.XllPath;
            registerParameters[1] = "RegistrationInfo";
            registerParameters[2] = "QQ"; // Takes XLOPER12, returns XLOPER12
            registerParameters[3] = _registrationInfoName;
            registerParameters[4] = null;
            registerParameters[5] = 0; // hidden function

It seems  a little differerent with the print
Could you give me some suggstion?

Yuan

文 源

unread,
Jul 5, 2026, 12:55:59 PMJul 5
to exce...@googlegroups.com
获取Outlook for Android
Hello,
     I have a problem.The focus of the wpf window generated by the 'exceldna' plugin is always stolen by the excel main program. Text entered in the 'textbox' of the wpf window is directly written into the 'cell' of Excel, and the content pasted by using the 'Ctrl+V' shortcut key is also written into the 'cell' of Excel, instead of being pasted into the 'textbox' of the wpf window. How should I resolve this problem?

Yuan

Govert van Drimmelen

unread,
Jul 5, 2026, 6:29:03 PMJul 5
to exce...@googlegroups.com

There are known problems between WPF and Office, but there should be some ways to work around them.

 

Can you explain a few things first?

  • Are you hosting the WPF in a separate window that you pop up, or in a CTP pane?
  • If you are showing a Window, are you showing it as a model window, or modeless where you still want to interact with Excel while it is showing?

 

Here are some suggestions from Codex:


This is a known focus/message-routing problem when showing a modeless WPF window from Excel. The WPF textbox can appear focused, but Excel is still receiving the keyboard messages, so typing and Ctrl+V go to the active cell.

The best solution is to host the UI in an Excel Custom Task Pane. If the UI is WPF, host the WPF UserControl inside a WinForms UserControl using ElementHost, and create that WinForms control as the Excel-DNA custom task pane.

If you must use a standalone modeless WPF window with Show(), try setting Excel as the owner window and enabling WPF modeless keyboard interop before calling Show():

 

var window = new MyWpfWindow();

new WindowInteropHelper(window)
{
    Owner = ExcelDnaUtil.WindowHandle
};

ElementHost.EnableModelessKeyboardInterop(window);

window.Show();
window.Activate();

 

Add references to WindowsFormsIntegration, and use:

 

using System.Windows.Forms.Integration;
using System.Windows.Interop;
using ExcelDna.Integration;

 

ShowDialog() works because it creates a modal interaction with Excel, but that is not suitable if the user must continue working in Excel. For modeless UI, Custom Task Pane is the most robust approach.

 

If you’re still stuck after trying this, write back with a bit more details and I can try to make an example where the keyboard focus works right.

 

-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 visit https://groups.google.com/d/msgid/exceldna/CH2PR05MB6887662FC37C18DC534A6C05F5022%40CH2PR05MB6887.namprd05.prod.outlook.com.

文源

unread,
Jul 12, 2026, 1:46:20 AMJul 12
to exce...@googlegroups.com
Thanks very much for your answer.It is helpful for me.


From: exce...@googlegroups.com <exce...@googlegroups.com> on behalf of Govert van Drimmelen <govert.va...@gmail.com>
Sent: Monday, 06 July 2026 06:28:47
To: exce...@googlegroups.com <exce...@googlegroups.com>
Subject: RE: [ExcelDna] WPF window could not be focus.
 
Reply all
Reply to author
Forward
0 new messages