Solved

Not allowing focus to form/control

Posted on 1997-11-14
3
163 Views
Last Modified: 2010-05-18
[Delphi 3 / WinNT 4]

I'm creating a sort of "monitor window" that displays various messages based a different set of 12 byte masks.

I split the "monitor" up into 4 TRichEdit controls so I could display the various status's with color and font control.. bold red for some severe problems.. normal black for normal things.

The problem is that when the TRichEdit see's any modification to it's font, it grabs the focus.  I don't want that to happen.  I want it to politely sit in the background and update it's status.

Setting to ReadOnly or (Enabled := False) don't work.

Are there any Win32 messages I can use and programmatically disallow focus?
0
Comment
Question by:greendot
3 Comments
 
LVL 3

Expert Comment

by:Pegasus100397
ID: 1350508
Greendot,

in each of the RichEdit controls OnEnter event use the SetFocus to set the focus back to something other than the richedit, such as

procedure TForm1.RichEdit1Enter(Sender: TObject);
begin
Button1.SetFocus;
end;

As soon as the RichEdit gets the focus it immediately shifts focus back to Button1.

Hope this helps and good luck with your project!
Pegasus
0
 
LVL 2

Author Comment

by:greendot
ID: 1350509
Oops, I should have explained what I don't like about the focus situation a little better.

I don't want anything in that window getting the focus.  
0
 
LVL 8

Accepted Solution

by:
MikeP090797 earned 100 total points
ID: 1350510
I think this can solve it:
Use GetWindow(your window's hanlde, HWNDNEXT)
This will get the handle of the window below yours - the one who had the focus before.
Use SetForeGroundWindow(returned_handle)
This will set the focus to the previos window
Put this code to OnEnter(or whatever it's in Delphi)
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

Title # Comments Views Activity
Best Firemonkey component pack 1 86
Create Database on Android via Delphi dbExpress 3 80
Run video youtube webbrowse 10 57
select query - oracle 16 92
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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

910 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