SetParent and related API not working
Posted on 2004-09-04
This used to be easy stuff back in my VB6 days.. Setting forms as a child of the desktop or whatever I wanted, but I can't get it to work in VB.NET.
Basically, I want to set Winamp as a child of the desktop window (when I press the Show Desktop button, Winamp and whatever else is a child of the desktop won't hide). Using Spy++, I've determined that Winamp's caption is "Main window" and its class is "BaseWindow_RootWnd".
At this point, I can't even set my own forms as a child of the desktop.. I'm using the following code (just testing, that's why it's ugly):
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim blah As Long = FindWindow("Progman", vbNullString)