Below is my code for the reception of the SpecialFocus message that I
defined. I have verified that I get the message by using the message box.
And EVERYTHING works correctly when the MessageBox is displayed. However
when the message box is commented out (as shown), the APP never recieves
focus nor is it brought to the top. I have tried several other combinations
of the commands below. One that I tried is setting the window to
"&wndTopMost" instead of "&wndTop". When I do that, the window will become
the topmost window when it gets clicked on. So I KNOW the code is being
executed. I'd really appreciate any ideas on what I am doing wrong.
Thanks
void CMyAppDlg::OnSpecialFocusMsg(WPARAM wParam, LPARAM lParam)
{
// ::AfxMessageBox("Receiving Focus from Duplicate App -- This message
is temporary");
ShowWindow(SW_SHOWNORMAL);
BringWindowToTop();
SetWindowPos(&wndTop, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE |
SWP_NOMOVE);
SetForegroundWindow();
}
--
Don
This is a SPAMproof address. Please address all replies to the newsgroup
SetForegroundWindow in the previous instance will often only flash the
program, rather than bring the window to the front. You could try this
sequence in the new instance (that is about to quit):
SetForegroundWindow(); // to ensure that you are allowed to call the next
function
LockSetForegroundWindow(LSFW_UNLOCK); // turns off SetForegroundWindow
locking
(Now other applications, such as the previous instance) can call
SetForegroundWindow. Send your private message now.
I've never tried this, but the documentation seems to imply that it would
work.
Christian.