Solved

drag and drop images in Borland C++ Builder

Posted on 2002-04-07
4
2,958 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
  • 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C++ assignment question 7 197
Fully specialized class template function 21 136
Find Visual Studio Tools 2 102
Header of docx file 17 102
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…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

785 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