在MFC中管理类似控件的行的数据的最佳方法是什么? [英] What is the best way to manage data for rows of similar controls in MFC?

查看:74
本文介绍了在MFC中管理类似控件的行的数据的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个对话框,允许用户为一个对象的多个实例设置相同的属性.像这样:

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?

推荐答案

如果每一行都是子对话框,则控件数组和控件ID的问题将消失.您所要做的就是编写一个事物"的代码,然后管理一系列事物".

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中管理类似控件的行的数据的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆