Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1284
  • Last Modified:

Modal dialog hides behind MDI application window

In my MFC MDI application a dialog (derived from CDialog) is to be displayed when a button on a view (derived from CFormView) is clicked. The problem is that the dialog sometimes hides behind the application window. This is very queer since a modal dialog should always be in front of its parent window (mainframe in this case). I tried SetWindowPos(&wndTop,...) in its OnInitDialog(). But it does not work. Please suggest what may be going wrong.
Thanks for you time.
0
Toofani
Asked:
Toofani
  • 5
  • 4
1 Solution
 
AlexFMCommented:
Use pointer to View or Frame class in the dialog constructor. For example, to create dialof from CMainFrame class:

CMyDialog dlg(this);
dlg.DoModal();
0
 
ToofaniAuthor Commented:
Thanks AlexFM.
I have tried many tricks. I am passing the parent window too as suggested by you.
Further, I think if NULL is passed as the parent window argument in a dialog c'tor, the application's main window (mainframe in this case) is taken by default.
Do you have any other suggestion?
Thanks again.
0
 
AndyAinscowCommented:
Does the mainframe have any settings such as TOPMOST ?

Is the view or dialog in a dll ?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
ToofaniAuthor Commented:
Hi Andy,
The mainframe is not TOPMOST.
But the MDI application is invoked using CreateProcess() from another window application. Is anything special required for doing this?
Thanks for ur input.
0
 
AndyAinscowCommented:
<CreateProcess() from another window application. Is anything special required for doing this?>

Nothing should be required - that should just start the application as if the user had started it.



again
Is the view or dialog in a dll ?
0
 
ToofaniAuthor Commented:
<Is the view or dialog in a dll ?>
No, the view or dialog are not in a dll.
0
 
ToofaniAuthor Commented:
If I call SetWindowPos(&wndTop) a couple of times using the OnTimer() event in the dialog , it works. Though this is just a workaround (a desperate one!!).
Further, if the application is executed from command-line (not invoked from other application), the problem does not occur.
0
 
AndyAinscowCommented:
OK.  Please post the CreateProcess code
0
 
ToofaniAuthor Commented:
Hi Andy
Here's the code I use to execute the app
LPTSTR lpCmd;
//Set lpCmd as Application exe path
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
ZeroMemory(&pi, sizeof(pi));
si.cb = sizeof(si);
CString strCrtDirectory = _T("");
//set working directory to strCrtDirectory
bResult = CreateProcess(NULL, lpCmd, NULL, NULL, FALSE, 0, NULL, strCrtDirectory, &si, &pi);
::::
0
 
AndyAinscowCommented:
That looks pretty standard.

I'm puzzled.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now