Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Drawing line conneting two dialogs

Drawing line conneting two dialogs

Scheduled Pinned Locked Moved C / C++ / MFC
comgraphicshelptutorialquestion
10 Posts 4 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Crercio O Silva
    wrote on last edited by
    #1

    Hi, Does anyone have any idea how to create a line connecting two modeless dialogs, like in MSAccess relationship editor? I could create the dialogs inside a CWnd or CView derived class and even the drag and drop support is enable between the two dialogs (which holds a CListBox control), but I couldn't figure out how to create (or draw) the line connecting them. Any help or lights on these would be really nice. Thanks, Crercio O. Silva / DBTools Development http://www.dbtools.com.br

    N S M 3 Replies Last reply
    0
    • C Crercio O Silva

      Hi, Does anyone have any idea how to create a line connecting two modeless dialogs, like in MSAccess relationship editor? I could create the dialogs inside a CWnd or CView derived class and even the drag and drop support is enable between the two dialogs (which holds a CListBox control), but I couldn't figure out how to create (or draw) the line connecting them. Any help or lights on these would be really nice. Thanks, Crercio O. Silva / DBTools Development http://www.dbtools.com.br

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      I suppose you could pick an arbitrary set of points (say half the height of both dialogs) and then use the DrawLine method in GDI. :) Nick Parker
      May your glass be ever full. May the roof over your head be always strong. And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing


      C 1 Reply Last reply
      0
      • C Crercio O Silva

        Hi, Does anyone have any idea how to create a line connecting two modeless dialogs, like in MSAccess relationship editor? I could create the dialogs inside a CWnd or CView derived class and even the drag and drop support is enable between the two dialogs (which holds a CListBox control), but I couldn't figure out how to create (or draw) the line connecting them. Any help or lights on these would be really nice. Thanks, Crercio O. Silva / DBTools Development http://www.dbtools.com.br

        S Offline
        S Offline
        Scott H Settlemier
        wrote on last edited by
        #3

        I'm not familiar with the relationship editor, but I would guess that the windows twixt which the line is drawn are not top level windows (modeless dialogs), but rather child windows of some container and it is on the container window that the line is drawn.

        C 1 Reply Last reply
        0
        • C Crercio O Silva

          Hi, Does anyone have any idea how to create a line connecting two modeless dialogs, like in MSAccess relationship editor? I could create the dialogs inside a CWnd or CView derived class and even the drag and drop support is enable between the two dialogs (which holds a CListBox control), but I couldn't figure out how to create (or draw) the line connecting them. Any help or lights on these would be really nice. Thanks, Crercio O. Silva / DBTools Development http://www.dbtools.com.br

          M Offline
          M Offline
          Maximilien
          wrote on last edited by
          #4

          CDC::MoveTo and CDC::LineTO ? I think the problem you might have is how to handle the action itself, how to click ( somewhere ), then drag the mouse ( to draw the line ), and release ( to finalize the connection ) I'd do it by hand, and handle the WM_MOUSEMOVE, WM_LBUTTONDOWN and WM_LBUTTONUP of the modeless dialogs; on the WM_LBUTTONDOWN, "anchor" the starting point, and on the mouse move, draw the line from the anchor to the current point, and on the WM_LBUTTONUP, process the connection by fetching which dialog is the "target" and which is the source, and drawing the line from the closest border. Max.

          C 1 Reply Last reply
          0
          • M Maximilien

            CDC::MoveTo and CDC::LineTO ? I think the problem you might have is how to handle the action itself, how to click ( somewhere ), then drag the mouse ( to draw the line ), and release ( to finalize the connection ) I'd do it by hand, and handle the WM_MOUSEMOVE, WM_LBUTTONDOWN and WM_LBUTTONUP of the modeless dialogs; on the WM_LBUTTONDOWN, "anchor" the starting point, and on the mouse move, draw the line from the anchor to the current point, and on the WM_LBUTTONUP, process the connection by fetching which dialog is the "target" and which is the source, and drawing the line from the closest border. Max.

            C Offline
            C Offline
            Crercio O Silva
            wrote on last edited by
            #5

            Maximilien wrote: CDC::MoveTo and CDC::LineTO ? I think the problem you might have is how to handle the action itself, how to click ( somewhere ), then drag the mouse ( to draw the line ), and release ( to finalize the connection ) This part actually is already done. I'm using a CListBox ctrl inside each modeless dialog. I managed to implement the drag and drop from one dialog to another. Although in the destination dialog there is a need to have at least one item selected (I couldn't figure out the item on the drop position). I'm now starting the code to draw the line itself. What I've done so far was: - I derived a class from CWnd named CContainerWnd with these methods: CContainer::AddDialog(CString pName) CContainer::RemoveDialog(CString pName) CContainer::CreateRelationship(CString PKName, CString FKName) This class is the parent for all modeless dialogs. I have also used a CFormView as a container for doc/view arquiteture, which worked like a charm including the scrollbars. Inside the CreateRelationship I managed to identify the dialogs position (which I save when created), so to draw the lines was quite easy. The problem comes when I move one of the dialogs. In this case it's necessary to clear the old line and redraw it in the new position. Also there is an even worse problem: if there is another dialog in between two that are related, the line will be drawn over this dialog, so far I couldn't figure out how to do it. I think if I'm able to create a CWnd derived class just to handle the line it may solve my problem, but I'm not too familiar with that. Thanks for the tips. []s Crercio O. Silva / DBTools Development http://www.dbtools.com.br

            M 1 Reply Last reply
            0
            • S Scott H Settlemier

              I'm not familiar with the relationship editor, but I would guess that the windows twixt which the line is drawn are not top level windows (modeless dialogs), but rather child windows of some container and it is on the container window that the line is drawn.

              C Offline
              C Offline
              Crercio O Silva
              wrote on last edited by
              #6

              Scott H. Settlemier wrote: I'm not familiar with the relationship editor, but I would guess that the windows twixt which the line is drawn are not top level windows (modeless dialogs), but rather child windows of some container and it is on the container window that the line is drawn. Oh, I guess I forgot to say this before. The dialogs are childs from a Dialog Container (A CWnd derived control). Thanks for the tip. []s Crercio O. Silva / DBTools Development http://www.dbtools.com.br

              1 Reply Last reply
              0
              • N Nick Parker

                I suppose you could pick an arbitrary set of points (say half the height of both dialogs) and then use the DrawLine method in GDI. :) Nick Parker
                May your glass be ever full. May the roof over your head be always strong. And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing


                C Offline
                C Offline
                Crercio O Silva
                wrote on last edited by
                #7

                Nick Parker wrote: I suppose you could pick an arbitrary set of points (say half the height of both dialogs) and then use the DrawLine method in GDI. I couldn't find the DrawLine method. Is it the same as using LineTo, MoveTo? Thanks, Crercio O. Silva / DBTools Development http://www.dbtools.com.br

                N 1 Reply Last reply
                0
                • C Crercio O Silva

                  Maximilien wrote: CDC::MoveTo and CDC::LineTO ? I think the problem you might have is how to handle the action itself, how to click ( somewhere ), then drag the mouse ( to draw the line ), and release ( to finalize the connection ) This part actually is already done. I'm using a CListBox ctrl inside each modeless dialog. I managed to implement the drag and drop from one dialog to another. Although in the destination dialog there is a need to have at least one item selected (I couldn't figure out the item on the drop position). I'm now starting the code to draw the line itself. What I've done so far was: - I derived a class from CWnd named CContainerWnd with these methods: CContainer::AddDialog(CString pName) CContainer::RemoveDialog(CString pName) CContainer::CreateRelationship(CString PKName, CString FKName) This class is the parent for all modeless dialogs. I have also used a CFormView as a container for doc/view arquiteture, which worked like a charm including the scrollbars. Inside the CreateRelationship I managed to identify the dialogs position (which I save when created), so to draw the lines was quite easy. The problem comes when I move one of the dialogs. In this case it's necessary to clear the old line and redraw it in the new position. Also there is an even worse problem: if there is another dialog in between two that are related, the line will be drawn over this dialog, so far I couldn't figure out how to do it. I think if I'm able to create a CWnd derived class just to handle the line it may solve my problem, but I'm not too familiar with that. Thanks for the tips. []s Crercio O. Silva / DBTools Development http://www.dbtools.com.br

                  M Offline
                  M Offline
                  Maximilien
                  wrote on last edited by
                  #8

                  Crercio O. Silva wrote: if there is another dialog in between two that are related, the line will be drawn over this dialog, so far I couldn't figure out how to do it. You need to re-order the drawings. in your view, you need to draw the different lines then draw the dialogs. Max.

                  C 1 Reply Last reply
                  0
                  • C Crercio O Silva

                    Nick Parker wrote: I suppose you could pick an arbitrary set of points (say half the height of both dialogs) and then use the DrawLine method in GDI. I couldn't find the DrawLine method. Is it the same as using LineTo, MoveTo? Thanks, Crercio O. Silva / DBTools Development http://www.dbtools.com.br

                    N Offline
                    N Offline
                    Nick Parker
                    wrote on last edited by
                    #9

                    Crercio O. Silva wrote: I couldn't find the DrawLine method. Is it the same as using LineTo, MoveTo? Sorry, I have had my head stuck in .NET lately as it is available in GDI+. You could write your own DrawLine function, here could be a prototype:

                    void DrawLine(CDC *dc, CPoint& start, CPoint& end);

                    Nick Parker
                    May your glass be ever full. May the roof over your head be always strong. And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing


                    1 Reply Last reply
                    0
                    • M Maximilien

                      Crercio O. Silva wrote: if there is another dialog in between two that are related, the line will be drawn over this dialog, so far I couldn't figure out how to do it. You need to re-order the drawings. in your view, you need to draw the different lines then draw the dialogs. Max.

                      C Offline
                      C Offline
                      Crercio O Silva
                      wrote on last edited by
                      #10

                      Maximilien wrote: You need to re-order the drawings. in your view, you need to draw the different lines then draw the dialogs. I have implemented this. So far the lines are drawn as they should be. When the dialog moves a method in the CContainer erases the previous lines and redraw all of them again. I used this approach to handle the draw of the dialogs: - first I connected WM_SIZE and WM_MOVE in the dialogs to the CContainer window, when one of them occurs it will call a method to repaint the lines - in the paint lines method I first draw the lines and then I hide/show the dialogs in order to make the lines stay under the dialogs. This is really working but the problem is I really think that using CDialog::ShowWindow() is causing me problems since the application goes into a infinite loop (looks like ShowWindow(SW_SHOW/SW_HIDE) updates the position of the dialog causing them to call the repaint method of the CContainer parent. Las night I worked on this till 3:00AM I wasn't thinking clearly anymore. Maybe after some sleep ...:zzz: Thanks man Crercio O. Silva / DBTools Development http://www.dbtools.com.br

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups