Hi:
I have a form with a picture box and some command buttons to make
certain shapes appear in the picture box. The shapes are drawn on
blank UserControls added like this:
'at top of form module
Dim WithEvents tc As testControl
'button1_click (for example)
Set tc = Controls.Add("t estproj.testCon trol", "tc[index]",
Form1.Picture1)
(then shapes are drawn on the control and it's added to a collection
of like shapes)
My idea was to have these UserControls store internally some data that
would enable them to interact, most importantly to implement dragdrop
operations so that one control dragged over a "hot spot" in another
control would site itself at that spot, after some validation.
Here's where I'm stuck: I've found example after example explaining
how to convert a point on one object to a point in its container, but
none of them have worked so far. I'm wondering if this is a result of
creating the UserControls at run-time? Specifically, here is what I
would like to happen, but can't pull it off:
When the shapes are drawn on the control, certain points are captured
as hot spots and stored in a read-only array. These coordinates remain
in the control's own scale and are not converted.
When one control is dropped onto another, the dragdrop event fires,
and I can confirm the source is at a point inside the target control.
I want to compare this point to the internally stored points of target
and select the closest hot point. Then I need to convert that hot
point to the picture1 coordinates and move the source control there.
This seems like it should be a piece of cake, but it's been driving me
crazy for almost a day now. Any help would be appreciated, thanks in
advance.
I have a form with a picture box and some command buttons to make
certain shapes appear in the picture box. The shapes are drawn on
blank UserControls added like this:
'at top of form module
Dim WithEvents tc As testControl
'button1_click (for example)
Set tc = Controls.Add("t estproj.testCon trol", "tc[index]",
Form1.Picture1)
(then shapes are drawn on the control and it's added to a collection
of like shapes)
My idea was to have these UserControls store internally some data that
would enable them to interact, most importantly to implement dragdrop
operations so that one control dragged over a "hot spot" in another
control would site itself at that spot, after some validation.
Here's where I'm stuck: I've found example after example explaining
how to convert a point on one object to a point in its container, but
none of them have worked so far. I'm wondering if this is a result of
creating the UserControls at run-time? Specifically, here is what I
would like to happen, but can't pull it off:
When the shapes are drawn on the control, certain points are captured
as hot spots and stored in a read-only array. These coordinates remain
in the control's own scale and are not converted.
When one control is dropped onto another, the dragdrop event fires,
and I can confirm the source is at a point inside the target control.
I want to compare this point to the internally stored points of target
and select the closest hot point. Then I need to convert that hot
point to the picture1 coordinates and move the source control there.
This seems like it should be a piece of cake, but it's been driving me
crazy for almost a day now. Any help would be appreciated, thanks in
advance.
Comment