[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Block window focus

Posted on 2006-04-18
4
Medium Priority
?
241 Views
Last Modified: 2010-04-05
Hi!
I created an on-screen keyboard and I want my form not to receive the focus when I click it or any control on it. Does anybody know how can I do it?

Thanks in advance
0
Comment
Question by:quentin1
  • 3
4 Comments
 
LVL 11

Accepted Solution

by:
ZhaawZ earned 160 total points
ID: 16481924
Try this:


procedure TForm1.FormCreate(Sender: TObject);
begin
FormStyle := fsStayOnTop;
SetWindowLong(handle, gwl_exstyle, GetWindowLong(handle, gwl_exstyle) or ws_ex_noactivate);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
caption := 'test';
end;
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 16481959
You may also add this line to onCreate event:
ShowWindow(handle, sw_showna);

Without this line the form (when I tried it) looked like it's active (however it was NOT). When added this line, it got a "light" border (like inactive windows have).

When clicking controls on a form with ws_ex_noactivate ex-style, they may get a focus, but they will not be active.
0
 

Author Comment

by:quentin1
ID: 16484766
Thanks ZhaawZ. It works fine
0
 
LVL 11

Expert Comment

by:ZhaawZ
ID: 16486623
glad to help ;)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
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…
Integration Management Part 2
Screencast - Getting to Know the Pipeline
Suggested Courses

830 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