Re: How to bring a dialog itself to top?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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








.



Relevant Pages

  • Re: How to bring a dialog itself to top?
    ... void CMyDialog::ActivateMeAndStealFocus ... then I need the user to input something in the textbox. ... I want to bring the dialog to top and put input focus to the ... previous top window's title bar is still blue. ...
    (microsoft.public.vc.mfc)
  • Re: How to bring a dialog itself to top?
    ... void CMyDialog::ActivateMeAndStealFocus ... then I need the user to input something in the textbox. ... I want to bring the dialog to top and put input focus to the ... previous top window's title bar is still blue. ...
    (microsoft.public.vc.mfc)
  • Re: How to bring a dialog itself to top?
    ... void CMyDialog::ActivateMeAndStealFocus ... need the user to input something in the textbox. ... bring the dialog to top and put input focus to the textbox. ... top window's title bar is still blue. ...
    (microsoft.public.vc.mfc)
  • Connecting to an open Window Example: IE Browser Window
    ... window and type a URL in the address bar and direct it there. ... Select another TextBox on same page. ... to know some recommended classes or methods others might use. ...
    (comp.lang.java.programmer)
  • Active window
    ... I need to be able to force a window's title bar to remain the "active" ... color even when that window does not have the input focus. ... remember that there is an API to do just this but since this is not ...
    (microsoft.public.vb.general.discussion)