C# : Client windows in client windows

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2005
Posts: 2
Reputation: Joe Diamond is an unknown quantity at this point 
Solved Threads: 0
Joe Diamond Joe Diamond is offline Offline
Newbie Poster

C# : Client windows in client windows

 
0
  #1
May 24th, 2005
Hi,

I'm working in C# Windows Forms, with an MDI system. My documents contain several different objects. I want those objects to be shown as dragable windows *inside* the document (MDI client) window, and to be part of that window (ie scroll with it, affect the scroll bars, etc). I've tried to add the windows as children of the MDI client window and I get an error. I've also tried a bunch of other things, none of them work.

Is that possible, or do I have to create several controls to fake it?

I'm not married to the MDI, I just used it to get this to work.... SDI would be fine if I could get #(@!$ child windows to work....

Thanks in advance,

Joe
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 263
Reputation: Toulinwoek is an unknown quantity at this point 
Solved Threads: 2
Toulinwoek's Avatar
Toulinwoek Toulinwoek is offline Offline
Posting Whiz in Training

Re: C# : Client windows in client windows

 
0
  #2
Jun 1st, 2005
Well, Joe, I'm new to C#, and I think it's kinda troubling that no one's responded yet to your query.
Basically, the process you seem to be describing can be implemented by setting the "IsMdiContainer" property of what will be your parent window to TRUE.
Then, you create your child objects normally, and whatever control (button or menu) you use to open an instance of a child object, it should have code similar to the following:

protected void MDIChildNew_Click(object sender, System.EventArgs e){
Form2 newMDIChild = new Form2();
// Set the Parent Form of the Child window.
newMDIChild.MdiParent = this;
// Display the new form.
newMDIChild.Show();
}

"Form2" is the name of the child object. This should cause the child object to exist within the confines of the parent window. My only problem with this concept is the lack of control (as far as I know) over the position of the child objects; they cascade by default, which I would rather they didn't do.

There might be easier ways, but this process has worked for me. Hope this helps!
:!: In The Beginning, God; In The End, God. In between, believe whatever you like. :)
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 2
Reputation: Joe Diamond is an unknown quantity at this point 
Solved Threads: 0
Joe Diamond Joe Diamond is offline Offline
Newbie Poster

Re: C# : Client windows in client windows

 
0
  #3
Jun 2nd, 2005
Dear Toulinwoek, (I'm curious about this name, by the way)

Thanks for your kind reply to my question; I was beginning to wonder if I had some kind of special invisible posting account!!

That said, my question was quite esoteric, so not totally surprised.

The process you describe sets up client windows inside an MDI app. I agree it has its limitations, one of which is that when you use it, it's difficult to put windows inside the MDI client windows - if you try to create a form there then you get an error saying you can't add a top-level form to a child form, or something like that.

Fortunately, after several days of searching, and a lot of people telling me
it couldn't be done (not to mention some unanswered posts), I just found out how to do it, which I include for others struggling with this problem:

Forms.frmTest oMyForm = new Forms.frmTest();
oMyForm.TopLevel=false;
this.Controls.Add(oMyForm);
oMyForm.Show();

This, then, allows a top-level form (ie a window) to be added to another window without an error. The bold line is the crucial one.

In addition, I found the following :

There is setting in Options that is hiding some properties.

Go to Tools->Options->TextEditor->All Languages and Uncheck the Hide
Advanced Members CheckBox. . .

The latter didn't seem to make a difference for me, but might help someone
else.

Thanks again for your kind help on this one - it's good to know there are people out there who answer questions....

Have a good one.

JamesCC
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 263
Reputation: Toulinwoek is an unknown quantity at this point 
Solved Threads: 2
Toulinwoek's Avatar
Toulinwoek Toulinwoek is offline Offline
Posting Whiz in Training

Re: C# : Client windows in client windows

 
0
  #4
Jun 2nd, 2005
Ah, OK. Now I see; I wasn't fully understanding what you were trying to do, so thanks for sharing what you found. I'll add it to my code library right away!
:!: In The Beginning, God; In The End, God. In between, believe whatever you like. :)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC