Re: How to bring a dialog itself to top?
- From: "AliR \(VC++ MVP\)" <AliR@xxxxxxxxxxxxx>
- Date: Mon, 27 Oct 2008 10:35:17 -0500
How is the thread notifying the window that it needs to be activated?
AliR.
"Evan Li" <music4@xxxxxxx> wrote in message
news:O%23r7feEOJHA.2100@xxxxxxxxxxxxxxxxxxxxxxx
AliR,
Thanks for your answer. Unfortunately, it doesn't work. It's behavior is
just same as my original code. My dialog is brought to the top, but it's
not got active.
Evan
"AliR (VC++ MVP)" <AliR@xxxxxxxxxxxxx> wrote in message
1GkNk.6086$be.3184@xxxxxxxxxxxxxxxxxxxxxxx
Here is the sequence.
void CMyDialog::ActivateMeAndStealFocus()
{
if (IsIconic())
{
ShowWindow(SW_RESTORE);
}
SetForegroundWindow();
BringWindowToTop();
SetActiveWindow();
m_edtCode.SetFocus();
}
AliR.
"Evan Li" <cli4@xxxxxxxxxxxxxxxxxx> wrote in message
news:OUb33i$NJHA.1396@xxxxxxxxxxxxxxxxxxxxxxx
I have a dialog based MFC application. In this app, there is only dialog,
and there is a textbox on the dialog. Also there a thread in this app
that receives data from IP intranet. If the thread receive some message,
then I need the user to input something in the textbox. At that time, I
want to bring the dialog to top and put input focus to the textbox.
I use the folloing code in CMyDialog:
void CMyDialog::BringMeToTop()
{
WINDOWPLACEMENT pl;
pl.length = sizeof(pl);
GetWindowPlacement(&pl);
if (pl.showCmd == SW_SHOWMINIMIZED)
{
pl.showCmd = SW_RESTORE;
SetWindowPlacement(&pl);
}
SetForegroundWindow();
BringWindowToTop();
m_edtCode.SetFocus();
}
But it seems to not work. With this code, the dialog can be brought to
top, but it's not actived, it's title bar is still gray, and the
previous top window's title bar is still blue. So that the text box
cannot get input focus.
By the way, I am working on Win XP.
Any answer will be greatly appreciated.
Evan
.
- Follow-Ups:
- Re: How to bring a dialog itself to top?
- From: Evan Li
- Re: How to bring a dialog itself to top?
- References:
- How to bring a dialog itself to top?
- From: Evan Li
- Re: How to bring a dialog itself to top?
- From: AliR \(VC++ MVP\)
- Re: How to bring a dialog itself to top?
- From: Evan Li
- How to bring a dialog itself to top?
- Prev by Date: Re: How to bring a dialog itself to top?
- Next by Date: urgent problem that I want to have a comment about
- Previous by thread: Re: How to bring a dialog itself to top?
- Next by thread: Re: How to bring a dialog itself to top?
- Index(es):
Relevant Pages
|