Solved

drag and drop images in Borland C++ Builder

Posted on 2002-04-07
4
3,010 Views
Last Modified: 2012-06-27
I am trying to drag and drop images in a panel. The panel accepts the image fine but when the mouse is released the image moves off screen and the panel resizes. I have tried manual and automatic drag-mode in the TImage properties and also false and true in the TPanels autosize property. I cannot get the drag and drop operation to behave in a sensible way. I also experimented with a formulae to calculate the position of the mouse down coordinate and the mouse up coordinate to specify a location for the image but it behaved erratically. Can anyone tell me if this is the right track or am I missing something?
0
Comment
Question by:sylvrynne
[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
  • 3
4 Comments
 
LVL 6

Accepted Solution

by:
DrDelphi earned 100 total points
ID: 6925077
Sorry, no BCB here at the office, but I can give you a Delphi example (DragMode is dmAutomatic on both the TPanel and TImage):


procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
     BeginDrag(false);

end;

procedure TForm1.Panel1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
   if Source is Timage then Accept:=True;
end;

procedure TForm1.Panel1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
  Timage(source).Parent:=Panel1;
  Timage(source).Visible:=true;
  Timage(Source).left:=x;
  Timage(Source).top:=y;
end;


Good luck!!

0
 
LVL 6

Expert Comment

by:DrDelphi
ID: 6925081
I can give you a BCB example later today when I get home if you have trouble with this one.



Cheers.
0
 

Author Comment

by:sylvrynne
ID: 6955334
thanx for that ... finally got time to get back to it and from your code I could translate a solution .... thanx heaps
0
 
LVL 6

Expert Comment

by:DrDelphi
ID: 6958487
Cheers!

0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

732 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