Visual Studio 2005(c ++)中的组合框性能 [英] Combo Box Performance in Visual Studio 2005 (c++)

查看:93
本文介绍了Visual Studio 2005(c ++)中的组合框性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Visual Studio 2005中,组合框非常慢,我遇到了一个问题.
我有一个包含15个组合框的对话框,并使用
将其填充在InitDialog中

I have an issue with the Combo Boxes being very slow in Visual Studio 2005.
I have a dialog with 15 combo boxes and I fill them up in InitDialog using

::SendMessage(pCtl->m_hWnd, CB_ADDSTRING , 0, (LPARAM) "TestString"); //just adding the same string for testing



这似乎需要很长时间,并且正在影响我的程序的性能.我在Visual C ++ 6.0中执行了完全相同的代码,并且显示速度非常快.对函数进行了滴答计数,Visual Studio花费了大约750毫秒,而Visual C ++ 6.0仅花费了15毫秒!
我在这里做错什么了吗?

这是完整的代码:



This seems to take long and is affecting the performance of my program. I did the same exact code in Visual C++ 6.0 and it comes up quite fast. Did a tick count for the function and Visual Studio took around 750 milliseconds while Visual C++ 6.0 took only 15 !
Am I doing something wrong here ?

Here is the full code:

    CWnd *pCtl;
    int cid, clrId;
for (cid = LB_LIST1; cid <= LB_lIST_LAST; cid++)
{
    pCtl = GetDlgItem(cid);
    for(clrId = 0; clrId < 21; clrId++)
    {
        ::SendMessage(pCtl->m_hWnd, CB_ADDSTRING , 0, (LPARAM) "testString");
    }
    ::SendMessage(pCtl->m_hWnd, CB_SETCURSEL, 0, (LPARAM)0);
}



(组合框的ID连续编号定义为LB_LIST1至LB_LIST_LAST.)

感谢您的帮助!

谢谢.



(The ids for the Combo Boxes are defined as LB_LIST1 to LB_LIST_LAST in consecutive numbers.)

Appreciate any help!

Thank you.

推荐答案

谁在乎ComboBox性能?仅当您处理很少的项目(不超过10到20个左右)时,此组件才有用.如果您的组合框可以容纳更多物品,从而使物品甚至不适合屏幕,则表明设计错误.它实际上使该组件不可用.如果不算太少,除非您对选择的处理太糟糕,否则性能问题不会显示任何明显的延迟.无论如何,您不能为此问题归咎于ComboBox.

—SA
Who cares about ComboBox performance, ever? This component is only good if you deal with very few items, no more than 10-20 or so. If your combo box holds more so the items don''t even fit the screen, this is a clear sign of wrong design; it makes this component practically unusable. If it''s less, no performance problem can show any noticeable delay, unless you screw up the processing of selection too badly. Anyway, you could not blame ComboBox for this problem.

—SA


这篇关于Visual Studio 2005(c ++)中的组合框性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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