Need to place a floating modeless form over excel main window (quasi-task pane)

大憨熊 提交于 2019-12-10 13:42:12

问题


Hi I need to emulate a task pane by floating a modeless form over the Excel main window. The reason for this requirement is that 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).


回答1:


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.




回答2:


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!




回答3:


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.



来源:https://stackoverflow.com/questions/2553362/need-to-place-a-floating-modeless-form-over-excel-main-window-quasi-task-pane

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!