dialogs appearing behind the main window

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


Answer this question

dialogs appearing behind the main window

  • lwrich

    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.


  • Fernando Celarino

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

    Brian


  • Dav? S. A???????

    the static control (text control) im rendering the 3d on doesnt have a topmost property in it.
  • GDogius

    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


  • bday55

    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


  • Jimdbc-LLC

    Again, what is the actual parent window of the CColorDialog Is it the static control, or the application window
  • Phillip Carruthers

    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


  • prem_kumar_25

    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!


  • seanslyvinia

    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.)


  • drinian

    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.


  • Emilis

    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


  • cabby

    Is your main form (form1) set to

  • jhepple

    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).


  • Marco Otte-Witte

    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.


  • dialogs appearing behind the main window