?
Solved

drag and drop images in Borland C++ Builder

Posted on 2002-04-07
4
Medium Priority
?
3,061 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 400 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

801 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