 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Oren Halvani Guest
|
Posted: Wed Aug 17, 2005 1:24 pm Post subject: How to make a window at *runtime* topmost via:-SetWindowPos( |
|
|
dear builders,
i'm trying to make a window topmost in runtime..i know some people here
suggested me to avoid it, but i have to...
i'm using: SetWindowPos(..) to set it as topmost - what works fine..
but the window is not recreated..so i using UpdateWindow(handle..)
but it still does not recreate...i already tryed: ShowWindow() and
BringToFront()
but --NOTHING-- seems to force the window to be recreated...
what else do i need...?
Oren
/*********************************************************/
void __fastcall TfrmOptions::chkForegroundClick(TObject *Sender)
{
if(chkForeground->Checked)
{
imgAlways_OnTop1->Visible = true;
imgAlways_OnTop2->Visible = false;
SetWindowPos(Handle, HWND_TOPMOST, Left, Top, Width,
Height,SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
UpdateWindow(frmOptions->Handle);
}
else
{
imgAlways_OnTop1->Visible = false;
imgAlways_OnTop2->Visible = true;
SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE |
SWP_NOSIZE);
UpdateWindow(frmOptions->Handle);
}
}
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Aug 17, 2005 6:32 pm Post subject: Re: How to make a window at *runtime* topmost via:-SetWindow |
|
|
"Oren Halvani" <NoSpam (AT) fdtd (DOT) com> wrote
| Quote: | i'm using: SetWindowPos(..) to set it as topmost - what works
fine..but the window is not recreated..
|
It is not supposed to be.
| Quote: | 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?
| Quote: | 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
|
|
| Back to top |
|
 |
Oren Halvani Guest
|
Posted: Thu Aug 18, 2005 6:16 pm Post subject: Re: How to make a window at *runtime* topmost via:-SetWindow |
|
|
thanks Remy,
well i forgot to say something:
the Foreground-CheckBox is on a another form, NOT
the main form, so i've added...
void __fastcall TfrmOptions::chkForegroundClick(TObject *Sender)
{
bool bForeground = chkForeground->Checked;
imgAlways_OnTop1->Visible = bForeground;
imgAlways_OnTop2->Visible = !bForeground;
SetWindowPos(frmMainUnit->Handle, (bForeground) ? HWND_TOPMOST : HWND_NOTOPMOST,0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
/*...THIS */ SetWindowPos(frmOptions->Handle, (bForeground) ? HWND_TOPMOST : HWND_NOTOPMOST,0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
is this OK..? i mean it looks fine while i'm testing it, but
just wanted to know if it's safe..
Oren
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Aug 18, 2005 6:56 pm Post subject: Re: How to make a window at *runtime* topmost via:-SetWindow |
|
|
"Oren Halvani" <xx (AT) xx (DOT) com> wrote
| Quote: | the Foreground-CheckBox is on a another form, NOT the main form
|
That makes no difference at all.
| Quote: | SetWindowPos(frmMainUnit->Handle, (bForeground) ? HWND_TOPMOST :
HWND_NOTOPMOST,0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
/*...THIS */ SetWindowPos(frmOptions->Handle, (bForeground) ?
HWND_TOPMOST : HWND_NOTOPMOST,0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); |
Why are you setting two separate windows to be top-most at the same time?
Gambit
|
|
| Back to top |
|
 |
Oren Halvani Guest
|
Posted: Thu Aug 18, 2005 8:22 pm Post subject: Re: How to make a window at *runtime* topmost via:-SetWindow |
|
|
Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> schrieb im Newsbeitrag
news:4304d9be$1 (AT) newsgroups (DOT) borland.com...
| Quote: | Why are you setting two separate windows to be top-most at the same time?
Gambit
|
because, if i'm setting the main-window as topmost, the option-window
will be in the background, it has to be in the foreground (even after the
user has clicked the foreground-checkbox)
and that means the option-window has to be also top-most...
do you have another idea as mine...?
Oren
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Aug 18, 2005 9:00 pm Post subject: Re: How to make a window at *runtime* topmost via:-SetWindow |
|
|
"Oren Halvani" <xx (AT) xx (DOT) com> wrote
| Quote: | because, if i'm setting the main-window as topmost, the option
window will be in the background, it has to be in the foreground
(even after the user has clicked the foreground-checkbox)
|
Why are you making your options window top-most at all? If the main window
is top-most, showing the options window modally will automatically show it
on top of the main widow without actually making it a top-most window.
Gambit
|
|
| Back to top |
|
 |
Oren Halvani Guest
|
Posted: Thu Aug 18, 2005 9:32 pm Post subject: Re: How to make a window at *runtime* topmost via:-SetWindow |
|
|
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> schrieb im Newsbeitrag
news:4304f6ce$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
Why are you making your options window top-most at all? If the main window
is top-most, showing the options window modally will automatically show it
on top of the main widow without actually making it a top-most window.
Gambit
|
thats the point, it doesn't !
i guess it's the famous BCB3 - "ShowModal() bug" i heared in the past about it...
anyway, it seems to work pretty fine now, i'll have to make further tests,
the release-date is next week :-)
Oren
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Aug 18, 2005 11:03 pm Post subject: Re: How to make a window at *runtime* topmost via:-SetWindow |
|
|
"Oren Halvani" <xx (AT) xx (DOT) com> wrote
| Quote: | thats the point, it doesn't !
|
I have projects that do that and it works fine.
| Quote: | i guess it's the famous BCB3 - "ShowModal() bug" i heared
in the past about it...
|
You seriously need to stop using BCB3. You are a decade behind in bug fixes
and features.
Gambit
|
|
| Back to top |
|
 |
Oren Halvani Guest
|
Posted: Thu Aug 18, 2005 11:40 pm Post subject: Re: How to make a window at *runtime* topmost via:-SetWindow |
|
|
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> schrieb im Newsbeitrag
news:430513a5$1 (AT) newsgroups (DOT) borland.com...
| Quote: | You seriously need to stop using BCB3. You are a decade behind in bug fixes
and features.
Gambit
|
you are right again, but many, many of my projects have been started with BCB 3...
i also have BCB 6, but as i've tryed to convert my projects to the new XML
project-format of BCB 6, i've get too many errors so, i'm still use BCB3 :-(
besides this, i like BCB 3 because it produces compact & small exe files, as you know
the VCL in BCB3 doesn't support so many functionality like BCB6...
and another reason why i like BCB3: i bought it as i've been at school :-)
but i know it's a very old version and one day i realy should change :-(
Oren
|
|
| Back to top |
|
 |
|
|
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
|
|