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. 7 5845
On 9 Nov 2003 16:54:23 -0800, ka**@curio.com (Kate) wrote: 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_cli ck (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?
Definitely not - not a chance
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.
Ok, so you have an array of points in the ClientArea 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.
because you have the X and Y coordinates ...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.
So you have points stored INSIDE a usercontrol, that you wish to
convert into points inside its parent - the Picturebox
Have you looked at the Extender properties of a Usercontrol ?
eg: UserControl.Ext ender.Left 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'm not totally sure what you are up to ...
Another thing that could help is the ClientToScreen API
- and the ScreenToClient API er*****@nowhere .com (J French) wrote in message news:<3f******* *********@news. btclick.com>... On 9 Nov 2003 16:54:23 -0800, ka**@curio.com (Kate) wrote:
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?
Definitely not - not a chance
Specifically , here is what I would like to happen, but can't pull it off: Have you looked at the Extender properties of a Usercontrol ? eg: UserControl.Ext ender.Left
A bit..I know I want most of the code eventually inside the
UserControl module, but an early roadblock was that I cannot get the
dragdrop event inside the UserControl to fire--only the dragdrop event
of the run-time instance (and isn't it the Extender that provides
this...?) And as long as I'm stuck for the moment using the available
event, I want to at least figure out how to position a control where I
want it inside the picture control:
//pt is a POINTAPI, initially contains one of the hotspots inside
UserControl tc
pt.X = ScaleX(pt.X, vbTwips, vbPixels)
pt.Y = ScaleY(pt.Y, vbTwips, vbPixels)
//get the screen position of this point
ClientToScreen tc.GetHWnd, pt
//move the dragdrop source to the desired point on the target
Source.Move pt.X * Screen.TwipsPer PixelX - Picture1.Left, pt.Y * _
Screen.TwipsPer PixelY - Picture1.Top
Source just disappears, somewhere outside the picture box boundaries.
On 10 Nov 2003 06:26:48 -0800, ka**@curio.com (Kate) wrote:
<snip> Have you looked at the Extender properties of a Usercontrol ? eg: UserControl.Ext ender.LeftA bit..I know I want most of the code eventually inside the UserControl module, but an early roadblock was that I cannot get the dragdrop event inside the UserControl to fire--only the dragdrop event of the run-time instance
I do not understand
- what is a run-time instance ?
.... you cannot have tried to 'fake' the recipient of an event (?)(and isn't it the Extender that provides this...?)
No, the Extender knows about its environment
- that is subtly different from what I think you are talking about And as long as I'm stuck for the moment using the available event, I want to at least figure out how to position a control where I want it inside the picture control:
//pt is a POINTAPI, initially contains one of the hotspots inside UserControl tc pt.X = ScaleX(pt.X, vbTwips, vbPixels) pt.Y = ScaleY(pt.Y, vbTwips, vbPixels)
//get the screen position of this point ClientToScre en tc.GetHWnd, pt
//move the dragdrop source to the desired point on the target Source.Move pt.X * Screen.TwipsPer PixelX - Picture1.Left, pt.Y * _ Screen.TwipsPe rPixelY - Picture1.Top
Source just disappears, somewhere outside the picture box boundaries.
Probably because it is way outside the boundaries
Why not just trace where it is ? er*****@nowhere .com (J French) wrote in message news:<3f******* *********@news. btclick.com>... On 10 Nov 2003 06:26:48 -0800, ka**@curio.com (Kate) wrote:
<snip> Have you looked at the Extender properties of a Usercontrol ? eg: UserControl.Ext ender.Left A bit..I know I want most of the code eventually inside the UserControl module, but an early roadblock was that I cannot get the dragdrop event inside the UserControl to fire--only the dragdrop event of the run-time instance
I do not understand - what is a run-time instance ? ... you cannot have tried to 'fake' the recipient of an event (?)
Well, it's like this. I was working through the tutorial on creating
activeX control and want to see if control will support what I want to
do (create blank controls at runtime, draw on them as user dictates,
and allow user to site controls by dragging and dropping them). So I
have a control project and a test project to work with the control.
In the test project, events like click, mousedown, mouseup don't
appear in the pull-down procedure list unless I raise them in the
control project, but dragdrop appears automatically, and this is the
only dragdrop event that responds to my code (e.g., I deleted all
dragdrop code in the test project and put msgbox in control project
dragdrop--nothing happens when I drop onto an instance of my control
in this case. If I put the msgbox back into test project dragdrop, I
get the message.) (and isn't it the Extender that provides this...?) No, the Extender knows about its environment - that is subtly different from what I think you are talking about
Just received my book on COM/ActiveX, maybe that will clear things up.
Thanks--
"Kate" <ka**@curio.com > wrote in message
news:2c******** *************** ***@posting.goo gle.com... er*****@nowhere .com (J French) wrote in message
news:<3f******* *********@news. btclick.com>... On 10 Nov 2003 06:26:48 -0800, ka**@curio.com (Kate) wrote:
<snip>
In the test project, events like click, mousedown, mouseup don't appear in the pull-down procedure list unless I raise them in the control project, but dragdrop appears automatically, and this is the only dragdrop event that responds to my code (e.g., I deleted all dragdrop code in the test project and put msgbox in control project dragdrop--nothing happens when I drop onto an instance of my control in this case. If I put the msgbox back into test project dragdrop, I get the message.)
I found the same result. The DragDrop event does not seem to fire inside the
UserControl code module - presumably it is preset to just raise the event
instead. However, the OleDragDrop event will fire there. If you change your test
project to use the Ole DragDrop events instead, you can probably make it work.
"Kate" <ka**@curio.com > wrote in message
news:2c******** *************** ***@posting.goo gle.com... er*****@nowhere .com (J French) wrote in message
news:<3f******* *********@news. btclick.com>... On 9 Nov 2003 16:54:23 -0800, ka**@curio.com (Kate) wrote:
//pt is a POINTAPI, initially contains one of the hotspots inside UserControl tc pt.X = ScaleX(pt.X, vbTwips, vbPixels) pt.Y = ScaleY(pt.Y, vbTwips, vbPixels)
//get the screen position of this point ClientToScreen tc.GetHWnd, pt
//move the dragdrop source to the desired point on the target Source.Move pt.X * Screen.TwipsPer PixelX - Picture1.Left, pt.Y * _ Screen.TwipsPer PixelY - Picture1.Top
I think you should try
Source.Move pt.X, pt.Y
without any scaling. You are 1) converting X to pixels, 2) converting it to
screen position, 3) converting pixels back to Twips, and 4) offsetting that
amount not from the left edge of the screen, but from the left edge of Picture1.
You could similarly convert Picture1.Left to screen twips, and then offset from
that instead, but I think all the conversions cancel each other. You wind up the
original Pt.X twips from Picture1.Left.
On 10 Nov 2003 10:43:39 -0800, ka**@curio.com (Kate) wrote: er*****@nowher e.com (J French) wrote in message news:<3f******* *********@news. btclick.com>... On 10 Nov 2003 06:26:48 -0800, ka**@curio.com (Kate) wrote:
<snip>In the test project, events like click, mousedown, mouseup don't appear in the pull-down procedure list unless I raise them in the control project, but dragdrop appears automatically, and this is the only dragdrop event that responds to my code (e.g., I deleted all dragdrop code in the test project and put msgbox in control project dragdrop--nothing happens when I drop onto an instance of my control in this case. If I put the msgbox back into test project dragdrop, I get the message.)
Here is an alternative :-
Option Explicit
' Add a Textbox
' Move Form or Textbox on MouseDown & Drag
Private Declare Function ReleaseCapture _
Lib "user32" () As Long
Private Declare Function SendMessage _
Lib "user32" _
Alias "SendMessag eA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Any) As Integer
Const WM_NCLBUTTONDOW N = &HA1
Const HTCAPTION = 2
Public Sub MoveObject(hwnd As Long)
ReleaseCapture
SendMessage hwnd, WM_NCLBUTTONDOW N, HTCAPTION, 0&
End Sub
Private Sub Form_MouseDown( Button As Integer, _
Shift As Integer, _
X As Single, _
Y As Single)
MoveObject Me.hwnd
End Sub
Private Sub Text1_MouseDown (Button As Integer, _
Shift As Integer, _
X As Single, _
Y As Single)
MoveObject Text1.hwnd
End Sub This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: KS |
last post by:
I have a Button I want to pull to a Label.
I want the Button visualy to move when I pull it.
When I drop the button on the Label I want to test some data coming with the
Button - f.ex is the Button.Text="The right one!".
I have some code that can do the DragDrop-effect BUT this code disables the
visual effect og the Button visualy moving to the Label.
|
by: KS |
last post by:
In want to visualy drag a Button to a Label and when I depress the
mousebutton on top of the label I want to show some dato from the Button in
a MsgBox - that's my primary goal.
I have made a simple sample code - a form with a Button1, a Label1 and a
Timer1.
The Button1 has Tag="SomeData", the Label1 has AllowDrop=True and the Timer1
has an Interval=20.
|
by: dave |
last post by:
I am wishing to drag something from the desktop to a tab of a tab control in
vb.net.
The dragdrop event fires when release the mouse above the tab however i am
having a hard time trying to figure out which tab it was dropped on.
Currently i am using the following code but it is not working..Any help
would be appreciated...
Private Sub tc_DragDrop(ByVal sender As Object, ByVal e As
System.Windows.Forms.DragEventArgs) Handles...
|
by: Flack |
last post by:
Hello,
Is it possible to find out how many methods are listening to a certain
event? For example, if a number of methods subscribed to a controls DragDrop
event using +=, can I find out how many methods in total are listening to the
DragDrop event of the control?
If I can't find out the exact number of methods listening to the DragDrop
event, can I somehow remove all listeners of that event at once? I tried
using m_Control.DragDrop =...
|
by: SamSpade |
last post by:
How to program DragDrop with a RichTextBox?
If I develop by inherit I can override the DragDrop methods and do it that
way.
But if I want to include a RichTextBox on a UserControl the MethodName drop
down box does not include methods for the DragDrop events. Is there some way
to get the methods to show?
Is it OK to program them manually?
| |
by: Gene Hubert |
last post by:
Well, it seems fundamental to me anyway. Hopefully it is simple
enough.
The question is for when the source for the dragdrop is a different
application that the target for the dragdrop. How does the source for
the dragdrop operation know that a drop has been completed onto a
valid target? And then, how does the source know what the drop target
is?
I've got dragdrop working within my application but I can't see any
|
by: Gary Dunne |
last post by:
I'm writing an app that requires drag and drop operation between a ListView
and a TreeView control. (The source is the ListView). During the drag drop
operation I want to be able to detect the target node in the treeview and
auto expand it if applicable... but after a fair bit of head scratching I
can't find any easy way to accomplish this.
I think what i really need is the equivalent of the HitTest method from the
COM version of the...
|
by: JohnR |
last post by:
I am using dragdrop to drag and drop a custom class instance. When I
drag/drop from one window to another window in the same application
everything works fine. But when trying to move between the same windows
running in different instances of the application the "dropped" data comes
across as a system.__ComObject and I can't CType it to my class to extract
the data. I've been searching for hours and haven't found any solution so
I am...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |