Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

One window, multiple forms/views: SDI or MDI?

Status
Not open for further replies.

j0em0mma

Programmer
Jul 31, 2003
131
US
I am web developer trying to get win32 windows forms working. I have a simle structure with a main form with my menu and content forms with only a button to "return to main menu." First, my forms open in new windows, instead of the same as main. I only want one window and one form open at a time (though I wouldn't mind having a parent form that loads all the content forms, especially for state control). I've been looking around, and the only other clear-cut info I can find discusses MDI - Multiple document Interface. But this is not what I need. I only want to display one form at a time. Can anyone get me started here? Maybe point me to a good resource? (please, not MSDN reference material, I need a thorough explanation and maybe a sample project). Thank you, very much, in advance!
 
so you want to have a main menu form that opens a second form and at the same time the main menu form should close or turn invisible(hint)?

Christiaan Baes
Belgium

"My new site" - Me
 
yep, I see where you're going... To a web developer this seems really screwy, but if this is how it's done...?
 
The other problem I see with this is a whole lot of mechanism required to maintain the sizes and positions of all of these forms. to the user, it should appear to be only one window. That means that if they move any visible form, I'd need code to move the location of all invisible forms, right? And if they resize any visible form, than I need a mechanism to resize all invisible forms, correct?
 
yep. Or you could create a forms in form application. No not MDI.

you just create your first form with a panel on it then add a second form to the controls collection of that panel. you can turn of the borders and everything else of on the second form so that i doesnt look like a form more like a panel with the advantage that you can develop it much eassier.

Code:
dim frm2 as new form2
frm2.toplevel =false
panel1.controls.add(frm2)
frm2.show

Christiaan Baes
Belgium

"My new site" - Me
 
Ah, that's what I'm looking for! Terminology is everything... panels!

Thank you Christiaan!
 
chrissie you didn't you didn't post your genius trick:


Code:
	Private WithEvents f2 As Form2
	Private WithEvents f3 As Form3

	Private Sub Form2ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Form2ToolStripMenuItem.Click

		MenuStrip1.Enabled = False
		f2 = New Form2
		f2.TopLevel = False
		f2.FormBorderStyle = Windows.Forms.FormBorderStyle.None
		f2.Dock = DockStyle.Fill
		Me.Controls.Add(f2)
		f2.Show()

	End Sub

	Private Sub Form3ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Form3ToolStripMenuItem.Click

		MenuStrip1.Enabled = False
		f3 = New Form3
		f3.TopLevel = False
		f3.FormBorderStyle = Windows.Forms.FormBorderStyle.None
		f3.Dock = DockStyle.Fill
		Me.Controls.Add(f3)
		f3.Show()

	End Sub

	Private Sub f2_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles f2.FormClosed

		Me.Controls.Remove(f2)
		MenuStrip1.Enabled = True

	End Sub

	Private Sub f3_ForeColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles f3.ForeColorChanged

		Me.Controls.Remove(f3)
		MenuStrip1.Enabled = True

	End Sub

Not forgetting to make sure that each form (form2 and form3) has a button or something to close it.


Hope this helps.

[vampire][bat]
 
chrissie that's the second time today you haven't given me chance to reply [smile]. I've just spotted your second post.



[vampire][bat]
 
I'm slow, I'm getting old. Even you are faster then me now.
I like the sound of stars swooshing by.

Christiaan Baes
Belgium

"My new site" - Me
 
>> I'm getting old.
at this age? Life begins at 40. You have lots of years to reach there.[wink] then to get old...

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
Then you can re-start counting at the next world.

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
Do it now.. What if you don't get a chance later...

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top