Floating userform appears on task bar???

R

Robert Crandal

I am creating a special floating type of Userform using the
code and declarations below:

--------------------------------------------------------------------------------
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" ( _
ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetWindowLongA Lib "user32" _
(ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

Private Const GWL_HWNDPARENT As Long = -8

Private Sub UserForm_Initialize()
Dim hWnd As Long
hWnd = FindWindow("ThunderDFrame", Me.Caption)
SetWindowLongA hWnd, GWL_HWNDPARENT, 0&
End Sub
-------------------------------------------------------------------------------

Then I load the form using the following call:

UserForm1.Show vbModeless

I like how this code works, but I really hate the fact that my floating
Userform
gets displayed in the Windows taskbar along with other running applications.
Is there any way to change the code above so that my Userform dialog box
doesnt show up in the taskbar??

Thank you!
 
R

Robert Crandal

I wasnt really concerned about the position on the screen. I was wondering
about setting a property that prevents the Userform from having
an associated icon on the taskbar. Most dialog boxes do not appear in the
taskbar which allows the user to switch back to it..... I was wondering
if I could create my userform like that?
 
J

Jon Peltier

You don't need to call SetWindowLong when showing a form modelessly.
SetWindowLong in this case is changing the parent of the modeless form
from the Excel window to (I think) the desktop window, meaning it will
then show up on the taskbar.

Remove the SetWindowLong call, and your problem will go away.

- Jon
 
R

Robert Crandal

That almost worked. You see, whenever someone minimizes the
Excel application I want my popup Userform to remain visible
on the screen. If I remove the call to "SetWindowLong", then
my Userform will get minimized as well.

So.... I guess my problem is two-fold. I want a popup Userform
that does the following:

1) Remains visible when Excel is minimized

AND

2) The popup form must not create an additional "switch to" icon
for itself on the task bar.

Do you know if a Userform can have both of these properties??

thank you
 
R

Rob van Gelder

It sounds to me like you want complete detachment.

You could write an external winforms app, and execute it via shell or dll calls.
The trouble might be in returning data from the form back to Excel.
 

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