27 typedef struct _COLUMNS_DIALOG_CONTEXT
45 _In_ HWND ParentWindowHandle,
46 _In_ HWND ControlHandle,
52 context.ControlHandle = ControlHandle;
71 static int __cdecl PhpColumnsCompareDisplayIndexTn(
72 _In_
const void *elem1,
73 _In_
const void *elem2
83 static ULONG IndexOfStringInList(
90 for (i = 0; i < List->Count; i++)
108 if (uMsg == WM_INITDIALOG)
130 context->InactiveList = GetDlgItem(hwndDlg,
IDC_INACTIVE);
131 context->ActiveList = GetDlgItem(hwndDlg,
IDC_ACTIVE);
143 while (count < total)
166 ListBox_AddString(context->InactiveList, column.
Text);
173 qsort(displayOrderList->
Items, displayOrderList->
Count,
sizeof(PVOID), PhpColumnsCompareDisplayIndexTn);
176 if (displayOrderList)
178 for (i = 0; i < displayOrderList->
Count; i++)
184 ListBox_AddString(context->ActiveList, copy->
Text);
191 SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(
IDC_INACTIVE, LBN_SELCHANGE), (LPARAM)context->InactiveList);
192 SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(
IDC_ACTIVE, LBN_SELCHANGE), (LPARAM)context->ActiveList);
199 for (i = 0; i < context->Columns->Count; i++)
200 PhFree(context->Columns->Items[i]);
207 switch (LOWORD(wParam))
210 EndDialog(hwndDlg, IDCANCEL);
214 #define ORDER_LIMIT 100
221 memset(orderArray, 0,
sizeof(orderArray));
224 activeCount = ListBox_GetCount(context->ActiveList);
227 for (i = 0; i < activeCount; i++)
236 for (i = 0; i < context->Columns->Count; i++)
241 index = IndexOfStringInList(activeList, column->
Text);
248 orderArray[index] = column->
Id;
250 if ((ULONG)maxOrder < index + 1)
251 maxOrder = index + 1;
262 InvalidateRect(context->ControlHandle, NULL,
FALSE);
265 EndDialog(hwndDlg, IDOK);
270 switch (HIWORD(wParam))
274 SendMessage(hwndDlg, WM_COMMAND,
IDC_SHOW, 0);
279 INT sel = ListBox_GetCurSel(context->InactiveList);
281 EnableWindow(GetDlgItem(hwndDlg,
IDC_SHOW), sel != -1);
289 switch (HIWORD(wParam))
293 SendMessage(hwndDlg, WM_COMMAND,
IDC_HIDE, 0);
298 INT sel = ListBox_GetCurSel(context->ActiveList);
299 INT count = ListBox_GetCount(context->ActiveList);
301 EnableWindow(GetDlgItem(hwndDlg,
IDC_HIDE), sel != -1 && count != 1);
302 EnableWindow(GetDlgItem(hwndDlg,
IDC_MOVEUP), sel != 0 && sel != -1);
303 EnableWindow(GetDlgItem(hwndDlg,
IDC_MOVEDOWN), sel != count - 1 && sel != -1);
315 sel = ListBox_GetCurSel(context->InactiveList);
316 count = ListBox_GetCount(context->InactiveList);
320 ListBox_DeleteString(context->InactiveList, sel);
321 ListBox_AddString(context->ActiveList, string->
Buffer);
326 if (sel >= count - 1)
329 ListBox_SetCurSel(context->InactiveList, sel);
331 SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(
IDC_INACTIVE, LBN_SELCHANGE), (LPARAM)context->InactiveList);
332 SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(
IDC_ACTIVE, LBN_SELCHANGE), (LPARAM)context->ActiveList);
342 sel = ListBox_GetCurSel(context->ActiveList);
343 count = ListBox_GetCount(context->ActiveList);
349 ListBox_DeleteString(context->ActiveList, sel);
350 ListBox_AddString(context->InactiveList, string->
Buffer);
355 if (sel >= count - 1)
358 ListBox_SetCurSel(context->ActiveList, sel);
360 SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(
IDC_INACTIVE, LBN_SELCHANGE), (LPARAM)context->InactiveList);
361 SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(
IDC_ACTIVE, LBN_SELCHANGE), (LPARAM)context->ActiveList);
372 sel = ListBox_GetCurSel(context->ActiveList);
373 count = ListBox_GetCount(context->ActiveList);
379 ListBox_DeleteString(context->ActiveList, sel);
380 ListBox_InsertString(context->ActiveList, sel - 1, string->
Buffer);
384 ListBox_SetCurSel(context->ActiveList, sel);
385 EnableWindow(GetDlgItem(hwndDlg,
IDC_MOVEUP), sel != 0);
386 EnableWindow(GetDlgItem(hwndDlg,
IDC_MOVEDOWN), sel != count - 1);
397 sel = ListBox_GetCurSel(context->ActiveList);
398 count = ListBox_GetCount(context->ActiveList);
400 if (sel != count - 1)
404 ListBox_DeleteString(context->ActiveList, sel);
405 ListBox_InsertString(context->ActiveList, sel + 1, string->
Buffer);
409 ListBox_SetCurSel(context->ActiveList, sel);
410 EnableWindow(GetDlgItem(hwndDlg,
IDC_MOVEUP), sel != 0);
411 EnableWindow(GetDlgItem(hwndDlg,
IDC_MOVEDOWN), sel != count - 1);