Andrew Truckle
Andrew Truckle

Reputation: 19207

Can I programmatically set this modeless dialog to be hidden so it is not even seen momentarily?

In my application I have two editors and each editor is displayed in a modal dialog.

I am working on some test code to use one editor from within the other editor, to obtain data. This second editor is being loaded as a modeless dialog:

void CChristianLifeMinistryEditorDlg::EditDutyAssignments()
{
    auto pDlgReport = std::make_unique<CCreateReportDlg>();
    if (pDlgReport != nullptr && m_pEntry != nullptr)
    {
        pDlgReport->SetFileToOpen(L"d:\\test.srr", L"test.srr");
        pDlgReport->Create(IDD_DIALOG_CREATE, this);
        pDlgReport->ShowWindow(SW_HIDE);

        // Do stuff

        pDlgReport->DestroyWindow();
    }
}

The problem is that the modeless dialog flashes, Can I configure it programmatically to not be visible in this context?


I tried:

DWORD dwStyle = ::GetWindowLong(pDlgReport->GetSafeHwnd(), GWL_STYLE);
dwStyle &= ~WS_VISIBLE; //remove WS_VISIBLE
::SetWindowLong(pDlgReport->GetSafeHwnd(), GWL_STYLE, dwStyle);

pDlgReport->Create(IDD_DIALOG_CREATE, this);
pDlgReport->ShowWindow(SW_HIDE);

And it did not work. I think this is because the Create method is loading the actual dialog resource and thus overriding my style changes.

Upvotes: 1

Views: 29

Answers (0)

Related Questions