Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SetParent Usercontrol

Posted on 2002-07-12
4
Medium Priority
?
320 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 1584 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

618 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