Link to home
Start Free TrialLog in
Avatar of samsonite1023
samsonite1023

asked on

SetParent Usercontrol

I am trying to make a usercontrol that will go on the desktop, via the "SetParent" API call.

However, there is one minor problem.  Here is the slimmed down code:

(project with a usercontrol)

In the usercontrol there is this:

Private Declare Function WindowFromDC Lib "user32" (ByVal hdc As Long) As Long


Public Function hWnd() as long
    hWnd = WindowFromDC usercontrol.hDC
End Function



Now, in a form with UserControl1 (and a command button), there is this:

Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long

Private Sub Command1_Click()
    SetParent UserControl1.hWnd, GetDesktopWindow
End Sub



This works fine, UserControl1 goes onto the desktop.  However, it adds a button to the taskbar.  How can I stop it from putting this button there?

-Sam
Avatar of TigerZhao
TigerZhao

Form1.ShowInTaskbar = False
ASKER CERTIFIED SOLUTION
Avatar of Roshan Davis
Roshan Davis
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That is here I'm changing the control's extented style to WS_EX_TOOLWINDOW.
Here I tested also.. And works fine

Good Luck
Avatar of samsonite1023

ASKER

Thanks!  Man, I tried using the SetWindowLong stuff, and it didn't work for me.  I guess I was using the wrong constants.

Your code works fine, though.

Thanks a ton!

-Sam