Solved

Keeping the focus on the same form

Posted on 1998-07-16
6
213 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
Comment Utility
I don't think it's possible.
I would be interesed if it is.
0
 
LVL 10

Expert Comment

by:viktornet
Comment Utility
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
Comment Utility
Are you trying to make a button to stay in the caption area of the first button?

Viktor Ivanov
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 3

Expert Comment

by:vladika
Comment Utility
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
Comment Utility
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
Comment Utility
Hi Jacco,

It works just as you said.  Thank you.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This video discusses moving either the default database or any database to a new volume.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

12 Experts available now in Live!

Get 1:1 Help Now