Solved

drag and drop images in Borland C++ Builder

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

749 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