Solved

Line Program

Posted on 1998-09-07
5
190 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
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 50 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

896 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

12 Experts available now in Live!

Get 1:1 Help Now