rgutt
rgutt

Reputation: 73

MFC Modal Dialog is behind other elements

I'm writting a tool which involves displaying data in a CListCtrl. When the user right clicks on an item a menu opens with the option to show more details.

I created a class CListCtrExt which extends the features of CListCtrl. When the user clicks on details of an item the function OnDetails is triggered.

void CListCtrlExt::OnDetails()
{
    CTableDetailsPPg detailsDialog;
    int res = detailsDialog.DoModal();
}

The dialog header:

class CTableDetailsPPg : public CDialogEx
{
    DECLARE_DYNAMIC(CTableDetailsPPg)

public:
    CTableDetailsPPg(CWnd* pParent = nullptr);   // standard constructor
    virtual ~CTableDetailsPPg();

    // Dialog Data
#ifdef AFX_DESIGN_TIME
    enum { IDD = IDD_TABLE_DETAILS };
#endif

protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

    DECLARE_MESSAGE_MAP()
};

The dialog cpp:

IMPLEMENT_DYNAMIC(CTableDetailsPPg, CDialogEx)

CTableDetailsPPg::CTableDetailsPPg(CWnd* pParent /*=nullptr*/)
    : CDialogEx(IDD_TABLE_DETAILS, pParent)
{

}

CTableDetailsPPg::~CTableDetailsPPg()
{
}

void CTableDetailsPPg::DoDataExchange(CDataExchange* pDX)
{
    CDialogEx::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CTableDetailsPPg, CDialogEx)
END_MESSAGE_MAP()

The dialog actually opens but is behind some elements. When I replace CTableDetailsPPg in OnDetails() with CTaskDialog it opens the Dialog in the foreground.

I was wondering how to get the dialog on top of the other elements?

enter image description here

Upvotes: 2

Views: 234

Answers (0)

Related Questions