Thread: Dialog Box causes program to exit

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User mikeman118's Avatar
    Join Date
    Aug 2007
    Posts
    183
    Quote Originally Posted by norbs27 View Post
    Nope still nothing! I had tried it with HWND as NULL in the CreateDialog statement and the effect is still the same. In response to Elysia, my code is laid out properly in VC++, it's just this forum word wraps it when I copy and paste, and I don't really see the need to go through it all and correct the line spacing when the code is still essentially the same...
    Well putting the HWND as NULL certainly won't fix the problem
    Last edited by mikeman118; 01-13-2008 at 08:37 PM.

  2. #2
    Registered User mikeman118's Avatar
    Join Date
    Aug 2007
    Posts
    183
    Okay, I've just realized the problem (I think): you're trying to use CreateWindow to make a window that's already there. You need to use the DialogBox() function, like this:
    Code:
    DialogBox(GetModuleHandle(NULL), 
               MAKEINTRESOURCE(/*Dialog Name*/), hwnd, /*Dialog Procedure*/);
    That should most likely fix your problem.

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    For a start.....

    Is hMenu VALID when you use it?

    Does the WM_INITDIALOG in the aboutdlg proc get called (put a breakpoint in there)?

    Why are you returning TRUE to WM_INITDIALOG in the aboutdlg proc (do you have a control to set focus to)?

    Why are you not testing that calls to create windows/dialogs succeed (ie return valid HWNDs before you use the HWND)?

    What does GetLastError() return when you app fails?

    Where is your use of IsDialogMessage()?

    Where is your call to RegisterClass() for the About Dlg? [as required by your use of DefDlgProc()]


    As your code is all over the place (not indented correctly, shortcuts in syntax, etc) I can not see the error (nor can I be bothered re-indenting it to see if it is a syntax error).

    I have used many versions of MSVC and not had the issue you describe when posting here.

    Look at the code posted by Elysia. The syntax error in that code is MUCH easier to spot than in your code.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  2. Dynamic array of pointers
    By csisz3r in forum C Programming
    Replies: 8
    Last Post: 09-25-2005, 02:06 PM
  3. Making dialog box the only window
    By PJYelton in forum Windows Programming
    Replies: 2
    Last Post: 09-06-2005, 12:02 PM
  4. validate data in a dialog box
    By COBOL2C++ in forum Windows Programming
    Replies: 4
    Last Post: 09-22-2003, 01:55 PM
  5. Simple Dialog Box (noob)
    By tegwin in forum Windows Programming
    Replies: 6
    Last Post: 06-30-2002, 06:04 PM