2

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

Jabberwocky
  • 48,281
  • 17
  • 65
  • 115
rgutt
  • 43
  • 5
  • How is `OnDetails` triggered? You need to show some more details of your `CListCtrlExt` class. Your `CTableDetailsPPg` class looks OK. – Jabberwocky Oct 15 '21 at 12:03
  • 1
    Try specifying the application's main window as parent of the modal dialog box in the dialog's constructor, eg `CTableDetailsPPg detailsDialog(AfxGetMainWnd());` or `CTableDetailsPPg detailsDialog(theApp.m_pMainWnd);` Also try the `CListCtrlExt` as parent, eg `CTableDetailsPPg detailsDialog(this);`, in this case it will be blocking the the `CListCtrlExt` window only. You can try the `WS_EX_TOPMOST` window style too. – Constantine Georgiou Oct 15 '21 at 13:19
  • 1
    How does the window that appears to render through to the front perform its painting? How is it registered (particularly, with which class styles)? Are you, by chance, trying to create a window hierarchy across multiple threads? Producing a [mcve] would help a lot in delivering a definitive answer. – IInspectable Oct 15 '21 at 16:18

0 Answers0