Re: How to bring a dialog itself to top?
Here is the sequence.
void CMyDialog::ActivateMeAndStealFocus()
{
if (IsIconic())
{
ShowWindow(SW_RESTORE);
}
SetForegroundWindow();
BringWindowToTop();
SetActiveWindow();
m_edtCode.SetFocus();
}
AliR.
"Evan Li" <cli4@alcatel-lucent.com> wrote in message
news:OUb33i$NJHA.1396@TK2MSFTNGP05.phx.gbl...
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