Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2024
  • Last Modified:

Removing Focus

How can I remove focus from a button in Delphi 5?
0
fh2
Asked:
fh2
1 Solution
 
EvarestCommented:
Bit stupid solution, but it works :-)

Place a button somewhere on your form where it can't be seen:

FocusButton1.Left :=-1000;
FocusButton1.Top :=-1000;

And if you want to loose the focus of any button call:
FocusButton1.SetFocus

This will focus the FocusButton1 (as it's still visible, you won't get an error)...

Good luck!
Evarest
0
 
Amir AzhdariCommented:
and also try to find the tabstop property of the button in the object inspector and set that to false
I mean
button1.tabstop:=false;
0
 
Pierre CorneliusCommented:
use the following:

  Windows.SetFocus(0);

It removes the focus from the control but does not set the focus to any other control in the window.

Regards
Pierre
0
 
esoftbgCommented:
Or use TSpeedButton: it never get the Focus ;-))
0
 
BlackTigerXCommented:
or set the Focus in any other control (in the OnClick event of the button or whenever you want the focus to go away from the button)

Edit1.SetFocus;
0

Featured Post

Technology Partners: 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!

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