473,399 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

problem with mdi children

5
Hi community,

i want to create simple MDI application but ths child forms should be in a special order of visibility or layer.
For example: if a child form has layer 0 it is always top most of all other child forms. A child form with layer 1 is behind a child form with layer 0 but in front of a childform with layer 2 and so on...

Does anybody know a simply solution?

Thanks
Jul 16 '09 #1
7 2609
cloud255
427 Expert 256MB
Hi

Well if you have several forms of each layer I would suggest using a 2 dimensional array.

You can then order the array to ensure that the display order of the layer is preserved and place forms of each layer in the corresponding 'row' of the array.

You could then create a function to loop the array drawing the last entry of the bottom most layer first and working your way up. By attaching a 'layer' property to each of your child forms and calling the display/sort functions you will ensure that children are always displayed in the correct order.

Hope this helps
Jul 16 '09 #2
KlausW
5
First thanks for your post cloud255.

When i create a child form i want to put the form in a layer till i close the form.
How could i tell the child form to be in layer 2 or layer 5?
There could be several child forms in the same layer, then they behave like normal child forms - the focused (or activated) form is in front of the other form.
Jul 16 '09 #3
cloud255
427 Expert 256MB
@KlausW
My apologies, but I will change my suggestion to using a List<LinkedList<>> instead of a 2 dimensional array. The concept is still pretty much the same, it will just be easier to implement.

You will have to create a struct or class which has a 'layer' property, you will use this property to assign a form to the appropriate part of the List:

Expand|Select|Wrap|Line Numbers
  1. //MyChildObject is a custom class/struct which has an integer property 'layer'
  2.  
  3. List<LinkedList<MyChildObject>> Layers;  //List of layers
  4.  
  5. LinkedList<MyChildObject> Children; //list of children in each layer
  6.  
  7. private void CreateNewChild(MyChildObject newChild)
  8. {
  9.        Layers[newChild.layer].AddFirst(newChild); //This adds the new child object to the correct layer and in the first position
  10. }
  11.  
Moving the selected child to the front can be done using the AddFirst method and then deleting the 'old' entry from the linked list using the FindLast method of the linked list.

The structure of List<LinkedList<>> will look something like this:

XXX
XXXXXXXX
XX
XXXXXXXXX
XXXXX
X
XXXXXXXXXXXX

If you are unfamiliar with the list and linkedlist data structures, see the below links:
List
LinkedList Class
Linked list concept

Please feel free to post if you are uncertain of anything.
Jul 16 '09 #4
KlausW
5
I'm familiar with List and LinkedList, that's not the problem.

Imagine the scenario:

If i have three child forms:
one with layer 2 (called form2)
one with layer 4 (called form4)
one with layer 6 (called form6)

all three have the same size and do not overlap each other at he begin.
example 1:
then i move form2 over form4 -> form2 will be in front of the form4. if i move form4 it should be behind form2.
example 2:
if i move form4 "over" form2 it will be behind form2, but if i move form4 over form6 it should be in front of form6. form6 is always behind form4 and form2

It does not depend on moving the form, getting the focus should make the same effect.
Jul 16 '09 #5
cloud255
427 Expert 256MB
Ok so you want the lowest number level to have focus i.e. layer 2 will have focus if no layer 0 or 1 children exist?

If that is the case you could simply set focus to the first element in the linked list of the at list[2] (a better way would be to loop through the list until you find an element that is not null instead of using an index value).
But this will result in the other children from layer 2 possibly being stacked behind some of the the higher layer children. This too can be avoided by looping through the linked list, starting at the back, and setting focus to child in the linked list. Thus the first node in the linked list at the lowest index of the list will always have focus have focus...
Jul 16 '09 #6
KlausW
5
Thanks for your participation to discuss this problem.

But i only want to "lay" the child forms with different layers in the correct visibility inside of the mdi parent.
Jul 17 '09 #7
KlausW
5
example for the visibility of child forms (but this is not mdi :-( ):

Expand|Select|Wrap|Line Numbers
  1. public partial class MDIParent1 : Form
  2. {
  3.  
  4.         private void ShowNewForm(object sender, EventArgs e)
  5.         {
  6.             Form f2 = new Form();
  7.             f2.ShowInTaskbar = false;
  8.             f2.Text = "Layer2";
  9.  
  10.             Form f1 = new Form();
  11.             f1.ShowInTaskbar = false;
  12.             f1.Text = "Layer1";
  13.  
  14.             Form f0 = new Form();
  15.             f0.ShowInTaskbar = false;
  16.             f0.Text = "Layer0";
  17.  
  18.             f0.Owner = f1;
  19.             f1.Owner = f2;
  20.             f2.Owner = this; 
  21.  
  22.             f0.Show();
  23.             f1.Show();
  24.             f2.Show();
  25.         }
  26.  
  27. ....
  28. }
Jul 17 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: David Fraser | last post by:
Hi We are trying to debug a problem with services created using py2exe. It seems that these problems have arisen after services were installed and removed a few times. OK, first the actual...
2
by: Thomas Baier | last post by:
Hi there, I've got a class with an array of pointers to objects of the same class. I thought of doing it like that: class test { test **array_var; ... }; void method::test(test object) {
2
by: veganeater | last post by:
Hello again everyone, I seem to have run into another problem... perhaps I'm just a bit slow. The problem is something like this: I have a popup window launched by a page sourced in an iFrame ...
10
by: gregbacchus | last post by:
Can someone please help me and tell my why the following code is not working, and hopefully how to get it working? What I am trying to do is make a serialization surrogate that stores, amongst...
6
by: Hendrik Schober | last post by:
Hi, I have a problem with extending some existing code. In a simplified form, the problem looks like this: I have four types, A, B, C, and D. Each A refers to zero, one, or more B's and each...
2
by: Nicholas Sherlock | last post by:
Hey all, I wrote a class to represent a node in a site navigation tree which contains methods for building the tree from the database. I also wrote some routines to print out the whole tree,...
8
by: BD | last post by:
Moving from MS Access to .Net using C# languag. Problem trying to duplicate form with structure as follows: 1. Main form 'Work Order' displayed as textboxes 2. subform 'Customers' textboxes...
8
by: Chris Noble | last post by:
I need to check whether a particular user is already a member of an Active Directory Security Group. The following code extract works but only if the user distinguished name is exactly the same...
15
by: vivekian | last post by:
Hi, I have this following class class nodeInfo ; class childInfo { public: int relativeMeshId ;
3
by: Gustaf | last post by:
I'm working on an object model that will represent trees of products, where one product may contain others (components of a product). Each product needs to keep track of its parent and child...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.