TIP: Click on subject to list as thread! ANSI
echo: visual_basic
to: All
from: Jennifer
date: 2004-06-18 16:51:00
subject: Open File as `child` in `

Hello -

Using VB6.0, I am attempting to build an application which has a
"parent" window with any number of "child" windows that
are opened
internal to the "parent" window.  I want to use common dialog to find
the file name and then open the file in the default application (i.e.,
..doc files in word, .pdf files in adobe).  But, the kicker is that I
want the default application to launch internal to the parent window. 
Is this even possible?  I've tried to code something to do this (see
below), but have only been able to get the default application to
launch in a separate window when I'm not using a MDI.  When I try to
use the same code with a MDI, I get an error stating that I can't have
multiple MDIs.

Any help is appreciated.  Please don't take any of my knowledge for
granted. It's my first week of working with VB, so I'm still learning
the ropes.

Option Explicit

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
     
Public Sub OpenFile()
On Error GoTo OpenErrHandle

Dim RetVal As Long
Const SW_SHOWNORMAL = 1
    
With fMain.FileHandleCMD
'With frmMain.dlgCommonDialog
    .DialogTitle = "Open..."
  
' Go to ErrHandle if the cancel button is pressed by the user
    .CancelError = True
    
' We can add more file types when we know what types of documents are
needed
    .Filter = "All Files (*.*)|*.*|" & _
              "Word Documents (*.doc)|*.doc|" & _
              "PDF Files (*.pdf)|*.pdf|" & _
              "Web Pages (*.htm,*.html)|*.htm;*.html|" & _
              "Text Files (*.txt)|*.txt"
              
' Specify default filter as "All Files"
    .FilterIndex = 1
    
' Set the initial directory
    .InitDir = "c:\"
    
' Display the open dialog box
    .ShowOpen
            
' Open the selected file in a new window
    RetVal = ShellExecute(1, "open", .FileName, vbNullString,
vbNullString, SW_SHOWNORMAL)
End With

Exit Sub

OpenErrHandle:
    Select Case Err.Number
        Case 32755
           Exit Sub     ' cancel button selected, exit sub
           
        Case Else
            MsgBox "An error has occurred that may cause the
application not to function." & _
            " Listed below is a description of the error." &
vbCrLf &
vbCrLf & _
            "Error Number : " & Err.Number & vbCrLf & _
            "Description : " & Err.Description,
vbExclamation, "Error
" & Err.Number
    End Select

End Sub
---
þ RIMEGate(tm)/RGXPost V1.14 at BBSWORLD * Info{at}bbsworld.com

---
 * RIMEGate(tm)V10.2áÿ* RelayNet(tm) NNTP Gateway * MoonDog BBS
 * RgateImp.MoonDog.BBS at 6/18/04 4:51:30 PM
* Origin: MoonDog BBS, Brooklyn,NY, 718 692-2498, 1:278/230 (1:278/230)
SEEN-BY: 633/267 270
@PATH: 278/230 10/345 106/1 2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.