// DialogBoxes.cpp : basic dialog box handling
//

#include <windows.h>
#include <tchar.h>
#include "resource.h"

BOOL MainDialog_OnCommand(HWND hWnd, WORD wCommand, WORD wNotify, HWND hControl)
{
    switch (wCommand)
    {
    case IDOK:
        MessageBox(hWnd, _T("Bye-bye world!"), _T("Sample Application"), MB_OK);

        // fall through

    case IDCANCEL:
        EndDialog(hWnd, wCommand);
        break;
    }
    return TRUE;
}

BOOL MainDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg)
    {
    case WM_COMMAND:
        return MainDialog_OnCommand(hWnd, LOWORD(wParam), HIWORD(wParam), (HWND)lParam);

    case WM_CLOSE:
        EndDialog(hWnd, 0);
        return TRUE;
    }
    return FALSE;
}

int _tmain(void)
{
    DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG1), 
        NULL, (DLGPROC)MainDialogProc, 0);
    return 0;
}