Board index » cppbuilder » preventing focus change to a newly visible window

preventing focus change to a newly visible window


2005-11-08 12:30:03 AM
cppbuilder25
Hi, I have a popup window that displays some information when the state
of my application change. (like the MSN Messenger little window)
I am able to display this window on top f every other application when I
am working in another application for example. (It also does not
receives the focus, so If I am typing something in Word, I am not
disturbe by this little window.)
The problem arise when I am typing something in another window of my
application. When the little window appears it receives the focus.
How could I prevent this?
BUt I have some buttons that I can click on this window, so it needs to
have the focus at some point.
I use this bit of code to display the window:
//***************************
ShowWindow(Handle, SW_SHOWNOACTIVATE);
SetWindowPos(Handle, HWND_TOPMOST, Left, Top,Width, Height,
SW_SHOWNOACTIVATE );
Visible = true;
//**********************************
Thank you for any ideas.
Simon
 
 

Re:preventing focus change to a newly visible window

Simon Guertin wrote:
Quote
The problem arise when I am typing something in another window of my
application. When the little window appears it receives the focus.

How could I prevent this?
Do you need the Visible=true, I'd try removing that.
Jonathan
 

Re:preventing focus change to a newly visible window

I tried it but it does work. It looks like the Buttons on my form are
not displayed. I just see the forms with the backgroud and some label. I
really need to set Visible = true;
Jonathan Benedicto wrote:
Quote
Simon Guertin wrote:

>The problem arise when I am typing something in another window of my
>application. When the little window appears it receives the focus.
>
>How could I prevent this?


Do you need the Visible=true, I'd try removing that.

Jonathan


 

{smallsort}

Re:preventing focus change to a newly visible window

Simon Guertin wrote:
Quote
I tried it but it does work. It looks like the Buttons on my form are
not displayed. I just see the forms with the backgroud and some
label. I really need to set Visible = true;
Ok, try changing the form's style to fsStayOnTop, then try this:
Show();
Application->BringToFront();
Jonathan
 

Re:preventing focus change to a newly visible window

It does not work, It removes the focus of the current executing
application also.
Maybee I have to dig deeply in TForm and TCustom form to not request the
focus when I set the Visible property to true only for this form..
Jonathan Benedicto wrote:
Quote
Simon Guertin wrote:

>I tried it but it does work. It looks like the Buttons on my form are
>not displayed. I just see the forms with the backgroud and some
>label. I really need to set Visible = true;


Ok, try changing the form's style to fsStayOnTop, then try this:

Show();
Application->BringToFront();

Jonathan


 

Re:preventing focus change to a newly visible window

Simon Guertin wrote:
Quote
It does not work, It removes the focus of the current executing
application also.
Set the form's style to fsStayOnTop, and then do this:
HWND LastWindow;
LastWindow = GetForegroundWindow( NULL );
Show();
SetForegroundWindow( LastWindow );
HTH
Jonathan