Solved

Keeping the focus on the same form

Posted on 1998-07-16
6
250 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
[X]
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
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month3 days, 13 hours left to enroll

630 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