Solved

Line Program

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

713 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