locked
dialogs appearing behind the main window RRS feed

  • Question

  • hey guys,

    i have a simple problem with  my MFC app. the messagebox's and color dialod's r appearing behind the main window.

    maybe is it because i have directx rendering a static text control in the main window so it always stays in focus or soemthing i dont know?

    here is my code for displaying for displaying a color dialog:

    CColorDialog cd = CColorDialog(0, CC_ANYCOLOR);
    cd.DoModal();


    when i press the alt button the color dialog appears.

    is there some special setting of some sort i have to do to get the dialogs to appear infront of the window? im quite new to mfc so sorry for my newbie questions.

    thx in advanced
    Friday, February 24, 2006 7:53 PM

Answers

  • Maybe the topmost style is being applied to the window containing the 3-d rendering.  You can use Spy++ to find ths out.

    Brian

     

    Monday, February 27, 2006 2:21 PM
  • Okay.  Try using Spy++ to determine how the window style of the parent of CColorDialog is affected by whether the static control is 3-d rendered (record Spy++ information with the 3-d-ness enabled, and then without).  Win32 can be weird and sometimes unforgiving when it comes with window styles.

    Use make sure that you're really pointing Spy++ to the parent of the dialog.  (Spy++ will tell you the parent of the CColorDialog window, if you point Spy++ to that dialog).

    Monday, February 27, 2006 6:49 PM

All replies

  • Is your main form (form1) set to


    this->TopMost = true;


    This will make the main form stay on top by defult.

    Saturday, February 25, 2006 6:28 PM
  • im not using .NET. this isnt form application.

    and the dialog for main application isnt my problem. my problem is in the messageboxes and colordialogs that appear behind my main window (dialog).

    Saturday, February 25, 2006 6:37 PM
  • A modal dialog is always on top of its parent window. CColorDialog takes the parent window as the third (optional) argument. 

    (This forum should be used for C++ language and tool issues.  Plus CColorDialog has good docs in MSDN.)

    Brian

     

    Saturday, February 25, 2006 7:00 PM
  • i understand it takes the window parent as a second parameter. i give it he main dialog window and it appears behind.

    notice when i render on a static control 3d stuff the CColorDialog appears behind, and other cases it appears on top as normal.

    Saturday, February 25, 2006 7:07 PM
  • The example you give above does not pass the parent window as the third argument.  That is a requirement.   Are you passing the frame window?

    Above this, I can't help you.  But you can try diagnosing the problem with a new MFC app.  Use the wizard to create one, and in the OnHelpAbout handler, try creating the CColorDlg.  Does it show above?  If so, analyze the differences between your app and the temporary one.  If you think 3-D static controls has something to do with it, then the temporary app should also exhibit the problem.

    Brian

    Saturday, February 25, 2006 7:30 PM
  • i understand the example i gave in doesnt have the window, but i am fiddling arround with it maybe it works as expected, but nop :(

    i think it is got to do with the 3d rendering im doing on the static control. cause another application i tried on, works perfectly.

    now im having trouble coloring a background of a button with a color a user chooses at run time with the colordialog :( i handled the WM_CTLCOLOR message as i saw on aq site, and it doesnt seem to work.

    all i want to do is a 3d tool application for my game engine. it is giving me a hard time!

    Saturday, February 25, 2006 7:36 PM
  • I did this once by accident, and it drove me crazy. I don't use MFC (but, I am a C++ programmer). It's surprisingly easy to do.

    In my case, I passed the wrong HWND to my WndProc. I passed a generic handle (hwnd), because I'd just copied and pasted the code from a source code example that I was using as the basis for actual excutable code. It compiles just fine in either case (which is what drives you nuts). What your dialogs and MessageBoxes are displaying to is the Desktop window. You want to pass the HWND that is returned from CreateWindow.

    In MFC, I know that you use Message Maps to set up your handler procedures, and CreateWindow is probably encapsulated in some MFC class (I don't know which one). I just use standard C++ source that calls the Windows API. So I don't know exactly where to look, but it's essentially a simple error to correct, once you know what to look for.

    Saturday, February 25, 2006 9:16 PM
  • well if you think its because of 3D rendering then why not disable it and try. if it works you will be sure its due to i3D rendering.

    Saurabh

    Monday, February 27, 2006 1:58 AM
  • well yeah it was from the 3d rendering, i disabled it and it worked just perfectly.

    now how can i over come this issue? any ideas?

    Monday, February 27, 2006 7:42 AM
  • Maybe the topmost style is being applied to the window containing the 3-d rendering.  You can use Spy++ to find ths out.

    Brian

     

    Monday, February 27, 2006 2:21 PM
  • the static control (text control) im rendering the 3d on doesnt have a topmost property in it.
    Monday, February 27, 2006 4:35 PM
  • Let me be more specific.  Exactly which window is the parent of the color dialog, and is it topmost?

    (Note: this conversation really belongs in a Win32 newsgroup, but you have us all hooked anyway.)

    Monday, February 27, 2006 5:30 PM
  • sorry if im causing problems

    here is a picture of my app im doing:

    http://img155.imageshack.us/img155/7515/problem2bo.jpg

    the control where i wrote 3D rendered here is the static text.

    notice the properties on the right belong to the the dialog, it has topmost to false.

    Monday, February 27, 2006 6:34 PM
  • Again, what is the actual parent window of the CColorDialog?  Is it the static control, or the application window?
    Monday, February 27, 2006 6:41 PM
  • the application, the main dialog.
    Monday, February 27, 2006 6:43 PM
  • Okay.  Try using Spy++ to determine how the window style of the parent of CColorDialog is affected by whether the static control is 3-d rendered (record Spy++ information with the 3-d-ness enabled, and then without).  Win32 can be weird and sometimes unforgiving when it comes with window styles.

    Use make sure that you're really pointing Spy++ to the parent of the dialog.  (Spy++ will tell you the parent of the CColorDialog window, if you point Spy++ to that dialog).

    Monday, February 27, 2006 6:49 PM
  • hm ok thx Brian. i Apologize for any trouble i caused. thx man
    • Proposed as answer by chrzx Sunday, July 6, 2014 3:14 AM
    Monday, February 27, 2006 6:52 PM
  • derive a class from CColorDialog and use ShowWindow(SW_SHOW) in OnInitDialog()
    Sunday, July 6, 2014 3:15 AM