Solved

Keeping the focus on the same form

Posted on 1998-07-16
6
220 Views
Last Modified: 2010-04-04
I have two forms which are visible at all time. One has some buttons, the other one has a TEdit. I want the Tedit to have the focus at all time. When the user clicks on the button, of course the focus goes to that form. Is there a way to prevent a form to get the focus, even if a component on that form is clicked. Right now I just have a OnClick event for everything on the form with the button that sets the focus back to the form with the edit button. It works but I would prefer a cleaner solution, like a form property that prevents the form from getting the focus.
0
Comment
Question by:moonrise
6 Comments
 
LVL 4

Expert Comment

by:jeurk
ID: 1358068
I don't think it's possible.
I would be interesed if it is.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1358069
Are you trying to make a button to stay in the caption area of the first button?

Viktor Ivanov
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1358070
Are you trying to make a button to stay in the caption area of the first button?

Viktor Ivanov
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 3

Expert Comment

by:vladika
ID: 1358071
Try make Form2(with Edit) modal.
After that you could not switch to Form1

0
 
LVL 10

Accepted Solution

by:
Jacco earned 20 total points
ID: 1358072
You can do one thing to do this.

first you install the following message handler on the form that you don't want to be activated:

procedure WMMouseActivate(var Message: TMessage); message WM_MOUSEACTIVATE;

implementation:

procedure TForm2.WMMouseActivate(var Message: TMessage);
begin
  Message.Result := MA_NOACTIVATE;
end;

Second you should you components on that form that cannot receive the focus:

in stead of TButton's use TSpeedButton's.

The only way your Form will get activated then is when the user starts to move your Form. If you want to disable that behaviour override the WM_NCHitTest message handler of the Form and return the value HTCLIENT.

procedure WMNCHitTest(var Message: TWMNCHitTest); message WM_NCHITTEST;

procedure TForm2.WMNCHitTest(var Message: TWMNCHitTest);
begin
  Message.Result := HTCLIENT;
end;

Hope this helps you on the way!

Regards
Jacco
0
 

Author Comment

by:moonrise
ID: 1358073
Hi Jacco,

It works just as you said.  Thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

896 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

19 Experts available now in Live!

Get 1:1 Help Now