Creating my own TaskPane

L

Lorenz H?lscher

Hi everyone,

in Nov. 2002 I found a very good idea to connect a (modeless?!) form
to a dockable commandbar which might behave very much like an own task
pane.

Unfortunately it wont work until now with this code:

Module_______________________________________________________________
Declare Function FindWindowEx Lib "user32" _
Alias "FindWindowExA" (ByVal hwndParent As _
Long, ByVal hwndChildAfter As Long, ByVal _
lpszClass As String, ByVal lpszWindow As _
String) As Long

Public Declare Function SetParent Lib "user32" (ByVal _
hWndChild As Long, ByVal hWndNewParent As Long) _
As Long

Declare Function SetActiveWindow Lib "user32.dll" _
(ByVal hwnd As Long) As Long

Sub StarteDock()
UserForm1.Show vbModeless
End Sub
_______________________________________________________________


UserForm_______________________________________________________________
Private Sub UserForm_Initialize()
Dim cmd As CommandBar
Dim x As Long, y As Long, z As Long

On Error Resume Next
ActiveDocument.CommandBars("A_TaskPane").Delete
On Error GoTo 0

Set cmd = ActiveDocument.CommandBars.Add("A_TaskPane",
msoBarRight, True)
With cmd
.Controls.Add msoControlButton
.Controls(1).Width = Me.Width
.Controls(1).Height = Me.Height
.Controls(1).Enabled = True
.Enabled = True
.Visible = True
End With

'Get the handle of the userform
x = FindWindowEx(0&, 0&, "ThunderDFrame", Me.Caption)
'Get the handle of the active window
z = FindWindowEx(0&, 0&, "OpusApp", ActiveWindow.Caption & " -
Microsoft Word")
'Get the handle of the "MsoDockRight" command bar
y = FindWindowEx(z, 0&, "MsoCommandBarDock", "MsoDockRight")

SetParent x, y
' SetActiveWindow y
End Sub
_______________________________________________________________

When I start that with "StarteDock" I see the commandbar but no
Userform. Does anyone see the error?

Thanks for your help,

Lorenz




The original thread was:
http://groups.google.de/groups?hl=d...askpane*+top&hl=de&lr=&ie=UTF-8&start=10&sa=N
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top