What is the best way to manage data for rows of si

2019-08-22 15:05发布

问题:

I want to create a dialog that allows the user to set the same attributes for several instances of an object. Something like:

It has been suggested that I create a titleless, modeless dialog for the row then instantiate it multiple times and maintain an array the objects for the row class. I tried that I got partway there but not quite. It seems my issue may have been clipping. I now have something working:

BOOL CPropPageDI::OnInitDialog()
{
    CPropertyPage::OnInitDialog();

    CRowDI* row = new CRowDI();

    CRect rect;
    CWnd* pos = GetDlgItem(IDC_POS_DI);
    pos->GetWindowRect(&rect);
    // Make sure that the row fits
    rect.right = rect.left + 492;
    rect.bottom = rect.top + 55;

    ScreenToClient(&rect);
    row->Create(IDD_ROW_DI, this);
    row->MoveWindow(&rect);
    row->ShowWindow(SW_SHOW);

I see the property page but it seems empty. Is there something else I have to do to make the row show up?

回答1:

If each row is a child dialog then issues of control arrays and control IDs disappear. All you have to write is the code for one 'Thing' and then manage an array of 'Things'.

In this case a child dialog would be a modeless dialog with the titlebar style turned off, so the visual result would be the same as your example.



标签: mfc