Article View: borland.public.cppbuilder.nativeapi
Article #5456Re: How to make a window at *runtime* topmost via:-SetWindowPos() & UpdateWindow()
From: Remy Lebeau (TeamB)
Date: Wed, 17 Aug 2005 18:32
Date: Wed, 17 Aug 2005 18:32
46 lines
2289 bytes
2289 bytes
"Oren Halvani" <NoSpam@fdtd.com> wrote in message
news:43033a7e$1@newsgroups.borland.com...
> i'm using: SetWindowPos(..) to set it as topmost - what works
> fine..but the window is not recreated..
It is not supposed to be.
> so i using UpdateWindow(handle..) but it still does not recreate...
You do not need the window to be recreated to begin with. Why are you
trying to force that?
> if(chkForeground->Checked)
> {
<snip>
> }
> else
> {
<snip>
> SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE |
> SWP_NOSIZE);
> UpdateWindow(frmOptions->Handle);
> }
> }
Look closely at that code. Notice anything particularly wrong? You are
setting the window to be top-most regardless of your chkForeground checkbox.
You are NOT removing the top-most attribute when the checkbox is becomes
unchecked. You need to use HWND_NOTOPMOST to remove the attribute. Try
this code instead:
void __fastcall TfrmOptions::chkForegroundClick(TObject *Sender)
{
bool bForeground = chkForeground->Checked;
imgAlways_OnTop1->Visible = bForeground;
imgAlways_OnTop2->Visible = !bForeground;
SetWindowPos(Handle, (bForeground) ? HWND_TOPMOST : HWND_NOTOPOST,
0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
Gambit
Technical Details
Message-ID:
<430382c4$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<43033a7e$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,175ffbbcf7a4552c X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <43033a7e$1@newsgroups.borland.com> Subject: Re: How to make a window at *runtime* topmost via:-SetWindowPos() & UpdateWindow() Date: Wed, 17 Aug 2005 11:32:25 -0700 Lines: 48 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <430382c4$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1124303556 68.69.17.41 (17 Aug 2005 11:32:36 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail