|
-
Sep 29th, 2000, 12:01 PM
#3
Fanatic Member
True enough indeed. But if there is a setting which chooses whether you use an SDI version of a form or an MDI version of a form though you have to keep 2 copies of each form, you can choose to have either at run time (you have to reload the project ...) The only forms you mess with are the MDI Children. Here is some sample code that I slopped together to show you what I mean.
Start a New Project.
Add Another Form (Form2)
Add An MDIForm (MdiForm1)
Set Form1's MDIChild to True.
Set the project to run with the MDIForm1.
Add a Menu to MDIForm1, Name it Test, Set it's caption to Test.
Add a Picturebox to MDIForm1 (Picture1)
Place the following code in the MDIForm1:
Code:
Dim Choice As Boolean
Private Sub MDIForm_Load()
Dim Temp As String
Temp = InputBox("SDI or MDI?", , "MDI")
If Temp = "SDI" Then
Choice = True
Me.Height = 0 + (Picture1.Height * 2) - 90
Else
Choice = False
End If
End Sub
Private Sub MDIForm_Resize()
If Choice = True Then
If Me.WindowState > 1 Then
Me.WindowState = 0
Me.Top = 0
Me.Left = 0
Me.Width = Screen.Width
Exit Sub
End If
If Me.Height <> 0 + (Picture1.Height * 2) - 90 And _
Me.WindowState < 1 Then
Me.Height = 0 + (Picture1.Height * 2) - 90
End If
End If
End Sub
Private Sub test_Click()
If Choice = True Then
Dim FormSDI As New Form2
Set FormSDI = New Form2
FormSDI.Show
Else
Dim FormMDI As New Form1
Set FormMDI = New Form1
FormMDI.Show
End If
End Sub
Place this Code in the form load event of Form1 & Form2:
Code:
Private Sub Form_Load()
MsgBox "I have been loaded"
End Sub
When you start up the project, you are asked to choose either MDI or SDI. If you use the default of MDI, everytime you hit the test button, you reieve the message "I have been loaded" and when you click ok, the form displays in the MDI parent area.
If you choose SDI (by typing it in), you will recieve a 'minimized' mdi form, which is just the height of the titlebar, picturebox, and menu. If you try to resize the window, it snaps back to that height. If you hit maximize, it moves to the top of the screen and changes it's width to match the screen width, you are still unable to resize it. If you hit minimize, it will minimize to the tray. If you click on test, Form2 displays as an SDI window. You can set this to vbModal if you wish ...
As you can see, the idea is possible, you just need to change the inputbox to a setting (from the registry, ini file, or whatnot, possibly even a menu item). You keep MDIForm as the main form, you just swap to a new Form style.
Hope this clears that up.
-Excalibur
[Edited by ExcalibursZone on 09-29-2000 at 01:37 PM]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|