• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

Sliding an image and running problems!

I've got two problems here, one is with delphi running. My project was working fine until I restarted my computer the next morning and clicked run on my project. It looked like it was about to run but then instantly closed and went back to my Form. It does it so fast you can't see what is happening..
So basically, when I click run it just loops back to the form and there are no errors.

Also, I want to how to:

Create an image on the screen that has a hotspot on it (Just give me an example for now) that is located with X,Y. Then when someone clicks this Hotspot, the image slides from one place to another, say 200 pixels left but you see it slide along. Thankyou!

0
99jfender
Asked:
99jfender
2 Solutions
 
LukA_YJKCommented:
I use Shape instead of a hotspot and it works fine. Set border of the Shape to zero, then it will be invisible, but it will generate OnClick event where you can write with Image1 do Left := Left - 200;
0
 
LukA_YJKCommented:
Regarding your problem maybe deleting some additional files (like .dsk, .dof) will solve it?
0
 
Slick812Commented:
hello 99jfender,, You could define your Image "HotSpots" with another Component, but you could just define your Click Rect and then test the position if the cursor in the TImage OnMouseUp with PtInRect( ). . . . If you want to do simple movement, you will use a TTimer with the Interval set at around 55 milliseconds and then change the position about 3 pixels in the Timer Event, , , some code -


  private
    { Private declarations }
    ClickRect1, ClickRect2: TRect;

procedure TForm1.FormCreate(Sender: TObject);
begin
ClickRect1 := Rect(8,8,38, 28);
ClickRect2 := Rect(8,38,38, 58);
end;

procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
if PtInRect(ClickRect1, Point(X,Y)) then
Timer2.Enabled := True;
if PtInRect(ClickRect2, Point(X,Y)) then
ShowMessage('Click Rect Two');
end;

procedure TForm1.Timer2Timer(Sender: TObject);
begin
if Image1.Left < 51 then
  begin
  Timer2.Enabled := False;
{kill timer when new position is reached}
  Exit;
  end;
Image1.Left := Image1.Left-3;
end;


 - - - - - - - - - - - - - - - - - - - - - - - - -
I can't help with your program running problem, all the info that I know about that problem is - that it used to run and now it does not.
0
 
Mark BradyPrincipal Data EngineerCommented:
I had a similar problem recently.  When I went to run my project, it wouldn't compile, but if I ran the exe from outside of Delphi, I found windows was still using it.  So delete or rename the exe then try again.  Else reboot.

Mark
0
 
CleanupPingCommented:
99jfender:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now