Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

excel

vsto

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).

like image 365
code4life Avatar asked Mar 31 '10 13:03

code4life


2 Answers

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!

like image 101
Jon49 Avatar answered Oct 24 '22 23:10

Jon49


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.

like image 35
iDevlop Avatar answered Oct 24 '22 22:10

iDevlop