Click here to Skip to main content
15,882,152 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there
I'm writing a genealogy application using visual studio 2005 and C++ and I want to draw lines between mdi child forms.
Can anyone suggest a good place to start? If there's something written in C# then I may be able to use that but c++ would be preferable.
I have the basics working at the moment - I create small child forms - and display them individually. Clicking on a child form displays information on a side bar etc.
I now need some help to draw lines between the child forms so that, if possible, when they're moved around the lines stay attached.

I'm a newbie here so please be gentle! :)

Mick White

Hmmm, I'm not sure if you design is feasible. You want to use child form for each family? or each person? Think how many child forms you will end up creating.

I think what you need is a custom control that mimics the behaviors of your child form. That with 'lil graphics work you should be on your way

just my 2cents.
Share this answer
Sergey Alexandrovich Kryukov 12-May-11 23:15pm    
Hardly feasible indeed, my 5.
Please see my solution for acceptable variants of design.
IMO you are making life harder for yourself than it needs to be by using MDI and Child Forms.

If your application is the 'standard' genealogy type then it is very similar to a UML, Class Diagram or Organization Chart application, just the information contained in the 'boxes' will be different.

Might I suggest that you search for Open Source versions of any of that type of program. e.g. StarUML[^] (there are loads more out there).

Have a look at a few to see how they do it and pick the bits that make the most sense to you.
Share this answer
LRonHorse 12-May-11 12:52pm    
HiThanks for your comments but all I'm looking to do at the moment is a very lightweight genealogy tool so something like a UML tool is a bit more than I need.
All I really need to do at the moment is connect the child forms with lines to show linkages like husband/wife parent/child etc. If I can just find out how to do this with in the parent form then that should be sufficient for the moment.
If you have any good ideas as to how to go about this I would be extremely grateful.
Henry Minute 12-May-11 13:04pm    
I have never tried drawing on the background of an MDI parent, so I can't give you any specifics on that. However, the way that the type of program I suggested earlier draw their connecting lines will be pretty much the same as you will need for your app. So once again I would suggest that you take a look at a couple of them for ideas.
LRonHorse 12-May-11 14:27pm    
OK - thanks for that. I'll have a look at some of code and see if it's useful.
Sergey Alexandrovich Kryukov 12-May-11 23:14pm    
You're right, my 5.
Please see my solution for acceptable variants of design.
This design is a very common mistake. In principle, it may be even feasible, but I knew so many attempts to complete the application or component base on similar (actually a bit better) ideas — all failed.

There are two approaches which work. In both cases, you should not use any controls (not even windows or forms) as graphics elements. Maybe it seems to you they already have intrinsic functionality you need, but this is wrong. Just the opposite, they have functionality which will make you lost on unneeded complexity.

1) Use light-weight approach. Create all graphics primitive in one control. You need to render all graphics in the handler of Control.Paint of overridden method Control.OnPaint. For rendering, use the instance of System.Drawing.Graphics supplied in the event arguments parameter (in both cases). To change image, use Control.Invalidate. For better performance, use Control.Invalidate with a parameter (Rectangle or Region), to invalidate just a part of the scene.

2) Use WPF. You don't need to do any rendering at all. Instead, you should use Canvas and put graphical primitives (such as lines, rectangles, etc., but you can put controls as well) on the canvas. This is really simple. You can even draw primitives in a vector editor, import vector graphics as XAML, put the saved XAML code to resource dictionary and reuse on your canvas. I recommend using wonderful Open Source editor InkScape.

Final note. There are no situations when MDI can be used. This is one of the most unsuccessful inventions my Microsoft. MDI is strongly discourages even by Microsoft. There are no solid software products or even products with acceptable quality using MDI. You would simply scare off your customers if you use it. The simplest nice alternative is tabbed interface, based on TabControl.

Share this answer
LRonHorse 13-May-11 5:49am    
Thank you SA - I'll investigate what you say.
Sergey Alexandrovich Kryukov 13-May-11 6:48am    
Not too much to investigate -- you certainly should use one of those ways and not hope that your way is solvable -- it's not.
If you find this information useful, please formally accept this answer (green button).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900