Dialog box bottleneck

Hello,

In the following code there seems to be a bottleneck that increases ever time I create a dialog box.

Here is the code that is called when the dialog box procedure receives the
WM_INITDIALOG message.

char buffer[30];
for (int i = 1; i <= 31; i++) {
sprintf_s(buffer,sizeof(buffer), "%d", i);

SendMessage(cmb_box1, CB_ADDSTRING, 0, (LPARAM)buffer);
SendMessage(cmb_box4, CB_ADDSTRING, 0, (LPARAM)buffer);
}

for (int i = 0; i < 12; i++) {
SendMessage(cmb_box2, CB_ADDSTRING, 0, (LPARAM)monthNames[i]);
SendMessage(cmb_box5, CB_ADDSTRING, 0, (LPARAM)monthNames[i]);
}

for (int i = 1920; i <= 2025; i++) {
sprintf_s(buffer, sizeof(buffer),"%d", i);
SendMessage(cmb_box3, CB_ADDSTRING, 0, (LPARAM)buffer);
SendMessage(cmb_box6, CB_ADDSTRING, 0, (LPARAM)buffer);
}

Can anyone shed some light on this ?
how many did you make?

are you making and destroying tons? is the form its own class, and does it destroy itself cleanly?

too many of these created at once could be a little slow, this is just a windows thing, after some number of dialogs are created the whole OS slows down, nothing specific to your stuff.

is this in debug mode or release mode? I don't remember how it acts in debug mode.

-- can you keep the dialog around with show-hide approach instead of destroy/create approach? That isnt suitable for everything but when it works, its a LOT faster.
I decided that your show-hide solution was fast and simple and have used it in my code.
Topic archived. No new replies allowed.