PDA

Click to See Complete Forum and Search --> : aligning graphics in two picture boxes


justind000
Dec 15th, 2002, 12:48 PM
I have two picture boxes that are parrellel to each other on my form.

When the mouse moves over picturebox1, i draw a line parrallel at the mouse position, and I also want to move a label parallel to the mouse position in picturebox 2.

but using the Y coord from picturebox1 to set the .top property of the label doesnt work. its offset by a little bit.

how can i make it exactly parrallel?

This is the code in picturebox1s mousemove event

picPrice.ScaleHeight = picChart.ScaleHeight
lblPrice.Top = Y

picChart is the first picture box, and picPrice is the second.
and it makes the label offset a little bit to the mouse position

thanks

NoteMe
Dec 15th, 2002, 01:15 PM
Is the label in the picturebox or on the form...I can't remember what they call it, but the label has to be made on the picturebox. Look at my example. Does it have the same problem as your app...or is mine working like you want it to do...???

justind000
Dec 15th, 2002, 01:59 PM
Yours works like I want it to, and the code looks the same as mine, but mine doesn't work like yours heh.

I think the problem has something to do with the scale of the boxes.

I attached the ctl the code is in if you want to take a look at it. It's a charting control, if you look at it I want the crosshair in the picChart picture box to have the label in picPrice to be parrallel with each other.

NoteMe
Dec 15th, 2002, 04:53 PM
I have never used a conroll before :D so I'm not 100% sure what to do with it...:D So if you don't throw up your example, I don't think I will use that much time to figgure out what is wrong with it...:D

But try to set the pictureboxes scalemode to 3...I don't think that has anything to do with it, but just try...

and an other thing. Look at this projekt and see what I mean by putting the label in the picturebox and not on the form....

justind000
Dec 15th, 2002, 09:04 PM
you just add the ctl file, then there is an icon in the toolbox, add that to the form and its good to go.

the lable is made on the picture box...

NoteMe
Dec 16th, 2002, 05:58 AM
OK i have tied your controll...but I get an error when I load it, and an error when I start my app...and an error when I end my app...:D

OK look here...I can't see what you are complaineing about...the label is following the cursor up and down...

Is your problem that the text in the label is under the cursor??? Because if it is that then the problem is simple. In your code you write that the Y in the mousemove event = the top of the label. But you actually want it to be like the mid of the text. Then You would have to do something like this...


Label1.Top = Y - (Label1.Height / 2)


Try that out and tell me if that is your problem....

BTW I have attached a picture showing what I mean. The black label is your controll now....and the red one is what I mean....

http://www.vbforums.com/attachment.php?s=&postid=1301699