Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++/CLI
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! Smile | :)
 
Mick White
Posted 12-May-11 4:33am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
SAKryukov at 12-May-11 23:15pm
   
Hardly feasible indeed, my 5.
Please see my solution for acceptable variants of design.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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.
  Permalink  
Comments
LRonHorse at 12-May-11 12:52pm
   
Hi
Thanks 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.
Cheers
Henry Minute at 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 at 12-May-11 14:27pm
   
OK - thanks for that. I'll have a look at some of code and see if it's useful.
SAKryukov at 12-May-11 23:14pm
   
You're right, my 5.
Please see my solution for acceptable variants of design.
--SA
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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.
 
—SA
  Permalink  
v2
Comments
LRonHorse at 13-May-11 5:49am
   
Thank you SA - I'll investigate what you say.
SAKryukov at 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).
--SA

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

  Print Answers RSS
0 mhegazy94 460
1 Sergey Alexandrovich Kryukov 450
2 Kornfeld Eliyahu Peter 305
3 Ravi Bhavnani 200
4 Shemeemsha RA 160
0 Sergey Alexandrovich Kryukov 6,890
1 OriginalGriff 6,761
2 CPallini 5,350
3 George Jonsson 3,609
4 Gihan Liyanage 2,797


Advertise | Privacy | Mobile
Web03 | 2.8.140922.1 | Last Updated 13 May 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100