Solved

Not allowing focus to form/control

Posted on 1997-11-14
3
171 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

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

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 The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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