I've got a dialog with several largeish combo boxes in it (maybe several hundred items apiece). There's a noticeable delay at construction while these are populated (confirmed that it's them by profiling).
My initial thought was that sorting was killing it's performance, but disabling sort and using InsertString instead doesn't seem to make things much better. I hadn't thought that it seemed like an excessive number of items - is there something else I should be doing or considering here?
The MFC calls are trivial wrappers to Win32 message calls so I don't think there's any significant overhead there.
DUPLICATE How to load a large array of strings in to an MFC combobox control fast as possible?
You should be using CWnd::SetRedraw around your adds, to prevent the control updating all its internal state after each add.
If you're not already doing it, then do this:
combo.SetRedraw(FALSE);
... All the adds
combo.SetRedraw(TRUE);
combo.Invalidate();
You should also consider using the CComboBox::InitStorage function, which preallocates memory for the combo-box.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With