Need to place a floating modeless form over excel main window (quasi-task pane)
Hi I need to emulate a task pane by floating a modeless form over the Excel main window. The reason for this requirement is t开发者_运维技巧hat I need to have taskpane features for my Excel 2003 add-in, but cannot use the document-centric model.
Can anyone suggest what would be the best way to do this? The modeless form would need to detect the main window resize event and resize itself accordingly, and also need to always position itself at the bottom of the window (kind of like a docking pane).
I preferred this method which is simple and straight forward:
Here's how I implemented it (in VB):
Public Class WindowWrapper
Implements System.Windows.Forms.IWin32Window
Private _hwnd As IntPtr
Public Sub New(ByVal handle As IntPtr)
_hwnd = handle
End Sub
Public ReadOnly Property Handle() As IntPtr Implements System.Windows.Forms.IWin32Window.Handle
Get
Return _hwnd
End Get
End Property
End Class
Dim owner As New WindowWrapper(CType(gXLApp.Hwnd, IntPtr))
gfTimeStamp = New FTimeStamp
gfTimeStamp.Show(owner)
Worked great!
Maybe I did not catch the question, but it seems that if you simply set the form's ShowModal property to False, you will get what you want.
I'm going to share what I've found so far. One article in Code Project was very informative, I think this will help me figure out what I need to do over the long run, although it's about Outlook panels integration. I haven't had time to really try and integrate the solution outlined below into my Excel project, but the idea outlined in the article seems solid.
http://www.codeproject.com/KB/office/additional_panel_Outlook.aspx
I'll update my post once I get more information.
精彩评论