Carl Serl
Carl Serl

Reputation: 51

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 );
}

Upvotes: 0

Views: 331

Answers (2)

Orochi
Orochi

Reputation: 397

Yes definitely...Haven't you seen calculator (calc.exe)? it is a dialog based application having main window as a dialog.

Upvotes: 0

Bob Moore
Bob Moore

Reputation: 6894

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.

Upvotes: 2

Related Questions