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
Solved

Removing Focus

Posted on 2004-10-06
5
1,722 Views
Last Modified: 2012-05-05
How can I remove focus from a button in Delphi 5?
0
Comment
Question by:fh2
5 Comments
 
LVL 4

Expert Comment

by:Evarest
ID: 12242254
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
 
LVL 6

Expert Comment

by:Amir Azhdari
ID: 12242465
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
 
LVL 14

Expert Comment

by:Pierre Cornelius
ID: 12242967
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
 
LVL 12

Expert Comment

by:esoftbg
ID: 12242997
Or use TSpeedButton: it never get the Focus ;-))
0
 
LVL 13

Accepted Solution

by:
BlackTigerX earned 250 total points
ID: 12243949
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

792 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