BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Display a TForm on top of other windows

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage)
View previous topic :: View next topic  
Author Message
Simon Guertin
Guest





PostPosted: Mon Jun 27, 2005 2:35 pm    Post subject: Display a TForm on top of other windows Reply with quote



Hi, I am trying to force a Form to be displayed on top of other windows.

It works when the form is not displayed on screen but it does not work
when the form is already displayed and partially and/or completely
hidden under another window.

Application->Restore();
Application->BringToFront();

MyForm->Show();
MyForm->BringToFront();

SetForegroundWindow( MyForm->Handle ));
BringWindowToTop( MyForm->Handle ));

is there a correct combination or a right order that will make my form
show up on top of all other windows?

My application also is controlled via another application that sends a
message through a named pipe, that is why my application does not have
the focus.

Thanks

Simon
Back to top
Vladimir Stefanovic
Guest





PostPosted: Mon Jun 27, 2005 4:07 pm    Post subject: Re: Display a TForm on top of other windows Reply with quote



Try this /but not sure if that will help/:

// This line (in my case) has effect only on Win98
SetForegroundWindow( Handle );

// This combination I use in similar cases ...
Application->Restore();
Application->BringToFront();

// This is something like FormStyle::fsStayOnTop which Borland claims...
// ... that is not advisable to do at run-time (changing Form Style),
// but this API solution does not affect your code stability in any way
(AFAIK)

SetWindowPos( Handle, HWND_TOPMOST, Left, Top, Width, Height,
SWP_NOSIZE );




--
Best regards,
Vladimir Stefanovic


Back to top
Simon Guertin
Guest





PostPosted: Tue Jun 28, 2005 2:45 pm    Post subject: Re: Display a TForm on top of other windows Reply with quote



I tried the SetWindowPos way and only work to show the window on top of
every other window, but then , the window stays on top until I click it,
this is not what I want, is there a bug or an error in the Borland
implemantation to make a window on top?

I tried and I tried many many other ways to bring a window that is
already visible but is hidden by other window that are on top of the
window and nothing works.
The Bring ToTop is not able to bring the window on top neitheir
BringWindowToFront.

I was able to bring the window to the front using CWnd->BringToFront
from another application (Using FindWindow("MYWINDOWNAME"))but again the
Form's behavior was not working properly when I used this way to display
my form.

Simon
Vladimir Stefanovic wrote:
Quote:
Try this /but not sure if that will help/:

// This line (in my case) has effect only on Win98
SetForegroundWindow( Handle );

// This combination I use in similar cases ...
Application->Restore();
Application->BringToFront();

// This is something like FormStyle::fsStayOnTop which Borland claims...
// ... that is not advisable to do at run-time (changing Form Style),
// but this API solution does not affect your code stability in any way
(AFAIK)

SetWindowPos( Handle, HWND_TOPMOST, Left, Top, Width, Height,
SWP_NOSIZE );





Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (VCL Components Usage) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.