Reputation: 1434
I have a MFC dialog with 32 CComboBoxes on it that all have the same data in the listbox. Its taking a while to come up, and it looks like part of the delay is the time I need to spend using InsertString() to add all the data to the 32 controls. How can I subclass CComboBox so that the 32 instances share the same data?
Upvotes: 0
Views: 370
Reputation: 14115
One way along the lines of your request would be to go owner drawn - you will be writing a fair chunk of code, but you won't have to add the data to all of them. "CComboBox::DrawItem"
Support.microsoft have this article on subclassing a Combo box which might also be of interest "How to subclass CListBox and Cedit inside of CComboBox"
Really one has to ask if it is worth the effort, and alot of that depends things like
Upvotes: 0
Reputation: 308392
In addition to what has already been said, you might also turn off sorting in your combo box and presort the data before you insert it.
Upvotes: 0
Reputation: 6059
The first thing I would try is calling "InitStorage" to preallocate the internal memory for the strings. From MSDN:
// Initialize the storage of the combo box to be 256 strings with
// about 10 characters per string, performance improvement.
int n = pmyComboBox->InitStorage(256, 10);
Upvotes: 0
Reputation: 78688
Turn off window redrawing when filling the combos. e.g.:
m_wndCombo.SetRedraw(FALSE);
// Fill combo here
...
m_wndCombo.SetRedraw(TRUE);
m_wndCombo.Invalidate();
This might help.
Upvotes: 1