Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
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

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


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:
C++
    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);
}


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

Appreciate any help!

Thank you.
Posted
Comments
Sergey Alexandrovich Kryukov 14-Nov-11 12:24pm    
How many items give you hard time? What do you do on selection and other events?
--SA
Member 8401110 14-Nov-11 12:31pm    
I have about 20 items in a combo box and have 15 of them in the dialog. There are other dialogs with abt 4 or so combo boxes and those are slow in coming up too.
On selection of an item, I just add to a database field, not too much processing in the combo at all.

1 solution

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
 
Share this answer
 
Comments
Member 8401110 14-Nov-11 12:30pm    
I have about 20 items in each Combo Box and 15 of them in the screen.
This was working just fine in the prev version of the software. Just because I upgraded the development environment the users should not experience any delay in the dialogs. should they ?
Sergey Alexandrovich Kryukov 14-Nov-11 13:45pm    
Hm. Sounds strange. It's not so many. What's the "previous"? Did you change platform? What is it?
--SA
Member 8401110 14-Nov-11 13:54pm    
It was all compiled with Visual C++ 6.0 previously. we upgraded to Visual Studio 2005 and suddenly noticed all these delays. So to be sure, I just took out this dialog alone into blank projects and compiled it in Visual Studio 2005 and VC++ 6.0 separately. The Visual C++ environment gave snappy results and VS2005 was slow...:(
Was wondering if I am missing some setting or property of the Combo
Albert Holguin 14-Nov-11 14:43pm    
this seems like you're doing something wrong... post some of the code maybe...
Albert Holguin 14-Nov-11 14:48pm    
Oops... I see the code up there... What method do you load the combo boxes in? ...should probably only be done once in OnInitDialog(), if you have it elsewhere, it may be getting called more than once by accident.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900