Solved

SetParent Usercontrol

Posted on 2002-07-12
4
310 Views
Last Modified: 2012-05-04
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
0
Comment
Question by:samsonite1023
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 4

Expert Comment

by:TigerZhao
ID: 7148602
Form1.ShowInTaskbar = False
0
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 396 total points
ID: 7148604
Make the window to Tool Window

Here is the code

Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long


SetWindowLong(UserControl1.hWnd, -20, 128);
SetParent UserControl1.hWnd, GetDesktopWindow
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 7148609
That is here I'm changing the control's extented style to WS_EX_TOOLWINDOW.
Here I tested also.. And works fine

Good Luck
0
 
LVL 1

Author Comment

by:samsonite1023
ID: 7148650
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
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question