+ list = GetDlgItem(tablist[NSSM_TAB_PROCESS], IDC_AFFINITY);\r
+ n = num_cpus();\r
+ SendMessage(list, LB_SETCOLUMNWIDTH, 16, 0);\r
+ for (i = 0; i < n; i++) {\r
+ TCHAR buffer[3];\r
+ _sntprintf_s(buffer, _countof(buffer), _TRUNCATE, _T("%d"), i);\r
+ SendMessage(list, LB_ADDSTRING, 0, (LPARAM) buffer);\r
+ }\r
+\r
+ /*\r
+ Size to fit.\r
+ The box is high enough for four rows. It is wide enough for eight\r
+ columns without scrolling. With scrollbars it shrinks to two rows.\r
+ Note that the above only holds if we set the column width BEFORE
+ adding the strings.
+ */\r
+ if (n < 32) {\r
+ int columns = (n - 1) / 4;\r
+ RECT rect;\r
+ GetWindowRect(list, &rect);\r
+ int width = rect.right - rect.left;
+ width -= (7 - columns) * 16;\r
+ int height = rect.bottom - rect.top;\r
+ if (n < 4) height -= SendMessage(list, LB_GETITEMHEIGHT, 0, 0) * (4 - n);
+ SetWindowPos(list, 0, 0, 0, width, height, SWP_NOMOVE | SWP_NOOWNERZORDER);\r
+ }\r
+ SendMessage(list, LB_SELITEMRANGE, 1, MAKELPARAM(0, n));\r
+\r
+ SendDlgItemMessage(tablist[NSSM_TAB_PROCESS], IDC_AFFINITY_ALL, BM_SETCHECK, BST_CHECKED, 0);\r
+ set_affinity_enabled(0);\r
+\r