Solved

drag the ghost of a control

Posted on 1997-03-18
2
282 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 50 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 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