26 #define WM_PH_LOG_UPDATED (WM_APP + 300)
37 static RECT MinimumSize;
38 static HWND ListViewHandle;
39 static ULONG ListViewCount;
65 _In_opt_ PVOID Parameter,
66 _In_opt_ PVOID Context
72 static VOID PhpUpdateLogList(
77 ListView_SetItemCountEx(ListViewHandle, ListViewCount, LVSICF_NOSCROLL);
81 if (ListView_IsItemVisible(ListViewHandle, ListViewCount - 2))
83 ListView_EnsureVisible(ListViewHandle, ListViewCount - 1,
FALSE);
88 static PPH_STRING PhpGetStringForSelectedLogEntries(
95 if (ListViewCount == 0)
100 i = ListViewCount - 1;
105 SYSTEMTIME systemTime;
111 if (!(ListView_GetItemState(ListViewHandle, ListViewCount - i - 1, LVIS_SELECTED) & LVIS_SELECTED))
117 entry = PhGetItemCircularBuffer_PVOID(&
PhLogBuffer, i);
155 ListViewHandle = GetDlgItem(hwndDlg,
IDC_LIST);
176 MinimumSize.left = 0;
178 MinimumSize.right = 290;
179 MinimumSize.bottom = 150;
180 MapDialogRect(hwndDlg, &MinimumSize);
184 Button_SetCheck(GetDlgItem(hwndDlg,
IDC_AUTOSCROLL), BST_CHECKED);
188 ListView_EnsureVisible(ListViewHandle, ListViewCount - 1,
FALSE);
205 switch (LOWORD(wParam))
209 DestroyWindow(hwndDlg);
222 selectedCount = ListView_GetSelectedCount(ListViewHandle);
224 if (selectedCount == 0)
227 string = PhpGetStringForSelectedLogEntries(
TRUE);
232 string = PhpGetStringForSelectedLogEntries(
FALSE);
238 SetFocus(ListViewHandle);
245 { L
"Text files (*.txt)", L
"*.txt" },
246 { L
"All files (*.*)", L
"*.*" }
277 string = PhpGetStringForSelectedLogEntries(
TRUE);
285 PhShowStatus(hwndDlg, L
"Unable to create the file", status, 0);
296 LPNMHDR header = (LPNMHDR)lParam;
298 switch (header->code)
300 case LVN_GETDISPINFO:
302 NMLVDISPINFO *dispInfo = (NMLVDISPINFO *)header;
305 entry = PhGetItemCircularBuffer_PVOID(&
PhLogBuffer, ListViewCount - dispInfo->item.iItem - 1);
307 if (dispInfo->item.iSubItem == 0)
309 if (dispInfo->item.mask & LVIF_TEXT)
311 SYSTEMTIME systemTime;
316 wcsncpy_s(dispInfo->item.pszText, dispInfo->item.cchTextMax, dateTime->
Buffer, _TRUNCATE);
320 else if (dispInfo->item.iSubItem == 1)
322 if (dispInfo->item.mask & LVIF_TEXT)
327 wcsncpy_s(dispInfo->item.pszText, dispInfo->item.cchTextMax, string->
Buffer, _TRUNCATE);