'wxWidgets C++ wxDirDialog shows empty window and pauses the program

my C++ code

void MyFrame::sub_load_directory(wxCommandEvent& evt)
{
    // Create a new wxDirDialog dialog
    wxDirDialog* dirDialog = new wxDirDialog(this);

    // Display the dialog and transfer the contents to
    // the wxTextCtrl on the main frame if the user
    // doesn't cancel
    if (dirDialog->ShowModal() == wxID_OK)     \\ Program pauses here
    {
        txtOutputFile->SetValue(dirDialog->GetPath());
    }

    dirDialog->Destroy();
}

Im using wxWidgets 3.1.5 on Windows 11, ive copied the examples and if just pauses the program . WxFileDialog works , so wxDirDialog should also work



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source