Solved

drag the ghost of a control

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

Technology Partners: 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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

736 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