Search code examples
c++windowsdialogwinmain

Is it correct/proper to use DialogBox as the main window?


Is it correct-proper as in windows doesn't say it's bad or not recommended.

For example like this:

int APIENTRY _tWinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPTSTR    lpCmdLine,
                     int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);
    UNREFERENCED_PARAMETER(nCmdShow);

    INT_PTR result = DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAINWINDOWBOX), nullptr, MainWindow);

    return static_cast<int>( result );
}

Solution

  • Using a Dialog Box as the main window is actually supported as one of the default configurations by MFC, so yes, that's fine (according to Microsoft).

    For what it's worth, virtually every Windows app I've written in years used a dialog box as the main window, but that's because I don't write office-type applications.