Dialog box from a Dialog Box

Dialog box from a Dialog Box

Post by Nigel Philli » Sat, 25 Oct 1997 04:00:00



Hi all,

Ok, this should be simple. Creating a dialog box from within a dialog
box. Anything special needed? Mine returns a -1 (failure) everytime.

Thanks,
Nigel

Heres the code:

case IDC_ADVANCED:
  if((DialogBox (hinst, MAKEINTRESOURCE(IDD_ADVANCED), hdlg,
(DLGPROC)advanceddialog)) == -1)

MessageBox(hdlg, "Could not open Advanced Box", "Advanced DB Failed",
MB_ICONINFORMATION | MB_OK);

break;
.
.
.
.
BOOL CALLBACK advanceddialog(HWND hdlg, UINT iMsg, WPARAM wParam,
LPARAM lParam)
     {
        static char tempbuffer[150];
        //int count;

        switch (iMsg)
          {
          case WM_INITDIALOG :
         MessageBox(hdlg, "Hello World", "Hello World", MB_OK);
                          return TRUE;

          case WM_COMMAND :
               switch (LOWORD (wParam))
               {
               case IDOK :
               case IDCANCEL :
                 EndDialog (hdlg, 0) ;
                           return TRUE ;
               }
               break ;
          }
     return FALSE ;
     }

 
 
 

Dialog box from a Dialog Box

Post by David Lownd » Sat, 25 Oct 1997 04:00:00


Quote:>Ok, this should be simple. Creating a dialog box from within a dialog
>box. Anything special needed? Mine returns a -1 (failure) everytime.

Nigel,

There's nothing fundamentally wrong with doing that, have you put a
breakpoint in the sub-dialog's message handler to see if it's getting
there. Does the IDD_ADVANCED dialog exist in your resource file?

Can you invoke the IDD_ADVANCED dialog as a top level dialog?

Dave
----
Address is altered to discourage junk mail.
Remove ".---" for the real address.
http://www.bj.co.uk

 
 
 

Dialog box from a Dialog Box

Post by Ziggy » Tue, 28 Oct 1997 04:00:00


The only problem I see is that you are displaying UI from within the
WM_INITDIALOG handler of your advanced dialog. This shouldn't cause it to
fail, but it may cause other undefined behavior, typically having to do with
screwing up z-order or enable/disable status of owner/parent windows. A
safer way to do so is to post yourself a message from the initdialog handler
and then display the necessary UI. That way you let the dialog fully
initialize before it needs to handle messages like paint/activation, etc.

In any case, as I said that shouldn't cause it to plain fail. My guess that
a non-existent resource. I believe GetLastError should give a clue of the
problem as well.

-ZiggyM

--
TO REPLY  to me directly: remove the "___" from my email address.
DISCLAIMER: My opinions are mine, not Microsoft's
----


>Hi all,

>Ok, this should be simple. Creating a dialog box from within a dialog
>box. Anything special needed? Mine returns a -1 (failure) everytime.

>Thanks,
>Nigel

>Heres the code:

>case IDC_ADVANCED:
>  if((DialogBox (hinst, MAKEINTRESOURCE(IDD_ADVANCED), hdlg,
>(DLGPROC)advanceddialog)) == -1)

>MessageBox(hdlg, "Could not open Advanced Box", "Advanced DB Failed",
>MB_ICONINFORMATION | MB_OK);

>break;
>.
>.
>.
>.
>BOOL CALLBACK advanceddialog(HWND hdlg, UINT iMsg, WPARAM wParam,
>LPARAM lParam)
>     {
> static char tempbuffer[150];
> //int count;

> switch (iMsg)
>          {
>          case WM_INITDIALOG :
> MessageBox(hdlg, "Hello World", "Hello World", MB_OK);
>   return TRUE;

>          case WM_COMMAND :
>               switch (LOWORD (wParam))
>               {
>               case IDOK :
>               case IDCANCEL :
>                 EndDialog (hdlg, 0) ;
>    return TRUE ;
>               }
>               break ;
>          }
>     return FALSE ;
>     }

 
 
 

1. Calling a modeless dialog box from a modal dialog box

Hi,

Can a modal dialog box be the parent of a modeless dialog box?

I have a dialog box with 7 radio buttons.  Depending on which
button is selected, a different modeless dialog box is displayed.
The user will select a control on the modeless dialog box and then
both the modal and modeless dialog boxes should go away.

I am using VC++ and MFC.

Any help would be appreciated.

Cathy

2. collect: premature EOM

3. Calling a 2nd Dialog box from within another Dialog Box

4. Null pointer constant, part 2

5. How to kill a dialog box from another dialog box ?

6. Email app. frozen on Revo

7. Displaying a second DIALOG BOX from another DIALOG BOX????

8. How many blocks of memory does the xbox hard drive have anyway

9. HELP! Dialog Boxes within Dialog Boxes!

10. Dialog Box from Dialog Box

11. Dialog boxes from dialog boxes?

12. Dialog boxes from Dialog Boxes

13. Displaying a second DIALOG BOX from another DIALOG BOX????