Link to home
Start Free TrialLog in
Avatar of wacjac
wacjac

asked on

The old moving button joke?

I've no doubt that you've all seen what I'm about to describe...

I'm trying to find the code involved with the old moving button in window joke - you know the one where as you attempt the click the 'click me to win a prize' as soon as the cursor position approaches the button the button moves off and is therfore impossible to press.

I'm interested in seeing how this is built (I've a rough idea) - can anyone point me in the direction of some code please?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of FrankTheRat
FrankTheRat

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MethinX
MethinX

Click on the MouseMove event of the Button and you 'll get this procedure header, and i added a code to move if from left 200 to left 50 and back.

procedure TForm1.Button1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if
    button1.Left <> 200 then
    button1.Left := 200
  else
    button1.Left := 50;
end;