I had my program up and running fine, with my child windows running fine inside the main one. However, as soon as I called the function CreateDialog(...), such as by clicking on a menu item within my program, the program would automatically close.

Here is the basic code (ignore any functions that are irrelevant):



Code:
HWND hAboutDialog ; 
HWND g_hwnd;
BOOL CALLBACK AboutDlgProc(HWND , UINT , WPARAM ,  LPARAM);  


LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);		// Windows procedure

int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nShow)
{

	


    MSG messages;													// Window Messages
	

    WNDCLASSEX wincl;												// Window class
	DWORD dwStyle;													// Window Style
	nShow = SW_SHOW;
    
    wincl.hInstance = hThisInstance;								// Window Structure - Instance
    wincl.lpszClassName = szClassName;								// Window Structure - Class Name
    wincl.lpfnWndProc = WindowProcedure;							// Window Structure - Procedure
    wincl.style = CS_DBLCLKS;										// Window Structure - Style (catch dblclicks)
    wincl.cbSize = sizeof (WNDCLASSEX);								// Window Structure - Size

    
    wincl.hIcon = hIcon;											// Load Application's Icon
    wincl.hIconSm = hIcon;											// Load Application's Icon
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);					// Default cursor
    wincl.lpszMenuName = "myMenu";									// Create menu name
    wincl.cbClsExtra = 0;											// No extra bytes after window class
    wincl.cbWndExtra = 0;											// Window Instance
	
   
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;				// Set default background

    
    if (!RegisterClassEx (&wincl))									// If window class doesn't register -> Quit
        return 0;

	
	
	
	
	dwStyle = WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;	// Adjust window settings
		

    
    g_hwnd = CreateWindowEx (											// Create the window
           0,                   
           szClassName,												// Class Name
           "Isis Media",											// Window title
           dwStyle,													// Style
           CW_USEDEFAULT,											// Default position
           CW_USEDEFAULT,											// Default position
           1024,													// Width (px)
           768,														// Height (px)
           NULL,													
           hMenu,													// Load My Menu              
           hThisInstance,											// Instance handler
           NULL                 
           );

    hAboutDialog = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_ABOUT),g_hwnd,AboutDlgProc);
    ShowWindow (g_hwnd, nShow);			

				ShowWindow(hAboutDialog,SW_SHOW);							// Show the window on the screen
	

   
    while (GetMessage (&messages, NULL, 0, 0))						// Message loop
		{
       
        TranslateMessage(&messages);								// Translate virtual-key messages into character messages
        
        DispatchMessage(&messages);									// Send message to WindowProcedure 
    }

    
    return messages.wParam;											// The program return-value is 0 - The value that PostQuitMessage() gave 
}


/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)                  /* handle the messages */
    {
        case WM_DESTROY:
			PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
		case WM_COMMAND:
			GetMenuMessage(hwnd,wParam);							// Check to see if menu item was pressed
			
			break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}


BOOL CALLBACK AboutDlgProc(HWND hWnd, UINT message , WPARAM wParam,  LPARAM lParam)
	{
		
	switch(message)
		{
		case WM_INITDIALOG:
			return true;
			break;
		default:
		return DefDlgProc (hWnd, message, wParam, lParam);
		
		}

	return false;
	}



Everything is set up fine - I've created the dialog box, given it the correct identifier etc

Am I missing something stupid, such as not linking a specific library or is it something else?

(I decided against using MFC as I'm not too familiar with it!)

Thanks,

Ed