TIP: Click on subject to list as thread! ANSI
echo: visual_basic
to: All
from: Randy Birch
date: 2004-06-18 21:44:00
subject: Re: Open File as `child`

That error is generated when you attempt to load a second copy of the MDI 
parent window because you've used the form name (eg MDIForm1) directly in 
code. The cause is the syntax:

dim f as form
set f = new MDIForm1 'or your MDI parent name
f.show

.... to show the MDI parent.  Don't do this ... instead use:

MDIForm1.Show

Now you can reference MDIForm1 to your hearts content and not get the error. 
You would use the former syntax to load the MDI child windows, but once you 
use this syntax to load the form YOU CAN NEVER REFER TO THE FORM BY ITS 
NAME. Doing so loads a copy of the form (hidden) and the actions you attempt 
to take place on the referenced form will occur on the hidden form. If you 
use the Dim f as Form / Set syntax, you must either keep track of the forms 
in your own array, use the built-in Forms collection to access a form, or 
use the ActiveForm property to address the child form currently having 
focus.

-- 

Randy Birch
MVP Visual Basic
http://vbnet.mvps.org/
Please respond only to the newsgroups so all can benefit.


"Jennifer"  wrote in message 
news:7ada0732.0406180735.58270bcf{at}posting.google.com...
: Hello -
:
: Working in VB6.0 I am attempting to open a file with its default
: application in a MDI.  In other words, I am trying to develop a
: "parent" window which holds all of the "child" windows of my
: application.  Currently I am using the openfile dialog to retrieve a
: filename and then I am trying to open the selected file in its default
: application (e.g., .doc with Word and .pdf with Adobe), where the
: default application opens within my parent window.  Is this possible?
: And, if it is, how do I accomplish this?
:
: I can get a chosen file to open with the default application in a
: separate window (see below).  But when I try to take this same code
: and call it within a project set up with a MDI, I get an error that I
: cannot have multiple MDIs.
: Is there a way to fix this problem?
:
: All advice is appreciated.  Please don't take my knowledge for
: granted, as this is my first week working in basic.  Thanks in
: advance.
:
: 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 9:44:31 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™.