I'm trying to launch Acrobat Reader inside a child form of my application (specifically inside a frame on that form). The external program fires up OK but it's not inside my child form (which sits empty behind Acrobat Reader and has to be closed separately after I close Reader).

If I understood better the code I'm using (it was just cut and pasted from somewhere I forget!) I could sort this myself but I don't unfortunately. Anyone any ideas?

Here is the code I'm using:

VB Code:
  1. Option Explicit
  2.  
  3. Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, _
  4. ByVal hWndNewParent As Long) As Long
  5.  
  6. Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, _
  7. lpRect As RECT) As Long
  8.  
  9. Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, _
  10. ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, _
  11. ByVal bRepaint As Long) As Long
  12.  
  13. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, _
  14. ByVal lpWindowName As String) As Long
  15.  
  16. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, _
  17. ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, _
  18. ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
  19.  
  20. Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
  21.  
  22. Private Type RECT
  23. Left As Long
  24. Top As Long
  25. Right As Long
  26. Bottom As Long
  27. End Type
  28.  
  29. Private lngGetApp As Long
  30.  
  31. Private Sub Form_Unload(Cancel As Integer)
  32.   DestroyWindow lngGetApp
  33. End Sub
  34.  
  35. Private Sub Form_Load()
  36.  
  37.   Dim RectCoord As RECT
  38.   Dim lr As Long
  39.  
  40.   lr = ShellExecute(Frame1.hwnd, "Open", FileToLoad, "", "", vbNormalFocus)
  41.   If (lr < 0) Or (lr > 32) Then
  42.   ' success '
  43.   Else
  44.     MsgBox "Failed to start '" & FileToLoad & "'", vbInformation
  45.   End If
  46.  
  47.   lngGetApp = FindWindow(vbNullString, "Beat Dyslexia/EV guide")
  48.   SetParent lngGetApp, Frame1.hwnd
  49.  
  50.   GetClientRect Frame1.hwnd, RectCoord
  51.   MoveWindow lngGetApp, 0, 0, RectCoord.Right - RectCoord.Left, RectCoord.Bottom - RectCoord.Top, True
  52.  
  53. End Sub