Window on top from modla dialog

Hi,

i have amodla dialog from qhich i execute iexplorer process

with this code:

void CDiagToolDlg::OnGuida()
{
      WIN32_FIND_DATA fdata;
      HANDLE hSearch;
      CString Path;

      Path=_T("\\Disco rigido2\\HTML\\HELP\\Index.htm");
      hSearch=FindFirstFile(Path,&fdata);
      if (hSearch==INVALID_HANDLE_VALUE)
            return;
      else
            FindClose(hSearch);

      SHELLEXECUTEINFO      csSEI;
      RECT rect = {0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)};

      SystemParametersInfo(SPI_SETWORKAREA,  0,  &rect,  SPIF_SENDCHANGE);

      memset(&csSEI, 0, sizeof(csSEI));
      csSEI.cbSize = sizeof(SHELLEXECUTEINFO);
      csSEI.fMask = SEE_MASK_FLAG_NO_UI;
      csSEI.lpVerb = _T("open");
      csSEI.lpFile = Path;
      csSEI.nShow = SW_SHOWMAXIMIZED;
      
      ShellExecuteEx(&csSEI);
      Sleep(100);

      HWND hExplorerWnd = ::FindWindow(_T("IExplore"), NULL);
      ::PostMessage(hExplorerWnd,WM_COMMAND,0x3E9,0);
        

the problem is thata the modla dialog appear on top of the iexplorer window...

why?
rileo8Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZoppoCommented:
Hi rileo8,

>> the modla dialog appear on top of the iexplorer window
What kind of application is it (Dialog or Document/View)? Or, i.o.w. is the dialog your app's main window?
If not: is the Internet Explorer shown below your app's main window or above the main window but below the dialog?

I have a quite similar code in my application (except the SystemParametersInfo call, see below), here it works fine - the only difference I have is that I pass the dialog's window handle to ShellExecuteEx. Try to set cdSEI.hwnd = m_hWnd; before calling ShellExecuteEx.

I'm not sure if this maybe a cause, but it's worth a try: Does the same happen when you comment out the SystemParametersInfo? It might be this call causes some message being produced after the function terminates, maybe thus causing your dialog to be moved on top.

Hope that helps,

ZOPPO
rileo8Author Commented:
the modal window is a cdialog

the iexplorer window apperas over the main window but under the modla dialog window

i tried like this:

void CAggiornamentoDlg::OnHowToUpdate()
{
      WIN32_FIND_DATA fdata;
      HANDLE hSearch;
      CString Path;

      // file aggiornamento
      Path=_T("\\Disco rigido\\HTML\\Sit\\Leonardo_manuale.htm");
      hSearch=FindFirstFile(Path,&fdata);
      if (hSearch==INVALID_HANDLE_VALUE)
            return;
      else
            FindClose(hSearch);

      SHELLEXECUTEINFO      csSEI;
      RECT rect = {0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)};

//      SystemParametersInfo(SPI_SETWORKAREA,  0,  &rect,  SPIF_SENDCHANGE);

      memset(&csSEI, 0, sizeof(csSEI));
      csSEI.cbSize = sizeof(SHELLEXECUTEINFO);
      csSEI.fMask = SEE_MASK_FLAG_NO_UI;
      csSEI.lpVerb = _T("open");
      csSEI.lpFile = Path;
      csSEI.nShow = SW_SHOWMAXIMIZED;
      csSEI.hwnd = m_hWnd;
      
      ShellExecuteEx(&csSEI);
      Sleep(100);

      HWND hExplorerWnd = ::FindWindow(_T("IExplore"), NULL);
      ::PostMessage(hExplorerWnd,WM_COMMAND,0x3E9,0);
}

but nothing chages
ZoppoCommented:
Hi,

I guess there must be something special in either the dialog's or the parent window's implementation. I tested exactly the code you have from a modal dialog which is opened from a SDI application. It works fine at least with IExplorer and FireFox. What I think is very strange is the fact that a window appears between a modal dialog and it's parent window. This shouldn't be possible without any extra implementation.

On which Windows version does this happen? Do you work local on your PC or somehow remote or virtual (RDP, Citrix, VMWare, ...)?

Is the IExplorer window just temporary between the dialog and it's parent? Does it come to the top when you click it? And, if you toggle back to your application, does it completeley cover (dialog and it's parent) the IExplorer window?

ZOPPO
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

rileo8Author Commented:
is a windowsCE5 application.

If i exit from the dialog iexlprer is terminated
rileo8Author Commented:
correction:

it does not exit,
iexplorer is covered by modal dialog parent window
ZoppoCommented:
hm, ok - unfortunateley I fear I can't give further help: It seems this works different in WinCE than in WinXP or Win7. I have absoluteley no experience with WinCE. And I have no knowledge about differences between WinCE and desktop Windows. And I have no WinCE device where I could make some tests.

Sorry,

ZOPPO
rileo8Author Commented:
I tried also using

::BringWindowToTop(hExplorerWnd);

but it doesn't change
rileo8Author Commented:
Found teh solution...

on modal dialog init this piece of code was executed:

SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);

i comment out this and it worjs...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rileo8Author Commented:
It's the solution!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.