Solved

SetParent Usercontrol

Posted on 2002-07-12
4
306 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bit defender blocks good applications 2 106
Sending a email via excel using vba 6 109
vb6 connector to mongodb 2 141
Export Data to Different .csv Files 26 121
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

733 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