E' impossibile non trovare niente su google per la SetParent ... a me sono arrivati 320.000 risultati per setparent ... !
A meno di non cercare ...
codice:
Private Const GW_HWNDNEXT = 2
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Function PidTohWnd(ByVal pid As Long) As Long
Dim ckH As Long
Dim ckThr As Long
Dim ckPid As Long
ckH = FindWindow(ByVal 0&, ByVal 0&)
Do While ckH
If GetParent(ckH) = 0 Then
ckThr = GetWindowThreadProcessId(ckH, ckPid)
If ckPid = pid Then
PidTohWnd = ckH
Exit Do
End If
End If
ckH = GetWindow(ckH, GW_HWNDNEXT)
Loop
End Function
Private Sub Form_Load()
Call SetParent(PidTohWnd(Shell("calc.exe", vbNormalFocus)), Me.hwnd)
End Sub