Sorry, I realize I posted very similar code a few days ago, but I have another question about it.

Code:
// Windows.cpp

#include <windows.h>
#include "Controls.h"

const char g_szClassName[] = "WindowClass";
HWND hWindowHandle;

char STSUsername[256];  // STS = String to store
char STSPassword[256];

////////////////////////////////////////////////////////////////////////////////
////////////////////////////// Control1 procedure //////////////////////////////
////////////////////////////////////////////////////////////////////////////////

BOOL CALLBACK Control1DlgProc(HWND hControl1Handle, UINT Message1, WPARAM wParam, LPARAM lParam)
{
    switch(Message1)
    {
        case WM_INITDIALOG:

            return TRUE;
        
            case WM_COMMAND:
            
                switch(LOWORD(wParam))
                {
                    case IDYES:
                        EndDialog(hControl1Handle, IDYES);
                        break;
                    
                    case IDNO:
                        EndDialog(hControl1Handle, IDNO);
                        break;
                        
                    default:
                        EndDialog(hControl1Handle, IDNO);
                        break;
                }
        
            break;
        
        default:
            return FALSE;
    }
    
    return TRUE;
}

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
////////////////////////////// Control2 procedure //////////////////////////////
////////////////////////////////////////////////////////////////////////////////

BOOL CALLBACK Control2DlgProc(HWND hControl2Handle, UINT Message2, WPARAM wParam, LPARAM lParam)
{
    switch(Message2)
    {
        case WM_INITDIALOG:
            
            SetDlgItemText(hControl2Handle, IDC_Username, "Administrator");
            
            case WM_COMMAND:
                
                switch(LOWORD(wParam))
                {
                    case IDOK:
                        
                        GetDlgItemText(hControl2Handle,IDC_Username,STSUsername,200);
                        GetDlgItemText(hControl2Handle,IDC_Password,STSPassword,200);
                        
                        EndDialog(hControl2Handle, IDOK);
                        break;
                    
                    case IDCANCEL:
                        EndDialog(hControl2Handle, IDCANCEL);
                        break;
                    
                    default:
                        EndDialog(hControl2Handle, IDCANCEL);
                }
            
            break;
            
    default:
        return FALSE;
            
    }
    
    return TRUE;
}    
            
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
///////////////////////// Step 4: the Window Procedure /////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

LRESULT CALLBACK WndProc(HWND hMainProcHandle, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
        case WM_CREATE:
            
            int Control1_Result;
            
            Control1_Result = DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Control1), hMainProcHandle, Control1DlgProc);
            
            if(Control1_Result == -1)
            {
                MessageBox(hWindowHandle, "Dialog failed!", "Error", MB_OK | MB_ICONINFORMATION);
                PostQuitMessage(0);
            }    
            
            else if (Control1_Result == IDYES)
            {
                ////////////////////////////////////////////////////////////////
                ////////////////////////////////////////////////////////////////
                ////////////////////////////////////////////////////////////////
                
                int Control2_Result;
                
                Control2_Result = DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Control2), hMainProcHandle, Control2DlgProc);
                
                while (Control2_Result != IDCANCEL && (STSUsername != "Username" && STSPassword != "Password"))
                {
                    MessageBox(hWindowHandle, "     Invlaid username or password.                   \n               Please try again.", "Windows Application", MB_ICONEXCLAMATION | MB_OK);
                    Control2_Result = DialogBox(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_Control2), hMainProcHandle, Control2DlgProc);
                }    
                
                PostQuitMessage(0);
                
                ////////////////////////////////////////////////////////////////
                ////////////////////////////////////////////////////////////////
                ////////////////////////////////////////////////////////////////
            }
            
            else
            {
                PostQuitMessage(0);
            }    
            
            break;
        
        case WM_CLOSE:
            DestroyWindow(hMainProcHandle);
            break;
            
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
            
        default:
            return DefWindowProc(hMainProcHandle, msg, wParam, lParam);
    }
    
    return 0;
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{
    WNDCLASSEX wc;
    MSG MainMessage;

    //Step 1: Registering the Window Class
    
    wc.cbSize        = sizeof(WNDCLASSEX);
    wc.style         = 0;
    wc.lpfnWndProc   = WndProc;
    wc.cbClsExtra    = 0;
    wc.cbWndExtra    = 0;
    wc.hInstance     = hInstance;
    wc.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 11);
    wc.lpszMenuName  = NULL;
    wc.lpszClassName = g_szClassName;
    wc.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);

    if(!RegisterClassEx(&wc))
    {
        MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
        return 0;
    }

    // Step 2: Creating the Window
    
    hWindowHandle = CreateWindowEx(
        WS_EX_CLIENTEDGE | WS_EX_TOPMOST,
        g_szClassName,
        "Windows Application",
        WS_DLGFRAME,
        0, 0, 240, 240,
        NULL, NULL, hInstance, NULL);

    if(hWindowHandle == NULL)
    {
        MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
        return 0;
    }
    
    // Step 3: The Message Loop
    
    while(GetMessage(&MainMessage, NULL, 0, 0) > 0)
    {
        TranslateMessage(&MainMessage);
        DispatchMessage(&MainMessage);
    }
    
    return MainMessage.wParam;
}
Code:
// Controls.rc

#include <afxres.h>
#include "Controls.h"

IDD_Control1 DIALOG DISCARDABLE  0, 0, 240, 65

STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_CENTER
CAPTION "Windows Application"
FONT 8, "MS Sans Serif"

BEGIN
    
    DEFPUSHBUTTON   "&Yes", IDYES, 174, 18, 50, 14
    PUSHBUTTON      "&No", IDNO, 174, 35, 50, 14
    GROUPBOX        "Login", IDC_STATIC, 7, 7, 225 ,52
    CTEXT           "Do you wish to login to Windows Application?", IDC_STATIC, 16, 26, 120, 20
    
END

////////////////////////////////////////////////////////////////////////////////

IDD_Control2 DIALOG DISCARDABLE 0, 0, 150, 150

STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | DS_CENTER
CAPTION "Windows Application"
FONT 8, "MS Sans Serif"

BEGIN

    GROUPBOX    "Login", IDC_STATIC, 7, 7, 136, 136
    LTEXT       "Username:", IDC_STATIC, 16, 32, 33, 7
    LTEXT       "Password:", IDC_STATIC, 16, 45, 33, 7
    DEFPUSHBUTTON  "OK", IDOK, 28, 121, 50, 14
    PUSHBUTTON  "Cancel", IDCANCEL, 85, 121, 50, 14
    
    EDITTEXT    IDC_Username, 56, 32, 80, 8, ES_AUTOHSCROLL
    EDITTEXT    IDC_Password, 56, 45, 80, 8, ES_AUTOHSCROLL | ES_PASSWORD
    
END
And a header that works and shouldn't have anything to do with my problem. Oh, by the way, here it is: Whenever I click on either the username or password edit boxes, the dialog closes. Is this meant to happen? Is there some code that needs to be added to prevent this from happening? I've looked through a few examples, and in them, it only mentioned the edit boxes in the .rc file, so I did the same. I'm on XP Pro, and using Dev-C++ if it matters.

Thanks in advance for any future replies.
Necrofear