Solved

drag the ghost of a control

Posted on 1997-03-18
2
259 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
2 Comments
 
LVL 3

Accepted Solution

by:
mheacock earned 50 total points
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now