Board index » cppbuilder » Focus problem with BCB4

Focus problem with BCB4

I have developed a program that shows a message to the user at precise
intervals. The message is nothing else but a form with the dialog
style, no system menus and no close buttons on the caption bar. This
dialog box is made visible by setting the Visible property to True.
I've also specified the "StayOnTop" style flag so the form should
always appear on top of all other windows on the desktop. This form
has only one control : a "Hide" button that sets the Visible property
back to False.

The behavior of this simple timer driven program is not constant.
Sometimes the dialog appears normally and the user can hide it by
pressing the Hide button.
But sometimes, it appears on top of let's say a PowerPoint
presentation yet it doesn't have the focus. Then again different
behaviors occur. When the user presses the Hide button it either
disappears normally, but it sometimes ends his presentation and
returns PowerPoint back to the Edit mode!

The question I'm asking myself is if the StayOnTop flag is enough to
force the focus to my form whichever application is running at that
time? If not what could be the solution behind it?

Note: the program just warns the teacher (almost always working with
PowerPoint) that the lesson stops in 5 minutes!

Anybody any idea?

Thanks in advance, Alex Roose.

alexro...@technologist.com

 

Re:Focus problem with BCB4


In the code that actually shows the form, try adding
SetForegroundWindow(Handle); or SetActiveWindow(Handle);

--
Yoto Yotov

C++Builder Developer's Network
http://cbdn.cjb.net/

Quote
"Alex Roose" <alexro...@technologist.com> wrote in message

news:823s5s$jl611@forums.borland.com...
Quote
> I have developed a program that shows a message to the user at precise
> intervals. The message is nothing else but a form with the dialog
> style, no system menus and no close buttons on the caption bar. This
> dialog box is made visible by setting the Visible property to True.
> I've also specified the "StayOnTop" style flag so the form should
> always appear on top of all other windows on the desktop. This form
> has only one control : a "Hide" button that sets the Visible property
> back to False.

> The behavior of this simple timer driven program is not constant.
> Sometimes the dialog appears normally and the user can hide it by
> pressing the Hide button.
> But sometimes, it appears on top of let's say a PowerPoint
> presentation yet it doesn't have the focus. Then again different
> behaviors occur. When the user presses the Hide button it either
> disappears normally, but it sometimes ends his presentation and
> returns PowerPoint back to the Edit mode!

> The question I'm asking myself is if the StayOnTop flag is enough to
> force the focus to my form whichever application is running at that
> time? If not what could be the solution behind it?

> Note: the program just warns the teacher (almost always working with
> PowerPoint) that the lesson stops in 5 minutes!

> Anybody any idea?

> Thanks in advance, Alex Roose.

> alexro...@technologist.com

Other Threads