Click to See Complete Forum and Search --> : MDI and the active doc


Fletch27278
October 9th, 2001, 11:16 PM
I have a great deal of experience using Visual C++, and this is my first dealing with complex Visual Basic app.

I have a MDI multiple form application that I set up. What I want is to have a MDI Form Mainframe with buttons and then have a document form be maximized in the mainframe. I was going to modify the code so that the application behaved as a SDI, because I really only want one document form open at one time. I choose the MDI application because I wanted all of the documents extra forms to show up with in the Mainframe and always on top of the document form. Crazy?

Questions:
1. Is the MDI application the correct project for this UI? Is this UI possible?
2. I am assuming that the Mainframe should be an MDI form, and that the document should not be. Is this correct? If not, then what should the document be? MDI Child? And what about all of the other forms, how should they be set up?
3. Currently, I am fairly close to accomplishing this, but my problem is whenever I try to address the form Document in code, a new instance of document is created. I think if I could address the current document, then my code would work. Any hints on how to address the active doc form?

TIA,
Scott


C++ Software Engineer
aka: Fletch
Hillsborough, NC

Cakkie
October 10th, 2001, 01:29 AM
First of all, welcome to VB, second of all, you're going in the good direction:

1) Yes, this can be done with that

2) You should make the document window MDI Child, any tool or option windows (or others) that need to be shown as modal must be SDI.

3) You cannot address a MDI Child using Form2 or something like that (okay, you can, let me explain). You probably created an instance of the form using something like Dim frm As New Form2. This results in the form only being accessible via it's refference, which in this case is the frm object. There are however some other ways to get the refference, like using the ActiveForm property of the MDI Parent window. This will give the refference to the MDI Child window that is selected (if any).

Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook

Fletch27278
October 11th, 2001, 09:11 PM
Thanks for the reply. Boy, that is going to make things very difficult. I guess I am just to used to using pointers and being able to gain access to whatever I need. I am really not sure what to do from here. The entire point of having the document in the first place was to have a common place for all of the applications data. If I cannot reliably get a reference to the doc then it is completely useless to me.

Can I basically put all of the document code into the MDI form, because that is referencable from any form in the project?

TIA,
Scott

C++ Software Engineer
aka: Fletch
Hillsborough, NC

Cakkie
October 12th, 2001, 01:23 AM
You just need to make the code public. If you make a sub or function public, you will be able to access the code form everywhere. Also, you can declare the refference (pointer) to the form as public, which allows you to access the form from everywhere.

' Somewhere in a module
public frmDoc as frmMainDocument
'
' somewhere else where the program starts, or where the document is opened
set frmDoc = new frmMainDocument
'
' Again somewhere else
frmDoc.SaveFileToDisk("c:\test.txt")
'
' in the frmMainDocument
public Sub SaveFileToDisk(strPath as string)
Dim FFile as integer
FFile = FreeFile
Open strPath for Output as #FFile
print #FFile, txtOutput.Text
Close #FFile
End Sub





Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook