?
Solved

Line Program

Posted on 1998-09-07
5
Medium Priority
?
220 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 1

Expert Comment

by:kacklehorn
ID: 1433419
Good luck not using APIs!!
0
 

Expert Comment

by:DaveD072798
ID: 1433420
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
ID: 1433421
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
ID: 1433422
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 100 total points
ID: 1433423
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

719 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