Solved

drag and drop images in Borland C++ Builder

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

759 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

21 Experts available now in Live!

Get 1:1 Help Now