Solved

Line Program

Posted on 1998-09-07
5
179 Views
Last Modified: 2010-04-30
I need to write a program that draw some blocks and them tie them together with lines. If the user moves the blocks, the lines go with them to the original point. Please, I don't want to draw lines using Windows API or graphic animation. Thank You!!!
0
Comment
Question by:dgtal
5 Comments
 
LVL 1

Expert Comment

by:kacklehorn
Comment Utility
Good luck not using APIs!!
0
 

Expert Comment

by:DaveD072798
Comment Utility
Try setting up Label controls with a BorderStyle=1 for your boxes. This will have an added advantage of allowing colored or transparent boxes.

In the Label_Click event, toggle it's DragMode to allow/disallow dragging it in the Form. Now you've got your movable blocks. All you need is to draw the lines.

Since there is no Paint event to trap for a Label, how about the Form_DragDrop event instead? Check if the control being dropped is a Label and redraw your line however you need to.
0
 

Author Comment

by:dgtal
Comment Utility
The "Drag and Drop"  of boxes is not the problem here. The problem is to keep the lines following the blocks wherever they go  without having to redraw lines....thank you
0
 
LVL 2

Expert Comment

by:shchuka
Comment Utility
There is no way to have the line following the box without redrawing the line.  Just think of it this way:  The box is located in some location and a line is drawn to that box.  Now you move the box - the line WILL NOT move along with it, since it's NOT part of the box.  Therefore you need to "delete" the old line and draw a new one.

You have to redraw the lines.
0
 
LVL 1

Accepted Solution

by:
felonius earned 50 total points
Comment Utility
Use line controls. If you have for instance 2 boxes with a line connected to the left of the first and to the right of the second.

*****      *****
* 1 *------* 2 *
*****      *****

That means that

line.x1 = box1.left + box1.width
line.y1 = box1.top + box1.height / 2
line.x2 = box2.left
line.y2 = box2.top + box2.height / 2

Whenever the box is moved (which you seem to have fixed) and the box is released you should go through the above formulas again. If you need to generate new lines and boxes run time use control arrays.

Hope this helps. Otherwise you must descibe your problem in more detail.

felonius
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now