blitz051697
asked on
implementing an OCX that supports drag/drop
I need to create an ocx that allows items to be drag/dropped from other instances of the same ocx.
Here is a simple example:
Lets say I created an OCX from the TListbox control in delphi. I want to be able to drap/drop between two instances of these controls in ,lets say, VB5. How should I do this. I probably need to do this using COM/OLE. But I'm lazy and don't want to spend the time trying to figure out the IDragSource and IDataObject interfaces. That's why I'm offering the following:
100 points for an example
500 points for working example OCX that does exactly what I stated above. Don't worry the acually thing plan on doing us much more complicated that strings. But its a start.
Here is a simple example:
Lets say I created an OCX from the TListbox control in delphi. I want to be able to drap/drop between two instances of these controls in ,lets say, VB5. How should I do this. I probably need to do this using COM/OLE. But I'm lazy and don't want to spend the time trying to figure out the IDragSource and IDataObject interfaces. That's why I'm offering the following:
100 points for an example
500 points for working example OCX that does exactly what I stated above. Don't worry the acually thing plan on doing us much more complicated that strings. But its a start.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Your example works great. three additional questions.
1. What if I want to pass a COM object around rather than a string. how difficult would this be. I have a string grid filled with data. when someone whats to drag/drop or manipulate the information, I instanciate a com object for the selected item in the grid. If they drag to another window --I would want to pass the object reference.
2. How do I handle multi-select?
3. What is the "link" method. I didn't see where this was ever used in your example?
thanks, blitz
1. What if I want to pass a COM object around rather than a string. how difficult would this be. I have a string grid filled with data. when someone whats to drag/drop or manipulate the information, I instanciate a com object for the selected item in the grid. If they drag to another window --I would want to pass the object reference.
2. How do I handle multi-select?
3. What is the "link" method. I didn't see where this was ever used in your example?
thanks, blitz
1 + 2: You even do not need a COM object. You can use any component, fill it with appropriate data, stream it into a memory stream (TMemoryStream.WriteCompon ent) and copy the memory into the global transfer mem. On the client side, you copy the global memory into a memory stream and use ReadComponent to create the component that now includes all data fields.
So e.g. you create 2 invisible string grids as transfer objects. When the drag starts, empty the first grid, copy all selected fields into this grid and stream the grid into memory. When the drop occurs, empty the second grid, stream the memory component into the grid and look what's in. All data and properties are properly set in there.
3: The Link method does a copy in my example. It is the equivalent to "create shortcut" (cursor with little arrow in the br corner).
Slash/d003303
So e.g. you create 2 invisible string grids as transfer objects. When the drag starts, empty the first grid, copy all selected fields into this grid and stream the grid into memory. When the drop occurs, empty the second grid, stream the memory component into the grid and look what's in. All data and properties are properly set in there.
3: The Link method does a copy in my example. It is the equivalent to "create shortcut" (cursor with little arrow in the br corner).
Slash/d003303
ASKER
blitz