Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

drag the ghost of a control

Posted on 1997-03-18
2
Medium Priority
?
285 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

636 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