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:
Option Explicit Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, _ ByVal hWndNewParent As Long) As Long Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, _ lpRect As RECT) As Long Private Declare Function MoveWindow Lib "user32" (ByVal hwnd As Long, _ ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, _ ByVal bRepaint As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, _ ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, _ ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End Type Private lngGetApp As Long Private Sub Form_Unload(Cancel As Integer) DestroyWindow lngGetApp End Sub Private Sub Form_Load() Dim RectCoord As RECT Dim lr As Long lr = ShellExecute(Frame1.hwnd, "Open", FileToLoad, "", "", vbNormalFocus) If (lr < 0) Or (lr > 32) Then ' success ' Else MsgBox "Failed to start '" & FileToLoad & "'", vbInformation End If lngGetApp = FindWindow(vbNullString, "Beat Dyslexia/EV guide") SetParent lngGetApp, Frame1.hwnd GetClientRect Frame1.hwnd, RectCoord MoveWindow lngGetApp, 0, 0, RectCoord.Right - RectCoord.Left, RectCoord.Bottom - RectCoord.Top, True End Sub




Reply With Quote