Solved

Not allowing focus to form/control

Posted on 1997-11-14
3
158 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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 Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 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