static const WCHAR szMainWndClass[] = L"ServManWndClass";
-BOOL bSortAscending = TRUE;
-
-
/* Toolbar buttons */
static const TBBUTTON Buttons [] =
{ /* iBitmap, idCommand, fsState, fsStyle, bReserved[2], dwData, iString */
{TBICON_REFRESH, ID_REFRESH, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}, /* refresh */
{TBICON_EXPORT, ID_EXPORT, TBSTATE_ENABLED, BTNS_BUTTON, {0}, 0, 0}, /* export */
- /* Note: First item for a seperator is its width in pixels */
+ /* Note: First item for a separator is its width in pixels */
{15, 0, TBSTATE_ENABLED, BTNS_SEP, {0}, 0, 0}, /* separator */
{TBICON_CREATE, ID_CREATE, TBSTATE_INDETERMINATE, BTNS_BUTTON, {0}, 0, 0 }, /* create */
static INT CALLBACK
CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
- ENUM_SERVICE_STATUS_PROCESS *Param1;
- ENUM_SERVICE_STATUS_PROCESS *Param2;
-// INT iSubItem = (LPARAM)lParamSort;
+ PMAIN_WND_INFO Info = (PMAIN_WND_INFO)lParamSort;
+ WCHAR Item1[256], Item2[256];
- if (bSortAscending) {
- Param1 = (ENUM_SERVICE_STATUS_PROCESS *)lParam1;
- Param2 = (ENUM_SERVICE_STATUS_PROCESS *)lParam2;
- }
- else
- {
- Param1 = (ENUM_SERVICE_STATUS_PROCESS *)lParam2;
- Param2 = (ENUM_SERVICE_STATUS_PROCESS *)lParam1;
- }
- return _wcsicmp(Param1->lpDisplayName, Param2->lpDisplayName);
+ ListView_GetItemText(Info->hListView, lParam1, Info->SortSelection, Item1, sizeof(Item1) / sizeof(WCHAR));
+ ListView_GetItemText(Info->hListView, lParam2, Info->SortSelection, Item2, sizeof(Item2) / sizeof(WCHAR));
+
+ return wcscmp(Item1, Item2) * Info->SortDirection;
}
RunActionWithProgress(Info->hMainWnd,
Info->pCurrentService->lpServiceName,
Info->pCurrentService->lpDisplayName,
- ACTION_START);
+ ACTION_START,
+ NULL); //FIXME: Add start params
UpdateServiceStatus(Info->pCurrentService);
ChangeListViewText(Info, Info->pCurrentService, LVSTATUS);
RunActionWithProgress(Info->hMainWnd,
Info->pCurrentService->lpServiceName,
Info->pCurrentService->lpDisplayName,
- ACTION_STOP);
+ ACTION_STOP,
+ NULL);
UpdateServiceStatus(Info->pCurrentService);
ChangeListViewText(Info, Info->pCurrentService, LVSTATUS);
RunActionWithProgress(Info->hMainWnd,
Info->pCurrentService->lpServiceName,
Info->pCurrentService->lpDisplayName,
- ACTION_PAUSE);
+ ACTION_PAUSE,
+ NULL);
UpdateServiceStatus(Info->pCurrentService);
ChangeListViewText(Info, Info->pCurrentService, LVSTATUS);
RunActionWithProgress(Info->hMainWnd,
Info->pCurrentService->lpServiceName,
Info->pCurrentService->lpDisplayName,
- ACTION_RESUME);
+ ACTION_RESUME,
+ NULL);
UpdateServiceStatus(Info->pCurrentService);
ChangeListViewText(Info, Info->pCurrentService, LVSTATUS);
RunActionWithProgress(Info->hMainWnd,
Info->pCurrentService->lpServiceName,
Info->pCurrentService->lpDisplayName,
- ACTION_RESTART);
+ ACTION_RESTART,
+ NULL);
UpdateServiceStatus(Info->pCurrentService);
ChangeListViewText(Info, Info->pCurrentService, LVSTATUS);
break;
case ID_VIEW_LARGE:
- SetListViewStyle(Info->hListView,
- LVS_ICON);
+ SetListViewStyle(Info->hListView, LVS_ICON);
+ ListView_Arrange(Info->hListView, LVA_DEFAULT);
+
CheckMenuRadioItem(GetMenu(Info->hMainWnd),
ID_VIEW_LARGE,
ID_VIEW_DETAILS,
break;
case ID_VIEW_SMALL:
- SetListViewStyle(Info->hListView,
- LVS_SMALLICON);
+ SetListViewStyle(Info->hListView, LVS_SMALLICON);
+ ListView_Arrange(Info->hListView, LVA_DEFAULT);
+
CheckMenuRadioItem(GetMenu(Info->hMainWnd),
ID_VIEW_LARGE,
ID_VIEW_DETAILS,
case LVN_COLUMNCLICK:
{
LPNMLISTVIEW pnmv = (LPNMLISTVIEW) lParam;
+ HDITEM hdi;
+
+ /* get pending sort direction for clicked column */
+ hdi.mask = HDI_LPARAM;
+ (void)Header_GetItem(Info->hHeader, pnmv->iSubItem, &hdi);
+
+ /* get new sort parameters */
+ Info->SortSelection = pnmv->iSubItem;
+ Info->SortDirection = hdi.lParam;
+
+ /* set new sort direction and save */
+ hdi.lParam = (hdi.lParam == ORD_ASCENDING) ?
+ ORD_DESCENDING : ORD_ASCENDING;
+
+ (void)Header_SetItem(Info->hHeader, pnmv->iSubItem, &hdi);
- (void)ListView_SortItems(Info->hListView,
- CompareFunc,
- pnmv->iSubItem);
- bSortAscending = !bSortAscending;
+ (void)ListView_SortItemsEx(Info->hListView,
+ CompareFunc,
+ (LPARAM)Info);
}
break;
-
case LVN_ITEMCHANGED:
{
LPNMLISTVIEW pnmv = (LPNMLISTVIEW) lParam;
case WM_CLOSE:
{
- HeapFree(ProcessHeap,
- 0,
- Info->pAllServices);
-
+ FreeServiceList(Info);
DestroyMenu(Info->hShortcutMenu);
DestroyWindow(hwnd);
}