1

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.

Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164
  • What is it in the Windows resource? Is the WS_VISIBLE flag set in the resource? If it is, remove the flag from the resource? – Joseph Willcoxson Nov 23 '22 at 14:46
  • @JosephWillcoxson Can’t do that because I also use it as a visible modal editor. I used the linked answer. I set a bool flag and added the winposchangi g event handler. – Andrew Truckle Nov 23 '22 at 15:17

0 Answers0