?
Solved

drag the ghost of a control

Posted on 1997-03-18
2
Medium Priority
?
283 Views
Last Modified: 2010-04-04
In designtime, during draging a control, a ghost (the shadow of the control) goes together with the mouse pointer nicely. However, there is no such ghost in runtime when I drag a control.

How to create it in runtime?
0
Comment
Question by:zhuhail
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 3

Accepted Solution

by:
mheacock earned 100 total points
ID: 1334896
I've not done much dragging and dropping, but it seems to me that you'd need another component to represent the 'dragging rectangle' that you are looking for.

How about enabling a TImage?  Set it to the size of the control you are dragging, draw a thick rectangle around its edges, set it to topmost, then just reposition it as the mouse moves?  You'd have to set its background color to that of the form.  Of course, since TImages are not transparent, it would cover any other controls it moved over.  You'd have to capture the background and copy it into the TImage if you didn't want it to cover up contols it passed over.

Perhaps simply move a collection of line controls, set up to be a rectangle of the size of the control you are moving?

Perhaps just reposition the actual control based on the location of the mouse?

There's no simple way of implementing this, but there are some options for you to look at.

I'll check the TechInfo articles at the Borland site and if I find anything specific, I'll post it here for you.
0
 
LVL 4

Expert Comment

by:StevenB
ID: 1334897
What I do in this situation is to create a rect region on the parent canvas and then color invert it using the API calls :
CreateRectRgn and InvertRgn (see Delphi help). To do this effectivly you have to be carefull to reinvert the region cleanly, or you mess up the whole canvas. Try:

On MouseDown:
  Invert the Region occupied by the component and store this Region

On MouseMove:
  Invert the stored region (i.e. return to original state) and invert a new region based on Mouse coordinates and store this region.

On MouseUp :
  Invert the stored region and move the original component to the new position.

  Does this help.

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month13 days, 17 hours left to enroll

801 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