I am making excel add-in in which clicking on menu item or toolbar button, Form opened. I have set form's topmost to true but it remain topmost to all applications of windows xp. I just need to remain topmost to Microsoft Excel only.
I have choosed project in Visual Studio 2008, in Excel ->2003.
Please tell me how to do that with any way ........
You can set your Form's owner to be the Microsoft Excel window. In Windows owned windows are always displayed above their owner. Dialogs and things like the search box in Excel are owned windows, which is what keeps them displayed above their owner.
There are a couple of ways you can set a Form's parent:
This does require you to know the Excel applications window handle.
[Edit - changed code]
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
void func()
{
Form1 f = new Form1();
SetParent(f.Handle, (IntPtr)ThisAddIn.ExcelApplication.Hwnd);
f.Show();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With