Solved

Keeping the focus on the same form

Posted on 1998-07-16
6
226 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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 …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 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