// Used to call the sort operation void CSIPropertyPage::OnColumnClick(LPNMLISTVIEW pLVInfo) { static int sortColumn = 0; static BOOL sortAscend = TRUE; LPARAM lParamSort; if (pLVInfo->iSubItem == sortColumn) { sortAscend = !sortAscend; } else { sortColumn = pLVInfo->iSubItem; sortAscend = TRUE; } // Combine values to pass to sort function lParamSort = 1 + sortColumn; if (!sortAscend) { lParamSort = -lParamSort; } // Sort list view ListView_SortItemsEx(pLVInfo->hdr.hwndFrom, ListViewCompare, lParamSort); // Toggle sort icon SetSortIcon(pLVInfo->hdr.hwndFrom, sortColumn, sortAscend + 1); }
// Refresh the Favorite Games List void RefreshFavGameList() { ListView_DeleteAllItems(hFavListView); // Clean the Favorite Games List ParseFavListDat(); // Parse the 'favorites.dat' SetFavListViewContent(); ListView_SortItemsEx(hFavListView, ListView_CompareFunc, (LPARAM)hFavListView); // Sort Favorite Games List (macro) }
// This method clears the list and adds contacts again, according to the current filter settings. void RebuildList() { LPSTR pszProto; MTime mtNow; MAnnivDate ad; int i = 0; DWORD age = 0; WORD wDaysBefore = db_get_w(NULL, MODNAME, SET_REMIND_OFFSET, DEFVAL_REMIND_OFFSET); WORD numMale = 0; WORD numFemale = 0; WORD numContacts = 0; WORD numBirthContacts = 0; ShowWindow(_hList, SW_HIDE); DeleteAllItems(); mtNow.GetLocalTime(); // insert the items into the list for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) { // ignore meta subcontacts here, as they are not interesting. if (!db_mc_isSub(hContact)) { // filter protocol pszProto = Proto_GetBaseAccountName(hContact); if (pszProto) { numContacts++; switch (GenderOf(hContact, pszProto)) { case 'M': numMale++; break; case 'F': numFemale++; } if (!ad.DBGetBirthDate(hContact, pszProto)) { age += ad.Age(&mtNow); numBirthContacts++; // add birthday if ((_filter.bFilterIndex != FILTER_ANNIV) && (!_filter.pszProto || !_strcmpi(pszProto, _filter.pszProto))) AddRow(hContact, pszProto, ad, mtNow, wDaysBefore); } // add anniversaries if (_filter.bFilterIndex != FILTER_BIRTHDAY && (!_filter.pszProto || !_strcmpi(pszProto, _filter.pszProto))) for (i = 0; !ad.DBGetAnniversaryDate(hContact, i); i++) if (!_filter.pszAnniv || !mir_tstrcmpi(_filter.pszAnniv, ad.Description())) AddRow(hContact, pszProto, ad, mtNow, wDaysBefore); } } } ListView_SortItemsEx(_hList, (CMPPROC)cmpProc, this); ShowWindow(_hList, SW_SHOW); // display statistics SetDlgItemInt(_hDlg, TXT_NUMBIRTH, numBirthContacts, FALSE); SetDlgItemInt(_hDlg, TXT_NUMCONTACT, numContacts, FALSE); SetDlgItemInt(_hDlg, TXT_FEMALE, numFemale, FALSE); SetDlgItemInt(_hDlg, TXT_MALE, numMale, FALSE); SetDlgItemInt(_hDlg, TXT_AGE, numBirthContacts > 0 ? (age - (age % numBirthContacts)) / numBirthContacts : 0, FALSE); }
// grid handler BOOL GridNotify(WPARAM wParam, LPARAM lParam) { LV_DISPINFO *pI = (LV_DISPINFO *) lParam, I = *pI; NM_LISTVIEW *m = (NM_LISTVIEW *)lParam; switch (I.hdr.code) { case NM_CLICK: break; case NM_DBLCLK: ListView_SetItemText(hwKwGrid, I.item, 0, ""); return TRUE; break; case LVN_BEGINLABELEDIT: break; case LVN_ENDLABELEDIT: if(I.item.pszText != NULL) { return TRUE; } break; case LVN_COLUMNCLICK: // The user clicked on one of the column headings - sort by // this column. ListView_SortItemsEx( m->hdr.hwndFrom, ListViewCompareProc, (LPARAM)(m->iSubItem)); break; break; } return FALSE; }
void RefreshPopupHistory(HWND hWnd, int renderer) { if (!hWnd) { return; } const int MAX_FILTER_SIZE = 1024; SIG_MATCHESFILTER MatchesFilter = (IsDlgButtonChecked(hWnd, IDC_HISTORY_FILTER_CASESENSITIVE)) ? MatchesFilterCS : MatchesFilterCI; //case sensitive compare or not ? SIG_ADDEVENTS AddEvents = (renderer == RENDER_DEFAULT) ? AddEventsDefault : AddEventsCustomControl; TCHAR filter[MAX_FILTER_SIZE]; DeleteOldEvents(hWnd, renderer); //delete events GetWindowText(GetDlgItem(hWnd, IDC_HISTORY_FILTER), filter, MAX_FILTER_SIZE); //get filter text AddEvents(hWnd, renderer, filter, MatchesFilter); if (renderer == RENDER_DEFAULT) { HWND hHistoryList = GetDlgItem(hWnd, IDC_LST_HISTORY); SortParams params = {0}; params.hList = hHistoryList; params.column = lastColumn; ListView_SortItemsEx(hHistoryList, PopupsCompare, ¶ms); } }
LRESULT CpuFuncOnColumnClick( __in PDIALOG_OBJECT Object, __in NMLISTVIEW *lpNmlv ) { HWND hWndHeader; int nColumnCount; int i; HDITEM hdi; LISTVIEW_OBJECT *ListView; PCPU_FORM_CONTEXT Context; HWND hWndCtrl; HWND hWnd; Context = SdkGetContext(Object, CPU_FORM_CONTEXT); ListView = Context->ListView; if (ListView->SortOrder == SortOrderNone){ return 0; } if (ListView->LastClickedColumn == lpNmlv->iSubItem) { ListView->SortOrder = (LIST_SORT_ORDER)!ListView->SortOrder; } else { ListView->SortOrder = SortOrderAscendent; } hWnd = Object->hWnd; hWndCtrl = GetDlgItem(hWnd, IDC_LIST_FUNCTION); hWndHeader = ListView_GetHeader(hWndCtrl); ASSERT(hWndHeader); nColumnCount = Header_GetItemCount(hWndHeader); for (i = 0; i < nColumnCount; i++) { hdi.mask = HDI_FORMAT; Header_GetItem(hWndHeader, i, &hdi); if (i == lpNmlv->iSubItem) { hdi.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP); if (ListView->SortOrder == SortOrderAscendent){ hdi.fmt |= HDF_SORTUP; } else { hdi.fmt |= HDF_SORTDOWN; } } else { hdi.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP); } Header_SetItem(hWndHeader, i, &hdi); } ListView->LastClickedColumn = lpNmlv->iSubItem; ListView_SortItemsEx(hWndCtrl, CpuFuncSortCallback, (LPARAM)hWnd); return 0L; }
void NewGUI_SortList(CListCtrl* pListCtrl) { if(pListCtrl == NULL) { ASSERT(FALSE); return; } std::pair<CListCtrl*, int> spParam(pListCtrl, pListCtrl->GetHeaderCtrl()->GetItemCount()); VERIFY(ListView_SortItemsEx(pListCtrl->m_hWnd, NgslCompareFunc, (LPARAM)&spParam) != FALSE); }
bool CSongList::Sort(int colIndex) { colSortDirs[colIndex] = !colSortDirs[colIndex]; //Reverse sort direction ListViewSortInfo sortinfo; sortinfo.handle = handle; sortinfo.colIndex = colIndex; sortinfo.sortDir = colSortDirs[colIndex]; ListView_SortItemsEx(handle, &CSongList::SortCallback, &sortinfo); return false; }
/* * FindDlgHandleNotify * * Purpose: * * WM_NOTIFY processing for FindDlg listview. * */ VOID FindDlgHandleNotify( LPNMLISTVIEW nhdr ) { INT c, k; LPWSTR lpItemText; LVCOLUMN col; if (nhdr == NULL) return; if (nhdr->hdr.idFrom != ID_SEARCH_LIST) return; switch (nhdr->hdr.code) { case LVN_ITEMCHANGED: if (!(nhdr->uNewState & LVIS_SELECTED)) break; lpItemText = supGetItemText(nhdr->hdr.hwndFrom, nhdr->iItem, 0, NULL); if (lpItemText) { ListToObject(lpItemText); HeapFree(GetProcessHeap(), 0, lpItemText); } break; case LVN_COLUMNCLICK: bFindDlgSortInverse = !bFindDlgSortInverse; FindDlgSortColumn = ((NMLISTVIEW *)nhdr)->iSubItem; ListView_SortItemsEx(FindDlgList, &FindDlgCompareFunc, FindDlgSortColumn); RtlSecureZeroMemory(&col, sizeof(col)); col.mask = LVCF_IMAGE; col.iImage = -1; for (c = 0; c < 2; c++) ListView_SetColumn(FindDlgList, c, &col); k = ImageList_GetImageCount(ListViewImages); if (bFindDlgSortInverse) col.iImage = k - 2; else col.iImage = k - 1; ListView_SetColumn(FindDlgList, ((NMLISTVIEW *)nhdr)->iSubItem, &col); break; default: break; } }
/* * DesktopListDialogProc * * Purpose: * * Desktop list page. * * WM_INITDIALOG - Initialize listview. * WM_NOTIFY - Handle list view notifications. * WM_SHOWWINDOW - Collect desktop info and fill list. * WM_DESTROY - Free image list. * */ INT_PTR CALLBACK DesktopListDialogProc( _In_ HWND hwndDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) { LPNMLISTVIEW nhdr = NULL; PROPSHEETPAGE *pSheet; PROP_OBJECT_INFO *Context = NULL; switch (uMsg) { case WM_SHOWWINDOW: if (wParam) { Context = GetProp(hwndDlg, T_PROPCONTEXT); DesktopListSetInfo(Context, hwndDlg); if (DesktopList) { ListView_SortItemsEx(DesktopList, &DesktopListCompareFunc, DesktopListSortColumn); } return 1; } break; case WM_NOTIFY: nhdr = (LPNMLISTVIEW)lParam; DesktopListHandleNotify(hwndDlg, nhdr); return 1; break; case WM_DESTROY: if (DesktopImageList) { ImageList_Destroy(DesktopImageList); } RemoveProp(hwndDlg, T_PROPCONTEXT); break; case WM_INITDIALOG: pSheet = (PROPSHEETPAGE*)lParam; if (pSheet) { SetProp(hwndDlg, T_PROPCONTEXT, (HANDLE)pSheet->lParam); } DesktopListCreate(hwndDlg); return 1; break; } return 0; }
void CSubtitleDlDlg::OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult) { LPNMHEADER phdr = reinterpret_cast<LPNMHEADER>(pNMHDR); *pResult = 0; if (phdr->iItem == ps.m_colIndex) { ps.m_ascending = !ps.m_ascending; } else { ps.m_ascending = true; } ps.m_colIndex = phdr->iItem; ps.m_hWnd = m_list.GetSafeHwnd(); SetRedraw(FALSE); ListView_SortItemsEx(m_list.GetSafeHwnd(), SortCompare, &ps); SetRedraw(TRUE); m_list.Invalidate(); m_list.UpdateWindow(); }
/* * PNDlgHandleNotify * * Purpose: * * WM_NOTIFY processing for PNDialog listview. * */ VOID PNDlgHandleNotify( LPNMLISTVIEW nhdr ) { LVCOLUMNW col; INT c, k; if (nhdr == NULL) return; if (nhdr->hdr.idFrom != ID_NAMESPACELIST) return; switch (nhdr->hdr.code) { case LVN_COLUMNCLICK: PnDlgContext.bInverseSort = !PnDlgContext.bInverseSort; PnDlgContext.lvColumnToSort = ((NMLISTVIEW *)nhdr)->iSubItem; ListView_SortItemsEx(PnDlgContext.ListView, &PNListCompareFunc, PnDlgContext.lvColumnToSort); RtlSecureZeroMemory(&col, sizeof(col)); col.mask = LVCF_IMAGE; col.iImage = -1; for (c = 0; c < PnDlgContext.lvColumnCount; c++) ListView_SetColumn(PnDlgContext.ListView, c, &col); k = ImageList_GetImageCount(ListViewImages); if (PnDlgContext.bInverseSort) col.iImage = k - 2; else col.iImage = k - 1; ListView_SetColumn(PnDlgContext.ListView, ((NMLISTVIEW *)nhdr)->iSubItem, &col); break; default: break; } }
/* * PipeDlgHandleNotify * * Purpose: * * WM_NOTIFY processing for Pipe Dialog listview. * */ VOID PipeDlgHandleNotify( LPARAM lParam ) { LVCOLUMN col; LPNMHDR nhdr = (LPNMHDR)lParam; if (nhdr == NULL) return; if (nhdr->idFrom != ID_PIPESLIST) return; switch (nhdr->code) { case LVN_COLUMNCLICK: PipeDlgContext.bInverseSort = !PipeDlgContext.bInverseSort; ListView_SortItemsEx(PipeDlgContext.ListView, &PipeDlgCompareFunc, 0); RtlSecureZeroMemory(&col, sizeof(col)); col.mask = LVCF_IMAGE; col.iImage = -1; ListView_SetColumn(PipeDlgContext.ListView, 0, &col); if (PipeDlgContext.bInverseSort) col.iImage = 1; else col.iImage = 2; ListView_SetColumn(PipeDlgContext.ListView, 0, &col); break; case NM_DBLCLK: PipeDlgShowProperties(((LPNMITEMACTIVATE)lParam)->iItem); break; default: break; } }
BOOL ListView_SortEx(HWND hListView, int iSortingColumn, int iSortedColumn) { HWND hHeader; HDITEM hColumn; BOOL bSortAsc; Sort sort; if ((GetWindowLongPtr(hListView, GWL_STYLE) & ~LVS_NOSORTHEADER) == 0) return TRUE; hHeader = ListView_GetHeader(hListView); SecureZeroMemory(&hColumn, sizeof(hColumn)); if ( (iSortedColumn != -1) && (iSortedColumn != iSortingColumn) ) { hColumn.mask = HDI_FORMAT | HDI_LPARAM; Header_GetItem(hHeader, iSortedColumn, &hColumn); hColumn.fmt &= ~HDF_SORTUP & ~HDF_SORTDOWN; hColumn.lParam = 0; // 0: deactivated, 1: false, 2: true. Header_SetItem(hHeader, iSortedColumn, &hColumn); } hColumn.mask = HDI_FORMAT | HDI_LPARAM; Header_GetItem(hHeader, iSortingColumn, &hColumn); bSortAsc = !(hColumn.lParam == 2); // 0: deactivated, 1: false, 2: true. hColumn.fmt &= (bSortAsc ? ~HDF_SORTDOWN : ~HDF_SORTUP ); hColumn.fmt |= (bSortAsc ? HDF_SORTUP : HDF_SORTDOWN); hColumn.lParam = (LPARAM)(bSortAsc ? 2 : 1); Header_SetItem(hHeader, iSortingColumn, &hColumn); /* Sort the list */ sort.bSortAsc = bSortAsc; sort.hList = hListView; sort.nClickedColumn = iSortingColumn; return ListView_SortItemsEx(hListView, SortListView, (LPARAM)&sort); }
void CScanMemDlg::OnLstScanResultLvnColumnClick(NMHDR *pNMHDR, LRESULT *pResult) { if (m_wndLvScanResult.GetItemCount () == 0) return; LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR); static BOOL bAscSort = TRUE; static int iLastColIdx = -1; if (iLastColIdx != pNMLV->iSubItem) bAscSort = TRUE; LPARAM dwParam[3]; dwParam[0] = (LPARAM) &m_wndLvScanResult; dwParam[1] = (LPARAM) pNMLV->iSubItem; dwParam[2] = bAscSort; ListView_SortItemsEx (m_wndLvScanResult.m_hWnd, CompareLvItemText, (LPARAM) &dwParam); bAscSort = !bAscSort; iLastColIdx = pNMLV->iSubItem; *pResult = 0; }
void CSubtitleDlDlg::LoadList() { m_list.SetRedraw(FALSE); for (int i = 0; i < m_parsed_movies.GetCount(); ++i) { isdb_movie_parsed& m = m_parsed_movies[i]; int iItem = m_list.InsertItem(i, _T("")); m_list.SetItemData(iItem, m.ptr); m_list.SetItemText(iItem, COL_FILENAME, m.name); m_list.SetItemText(iItem, COL_LANGUAGE, m.language); m_list.SetItemText(iItem, COL_FORMAT, m.format); m_list.SetItemText(iItem, COL_DISC, m.disc); m_list.SetItemText(iItem, COL_TITLES, m.titles); m_list.SetCheck(iItem, m.checked); } // sort by language and filename m_defps.m_hWnd = m_list.GetSafeHwnd(); ListView_SortItemsEx(m_list.GetSafeHwnd(), DefSortCompare, &m_defps); m_list.SetRedraw(TRUE); m_list.Invalidate(); m_list.UpdateWindow(); }
INT_PTR CALLBACK FindWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: SendDlgItemMessage(hwnd, IDC_SBAR, SB_SETTEXT, 0, (LPARAM)TranslateT("Enter a string to search the database for")); CheckDlgButton(hwnd, IDC_MODNAME, BST_CHECKED); CheckDlgButton(hwnd, IDC_SETTINGNAME, BST_CHECKED); CheckDlgButton(hwnd, IDC_SETTINGVALUE, BST_CHECKED); CheckDlgButton(hwnd, IDC_FOUND, BST_CHECKED); SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIcon(hInst, MAKEINTRESOURCE(ICO_REGEDIT))); SetWindowLongPtr(GetDlgItem(hwnd, IDC_REPLACE), GWLP_USERDATA, 0); SetWindowLongPtr(GetDlgItem(hwnd, IDC_SEARCH), GWLP_USERDATA, 0); SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_APPWINDOW); // taskbar icon TranslateDialogDefault(hwnd); ListView_SetExtendedListViewStyle(GetDlgItem(hwnd, IDC_LIST), 32 | LVS_EX_LABELTIP); // LVS_EX_GRIDLINES loadListSettings(GetDlgItem(hwnd, IDC_LIST), csResultList); Utils_RestoreWindowPositionNoMove(hwnd, NULL, modname, "Search_"); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: case IDC_SEARCH: if (GetWindowLongPtr(GetDlgItem(hwnd, IDC_SEARCH), GWLP_USERDATA)) // stop the search SetWindowLongPtr(GetDlgItem(hwnd, IDC_SEARCH), GWLP_USERDATA, 0); else { TCHAR text[FLD_SIZE]; TCHAR replace[FLD_SIZE] = {0}; if (!GetDlgItemText(hwnd, IDC_TEXT, text, _countof(text)) && !IsDlgButtonChecked(hwnd, IDC_EXACT)) break; // empty replace is done only for exact match or entire replace if (LOWORD(wParam) == IDOK && !GetDlgItemText(hwnd, IDC_REPLACE, replace, _countof(replace)) && (!IsDlgButtonChecked(hwnd, IDC_ENTIRELY) && !IsDlgButtonChecked(hwnd, IDC_EXACT))) break; if (BST_UNCHECKED == IsDlgButtonChecked(hwnd, IDC_MODNAME) && BST_UNCHECKED == IsDlgButtonChecked(hwnd, IDC_SETTINGNAME) && BST_UNCHECKED == IsDlgButtonChecked(hwnd, IDC_SETTINGVALUE)) break; FindInfo *fi = (FindInfo*)mir_calloc(sizeof(FindInfo)); if (!fi) break; fi->hwnd = GetDlgItem(hwnd, IDC_LIST); fi->options = (IsDlgButtonChecked(hwnd, IDC_CASESENSITIVE) ? F_CASE : 0) | (IsDlgButtonChecked(hwnd, IDC_EXACT) ? F_EXACT : 0) | (IsDlgButtonChecked(hwnd, IDC_MODNAME) ? F_MODNAME : 0) | (IsDlgButtonChecked(hwnd, IDC_SETTINGNAME) ? F_SETNAME : 0) | (IsDlgButtonChecked(hwnd, IDC_SETTINGVALUE) ? F_SETVAL : 0); if (LOWORD(wParam) == IDOK) { if (IsDlgButtonChecked(hwnd, IDC_ENTIRELY)) fi->options |= F_ENTIRE; fi->replace = mir_tstrdup(replace); SetDlgItemText(hwnd, IDOK, TranslateT("Stop")); EnableWindow(GetDlgItem(hwnd, IDC_SEARCH), 0); } else { SetDlgItemText(hwnd, IDC_SEARCH, TranslateT("Stop")); EnableWindow(GetDlgItem(hwnd, IDOK), 0); } fi->search = mir_tstrdup(text); ListView_DeleteAllItems(fi->hwnd); SetWindowLongPtr(GetDlgItem(hwnd, IDC_SEARCH), GWLP_USERDATA, 1); EnableWindow(GetDlgItem(hwnd, IDCANCEL), 0); mir_forkthread(FindSettings, fi); } break; case IDCANCEL: DestroyWindow(hwnd); break; } break; case WM_GETMINMAXINFO: { MINMAXINFO *mmi = (MINMAXINFO*)lParam; mmi->ptMinTrackSize.x = 610; mmi->ptMinTrackSize.y = 300; } return 0; case WM_SIZE: Utils_ResizeDialog(hwnd, hInst, MAKEINTRESOURCEA(IDD_FIND), FindDialogResize); break; case WM_NOTIFY: if (LOWORD(wParam) != IDC_LIST) break; switch (((NMHDR*)lParam)->code) { case NM_DBLCLK: { LVHITTESTINFO hti; LVITEM lvi; HWND hwndResults = GetDlgItem(hwnd, IDC_LIST); hti.pt = ((NMLISTVIEW*)lParam)->ptAction; if (ListView_SubItemHitTest(hwndResults, &hti) > -1) { if (hti.flags&LVHT_ONITEM) { lvi.mask = LVIF_PARAM; lvi.iItem = hti.iItem; lvi.iSubItem = 0; if (ListView_GetItem(hwndResults, &lvi)) { ItemInfo ii = {0}; ii.hContact = (MCONTACT)lvi.lParam; ListView_GetItemTextA(hwndResults, hti.iItem, 2, ii.module, _countof(ii.module)); ListView_GetItemTextA(hwndResults, hti.iItem, 3, ii.setting, _countof(ii.setting)); if (ii.setting[0]) ii.type = FW_SETTINGNAME; else if (ii.module[0]) ii.type = FW_MODULE; SendMessage(hwnd2mainWindow, WM_FINDITEM, (WPARAM)&ii, 0); } } } break; } case LVN_COLUMNCLICK: { LPNMLISTVIEW lv = (LPNMLISTVIEW)lParam; ColumnsSortParams params; params.hList = GetDlgItem(hwnd, IDC_LIST); params.column = lv->iSubItem; params.last = lastColumn; ListView_SortItemsEx(params.hList, ColumnsCompare, (LPARAM)¶ms); lastColumn = (params.column == lastColumn) ? -1 : params.column; break; } } // switch break; case WM_DESTROY: ListView_DeleteAllItems(GetDlgItem(hwnd, IDC_LIST)); saveListSettings(GetDlgItem(hwnd, IDC_LIST), csResultList); Utils_SaveWindowPosition(hwnd, NULL, modname, "Search_"); break; } return 0; }
/* * DesktopListHandleNotify * * Purpose: * * WM_NOTIFY processing for Desktop page listview. * */ VOID DesktopListHandleNotify( HWND hwndDlg, LPNMLISTVIEW nhdr ) { LVCOLUMNW col; INT c; SIZE_T sz, i, l; LPWSTR lpItemText, lpName; if (nhdr == NULL) { return; } if (nhdr->hdr.idFrom != ID_DESKTOPSLIST) { return; } switch (nhdr->hdr.code) { case LVN_COLUMNCLICK: bDesktopListSortInverse = !bDesktopListSortInverse; DesktopListSortColumn = ((NMLISTVIEW *)nhdr)->iSubItem; ListView_SortItemsEx(DesktopList, &DesktopListCompareFunc, DesktopListSortColumn); RtlSecureZeroMemory(&col, sizeof(col)); col.mask = LVCF_IMAGE; col.iImage = -1; for (c = 0; c < 3; c++) { ListView_SetColumn(DesktopList, c, &col); } if (bDesktopListSortInverse) col.iImage = 1; else col.iImage = 2; ListView_SetColumn(DesktopList, ((NMLISTVIEW *)nhdr)->iSubItem, &col); break; case NM_DBLCLK: /* * A very basic support for this type * desktop described by win32k PDESKTOP structure which is totally undocumented */ sz = 0; lpItemText = supGetItemText(DesktopList, ListView_GetSelectionMark(DesktopList), 0, &sz); if (lpItemText) { l = 0; for (i = 0; i<sz; i++) if (lpItemText[i] == L'\\') l = i + 1; lpName = &lpItemText[l]; //hwndDlg set to mainwindow on purpose propCreateDialog(hwndDlg, lpName, T_ObjectNames[TYPE_DESKTOP], NULL); HeapFree(GetProcessHeap(), 0, lpItemText); } break; default: break; } }
/** * @brief WM_NOTIFY handler of Machine State dialog. * @param hwnd - window handle. * @param idCtrl - identifier of the common control sending the message. * @param pnmh - pointer to an NMHDR structure that contains the notification code and additional information. */ static LRESULT MachineStateDlg_OnNotify(HWND hwnd, int idCtrl, LPNMHDR pnmh) { switch (pnmh->code) { case LVN_ITEMCHANGED: { if (idCtrl != IDC_PROCESS_LIST) break; LPNMLISTVIEW pnmv = (LPNMLISTVIEW)pnmh; if ((pnmv->uNewState & LVIS_SELECTED) != (pnmv->uOldState & LVIS_SELECTED)) { if (pnmv->uNewState & LVIS_SELECTED) { CWaitCursor wait(true); HWND hwndModuleList = GetDlgItem(hwnd, IDC_PROCESS_MODULES_LIST); SendMessage(hwndModuleList, WM_SETREDRAW, FALSE, 0); DisplayWaitBanner(hwndModuleList); LVITEM lvi; ZeroMemory(&lvi, sizeof(lvi)); lvi.mask = LVIF_TEXT; CEnumProcess::CModuleEntry module; if (g_pEnumProc->GetModuleFirst((DWORD)pnmv->lParam, module)) { int iItemPos = 0; do { lvi.iItem = iItemPos; lvi.pszText = module.m_szModuleName; ListView_InsertItem(hwndModuleList, &lvi); TCHAR szVersionString[64]; if (CSymEngine::GetVersionString(module.m_szModuleName, szVersionString, countof(szVersionString))) ListView_SetItemText(hwndModuleList, iItemPos, CID_MODULE_VERSION, szVersionString); TCHAR szTempBuf[32]; #if defined _WIN64 _stprintf_s(szTempBuf, countof(szTempBuf), _T("%016X"), (DWORD_PTR)module.m_pLoadBase); #elif defined _WIN32 _stprintf_s(szTempBuf, countof(szTempBuf), _T("%08X"), (DWORD_PTR)module.m_pLoadBase); #endif ListView_SetItemText(hwndModuleList, iItemPos, CID_MODULE_BASE, szTempBuf); ++iItemPos; } while (g_pEnumProc->GetModuleNext((DWORD)pnmv->lParam, module)); } else { TCHAR szMessage[100]; LoadString(g_hInstance, IDS_ERROR_NOT_AVAILABLE, szMessage, countof(szMessage)); lvi.iItem = 0; lvi.pszText = szMessage; ListView_InsertItem(hwndModuleList, &lvi); } SendMessage(hwndModuleList, WM_SETREDRAW, TRUE, 0); InvalidateRect(hwndModuleList, NULL, TRUE); } else { HWND hwndModuleList = GetDlgItem(hwnd, IDC_PROCESS_MODULES_LIST); ListView_DeleteAllItems(hwndModuleList); } } } break; case LVN_COLUMNCLICK: { LPNMLISTVIEW pnmv = (LPNMLISTVIEW)pnmh; if (idCtrl == IDC_PROCESS_LIST) { HWND hwndProcessList = GetDlgItem(hwnd, IDC_PROCESS_LIST); g_ProcessListOrder.ToggleSortParams(hwndProcessList, pnmv->iSubItem); LISTVIEW_SORT_PARAMS lvSortParams; lvSortParams.hwndList = hwndProcessList; lvSortParams.iColumnNumber = pnmv->iSubItem; lvSortParams.bAscending = g_ProcessListOrder.GetSortOrder(); switch (pnmv->iSubItem) { case CID_PROCESS_ID: lvSortParams.eCompareType = LISTVIEW_SORT_PARAMS::ICT_INTEGER; break; case CID_PROCESS_NAME: lvSortParams.eCompareType = LISTVIEW_SORT_PARAMS::ICT_STRING; break; } ListView_SortItemsEx(hwndProcessList, &ListViewCompareFunc, (LPARAM)&lvSortParams); } else if (idCtrl == IDC_PROCESS_MODULES_LIST) { HWND hwndModuleList = GetDlgItem(hwnd, IDC_PROCESS_MODULES_LIST); g_ModulesListOrder.ToggleSortParams(hwndModuleList, pnmv->iSubItem); LISTVIEW_SORT_PARAMS lvSortParams; lvSortParams.hwndList = hwndModuleList; lvSortParams.iColumnNumber = pnmv->iSubItem; lvSortParams.bAscending = g_ModulesListOrder.GetSortOrder(); switch (pnmv->iSubItem) { case CID_MODULE_NAME: case CID_MODULE_VERSION: lvSortParams.eCompareType = LISTVIEW_SORT_PARAMS::ICT_STRING; break; case CID_MODULE_BASE: lvSortParams.eCompareType = LISTVIEW_SORT_PARAMS::ICT_HEXADECIMAL; break; } ListView_SortItemsEx(hwndModuleList, &ListViewCompareFunc, (LPARAM)&lvSortParams); } } break; } return FALSE; }
BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG : { _fileListView.init(_hInst, _hSelf, _hImaLst); _fileListView.insertColumn(TEXT("Name"), 150, 0); _fileListView.insertColumn(TEXT("Ext."), 50, 1); _fileListView.initList(); _fileListView.display(); return TRUE; } case WM_NOTIFY: { switch (((LPNMHDR)lParam)->code) { case NM_DBLCLK: { LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam; int i = lpnmitem->iItem; if (i == -1) { ::SendMessage(_hParent, WM_COMMAND, IDM_FILE_NEW, 0); } return TRUE; } case NM_CLICK: { if ((0x80 & GetKeyState(VK_CONTROL)) || (0x80 & GetKeyState(VK_SHIFT))) return TRUE; LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam; int nbItem = ListView_GetItemCount(_fileListView.getHSelf()); int i = lpnmitem->iItem; if (i == -1 || i >= nbItem) return TRUE; LVITEM item; item.mask = LVIF_PARAM; item.iItem = i; ListView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item); TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam; activateDoc(tlfs); return TRUE; } case NM_RCLICK : { // Switch to the right document LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam; int nbItem = ListView_GetItemCount(_fileListView.getHSelf()); if (nbItem == 1) { int i = lpnmitem->iItem; if (i == -1 || i >= nbItem) return TRUE; LVITEM item; item.mask = LVIF_PARAM; item.iItem = i; ListView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item); TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam; activateDoc(tlfs); } // Redirect NM_RCLICK message to Notepad_plus handle NMHDR nmhdr; nmhdr.code = NM_RCLICK; nmhdr.hwndFrom = _hSelf; nmhdr.idFrom = ::GetDlgCtrlID(nmhdr.hwndFrom); ::SendMessage(_hParent, WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr); return TRUE; } case LVN_GETINFOTIP: { LPNMLVGETINFOTIP pGetInfoTip = (LPNMLVGETINFOTIP)lParam; int i = pGetInfoTip->iItem; if (i == -1) return TRUE; generic_string fn = getFullFilePath((size_t)i); lstrcpyn(pGetInfoTip->pszText, fn.c_str(), pGetInfoTip->cchTextMax); return TRUE; } case LVN_COLUMNCLICK: { LPNMLISTVIEW pnmLV = (LPNMLISTVIEW)lParam; setHeaderOrder(pnmLV); ListView_SortItemsEx(pnmLV->hdr.hwndFrom, ListViewCompareProc,(LPARAM)pnmLV); return TRUE; } case LVN_KEYDOWN: { switch (((LPNMLVKEYDOWN)lParam)->wVKey) { case VK_RETURN: { int i = ListView_GetSelectionMark(_fileListView.getHSelf()); if (i == -1) return TRUE; LVITEM item; item.mask = LVIF_PARAM; item.iItem = i; ListView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item); TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam; activateDoc(tlfs); return TRUE; } default: break; } } break; default: break; } } return TRUE; case WM_SIZE: { int width = LOWORD(lParam); int height = HIWORD(lParam); ::MoveWindow(_fileListView.getHSelf(), 0, 0, width, height, TRUE); break; } case WM_DESTROY: { _fileListView.destroy(); break; } default : return DockingDlgInterface::run_dlgProc(message, wParam, lParam); } return DockingDlgInterface::run_dlgProc(message, wParam, lParam); }
/* * MainWindowHandleWMNotify * * Purpose: * * Main window WM_NOTIFY handler. * */ LRESULT MainWindowHandleWMNotify( _In_ HWND hwnd, _In_ WPARAM wParam, _In_ LPARAM lParam ) { INT c, k; LPNMHDR hdr = (LPNMHDR)lParam; LPTOOLTIPTEXT lpttt; LPNMLISTVIEW lvn; LPNMTREEVIEW lpnmTreeView; LPWSTR str; SIZE_T lcp; LVITEM lvitem; LVCOLUMN col; TVHITTESTINFO hti; POINT pt; WCHAR item_string[MAX_PATH + 1]; UNREFERENCED_PARAMETER(wParam); if (hdr) { if (hdr->hwndFrom == g_hwndObjectTree) { switch (hdr->code) { case TVN_ITEMEXPANDED: case TVN_SELCHANGED: SetFocus(g_hwndObjectTree); supSetWaitCursor(TRUE); MainWindowTreeViewSelChanged((LPNMTREEVIEWW)lParam); SendMessage(hwndStatusBar, WM_SETTEXT, 0, (LPARAM)g_WinObj.CurrentObjectPath); ListObjectsInDirectory(g_WinObj.CurrentObjectPath); ListView_SortItemsEx(g_hwndObjectList, &MainWindowObjectListCompareFunc, SortColumn); supSetWaitCursor(FALSE); lpnmTreeView = (LPNMTREEVIEW)lParam; if (lpnmTreeView) { SelectedTreeItem = lpnmTreeView->itemNew.hItem; } break; case NM_RCLICK: GetCursorPos(&pt); hti.pt = pt; ScreenToClient(hdr->hwndFrom, &hti.pt); if (TreeView_HitTest(hdr->hwndFrom, &hti) && (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT))) { SelectedTreeItem = hti.hItem; TreeView_SelectItem(g_hwndObjectTree, SelectedTreeItem); SendMessage(hwndStatusBar, WM_SETTEXT, 0, (LPARAM)g_WinObj.CurrentObjectPath); supHandleTreePopupMenu(hwnd, &pt); } break; } } if (hdr->hwndFrom == g_hwndObjectList) { switch (hdr->code) { case NM_SETFOCUS: if (ListView_GetSelectionMark(g_hwndObjectList) == -1) { lvitem.mask = LVIF_STATE; lvitem.iItem = 0; lvitem.state = LVIS_SELECTED | LVIS_FOCUSED; lvitem.stateMask = LVIS_SELECTED | LVIS_FOCUSED; ListView_SetItem(g_hwndObjectList, &lvitem); } break; case LVN_ITEMCHANGED: lvn = (LPNMLISTVIEW)lParam; RtlSecureZeroMemory(&item_string, sizeof(item_string)); ListView_GetItemText(g_hwndObjectList, lvn->iItem, 0, item_string, MAX_PATH); lcp = _strlen(g_WinObj.CurrentObjectPath); if (lcp) { str = supHeapAlloc((lcp + sizeof(item_string) + 4) * sizeof(WCHAR)); if (str == NULL) break; _strcpy(str, g_WinObj.CurrentObjectPath); if ((str[0] == '\\') && (str[1] == 0)) { _strcpy(str + lcp, item_string); } else { str[lcp] = '\\'; _strcpy(str + lcp + 1, item_string); } SendMessage(hwndStatusBar, WM_SETTEXT, 0, (LPARAM)str); supHeapFree(str); } break; //handle sort by column case LVN_COLUMNCLICK: bMainWndSortInverse = !bMainWndSortInverse; SortColumn = ((NMLISTVIEW *)lParam)->iSubItem; ListView_SortItemsEx(g_hwndObjectList, &MainWindowObjectListCompareFunc, SortColumn); RtlSecureZeroMemory(&col, sizeof(col)); col.mask = LVCF_IMAGE; col.iImage = -1; for (c = 0; c < 3; c++) ListView_SetColumn(g_hwndObjectList, c, &col); k = ImageList_GetImageCount(g_ListViewImages); if (bMainWndSortInverse) col.iImage = k - 2; else col.iImage = k - 1; ListView_SetColumn(g_hwndObjectList, ((NMLISTVIEW *)lParam)->iSubItem, &col); break; case NM_DBLCLK: MainWindowHandleObjectListProp(hwnd); break; default: break; } } //handle tooltip if (hdr->code == TTN_GETDISPINFO) { lpttt = (LPTOOLTIPTEXT)lParam; switch (lpttt->hdr.idFrom) { case ID_OBJECT_PROPERTIES: case ID_VIEW_REFRESH: case ID_FIND_FINDOBJECT: lpttt->hinst = g_WinObj.hInstance; lpttt->lpszText = MAKEINTRESOURCE(lpttt->hdr.idFrom); lpttt->uFlags |= TTF_DI_SETITEM; break; default: break; } } } return FALSE; }
/** * This static method is the window procedure for the dialog. * * @param hDlg - handle of the dialog window * @param uMsg - message to handle * @param wParam - message dependend parameter * @param lParam - message dependend parameter * * @return depends on message **/ static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { CAnnivList *pDlg = (CAnnivList *)GetUserData(hDlg); switch (uMsg) { case WM_INITDIALOG: { HWND hCtrl; HICON hIcon; RECT rc; // link the class to the window handle pDlg = (CAnnivList *)lParam; if (!pDlg) break; SetUserData(hDlg, lParam); pDlg->_hDlg = hDlg; // init pointer listview control pDlg->_hList = GetDlgItem(hDlg, EDIT_ANNIVERSARY_DATE); if (!pDlg->_hList) break; // set icons hIcon = IcoLib_GetIcon(ICO_DLG_ANNIVERSARY); SendDlgItemMessage(hDlg, IDC_HEADERBAR, WM_SETICON, 0, (LPARAM)hIcon); SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon); // insert columns into the listboxes ListView_SetExtendedListViewStyle(pDlg->_hList, LVS_EX_FULLROWSELECT); // add columns if (pDlg->AddColumn(CAnnivList::COLUMN_ETA, LPGENT("ETA"), 40) || pDlg->AddColumn(CAnnivList::COLUMN_CONTACT, LPGENT("Contact"), 160) || pDlg->AddColumn(CAnnivList::COLUMN_PROTO, LPGENT("Proto"), 50) || pDlg->AddColumn(CAnnivList::COLUMN_AGE, LPGENT("Age/Nr."), 40) || pDlg->AddColumn(CAnnivList::COLUMN_DESC, LPGENT("Anniversary"), 100) || pDlg->AddColumn(CAnnivList::COLUMN_DATE, LPGENT("Date"), 80)) break; TranslateDialogDefault(hDlg); // save minimal size GetWindowRect(hDlg, &rc); pDlg->_sizeMin.cx = rc.right - rc.left; pDlg->_sizeMin.cy = rc.bottom - rc.top; // restore position and size Utils_RestoreWindowPosition(hDlg, NULL, MODNAME, "AnnivDlg_"); //save win pos GetWindowRect(hDlg, &pDlg->_rcWin); // add filter strings if (hCtrl = GetDlgItem(hDlg, COMBO_VIEW)) { ComboBox_AddString(hCtrl, TranslateT("All contacts")); ComboBox_AddString(hCtrl, TranslateT("Birthdays only")); ComboBox_AddString(hCtrl, TranslateT("Anniversaries only")); ComboBox_AddString(hCtrl, TranslateT("Disabled reminder")); ComboBox_SetCurSel(hCtrl, pDlg->_filter.bFilterIndex); } // init reminder groups pDlg->_bRemindEnable = db_get_b(NULL, MODNAME, SET_REMIND_ENABLED, DEFVAL_REMIND_ENABLED) != REMIND_OFF; if (hCtrl = GetDlgItem(hDlg, CHECK_REMIND)) { Button_SetCheck(hCtrl, pDlg->_bRemindEnable ? BST_INDETERMINATE : BST_UNCHECKED); EnableWindow(hCtrl, pDlg->_bRemindEnable); } CheckDlgButton(hDlg, CHECK_POPUP, db_get_b(NULL, MODNAME, SET_ANNIVLIST_POPUP, FALSE) ? BST_CHECKED : BST_UNCHECKED); // set number of days to show contact in advance SetDlgItemInt(hDlg, EDIT_DAYS, pDlg->_filter.wDaysBefore, FALSE); if (hCtrl = GetDlgItem(hDlg, CHECK_DAYS)) { Button_SetCheck(hCtrl, db_get_b(NULL, MODNAME, SET_ANNIVLIST_FILTER_DAYSENABLED, FALSE)); DlgProc(hDlg, WM_COMMAND, MAKEWPARAM(CHECK_DAYS, BN_CLICKED), (LPARAM)hCtrl); } pDlg->_wmINIT = false; } return TRUE; // set propertysheet page's background white in aero mode case WM_CTLCOLORSTATIC: case WM_CTLCOLORDLG: if (IsAeroMode()) return (INT_PTR)GetStockBrush(WHITE_BRUSH); break; case WM_NOTIFY: switch (((LPNMHDR)lParam)->idFrom) { case EDIT_ANNIVERSARY_DATE: switch (((LPNMHDR)lParam)->code) { // handle changed selection case LVN_ITEMCHANGED: { CItemData *pid; HWND hCheck; pDlg->_curSel = ((LPNMLISTVIEW)lParam)->iItem; pid = pDlg->ItemData(pDlg->_curSel); if (pid && pDlg->_bRemindEnable && (hCheck = GetDlgItem(hDlg, CHECK_REMIND))) { SetDlgItemInt(hDlg, EDIT_REMIND, pid->_wDaysBefore, FALSE); Button_SetCheck(hCheck, pid->_wReminderState); DlgProc(hDlg, WM_COMMAND, MAKEWPARAM(CHECK_REMIND, BN_CLICKED), (LPARAM)hCheck); } } break; // resort the list case LVN_COLUMNCLICK: { LPNMLISTVIEW pnmv = (LPNMLISTVIEW)lParam; if (pDlg->_sortHeader == pnmv->iSubItem) pDlg->_sortOrder *= -1; else { pDlg->_sortOrder = 1; pDlg->_sortHeader = pnmv->iSubItem; } ListView_SortItemsEx(pDlg->_hList, (CMPPROC)cmpProc, pDlg); } break; // show contact menu case NM_RCLICK: { CItemData *pid = pDlg->ItemData(pDlg->_curSel); if (pid) { HMENU hPopup = Menu_BuildContactMenu(pid->_hContact); if (hPopup) { POINT pt; GetCursorPos(&pt); TrackPopupMenu(hPopup, TPM_TOPALIGN | TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, 0, hDlg, NULL); DestroyMenu(hPopup); } } } break; // handle double click on contact: show message dialog case NM_DBLCLK: { CItemData *pid = pDlg->ItemData(((LPNMITEMACTIVATE)lParam)->iItem); if (pid) CallService(MS_MSG_SENDMESSAGE,(WPARAM)pid->_hContact, NULL); } } } break; case WM_COMMAND: if (PtrIsValid(pDlg)) { CItemData* pid = pDlg->ItemData(pDlg->_curSel); // process contact menu command if (pid && CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM)pid->_hContact)) break; switch (LOWORD(wParam)) { // enable/disable reminder checkbox is clicked case CHECK_REMIND: if (pDlg->_bRemindEnable && HIWORD(wParam) == BN_CLICKED) { BYTE checkState = Button_GetCheck((HWND)lParam); EnableWindow(GetDlgItem(hDlg, EDIT_REMIND), checkState == BST_CHECKED); EnableWindow(GetDlgItem(hDlg, SPIN_REMIND), checkState == BST_CHECKED); if (pid && pid->_wReminderState != checkState) pid->_wReminderState = checkState; } break; // number of days to remind in advance is edited case EDIT_REMIND: if (pid && pDlg->_bRemindEnable && HIWORD(wParam) == EN_CHANGE) { WORD wDaysBefore = GetDlgItemInt(hDlg, LOWORD(wParam), NULL, FALSE); if (pid->_wReminderState == BST_CHECKED && pid->_wDaysBefore != wDaysBefore) { pid->_wDaysBefore = wDaysBefore; } } break; // the filter to display only contacts which have an anniversary in a certain // period of time is enabled/disabled case CHECK_DAYS: if (HIWORD(wParam) == BN_CLICKED) { BYTE isChecked = Button_GetCheck((HWND)lParam); EnableWindow(GetDlgItem(hDlg, EDIT_DAYS), isChecked); EnableWindow(GetDlgItem(hDlg, TXT_DAYS), isChecked); pDlg->_filter.wDaysBefore = isChecked ? GetDlgItemInt(hDlg, EDIT_DAYS, NULL, FALSE) : (WORD)-1; pDlg->RebuildList(); } break; // the number of days a contact must have an anniversary in advance to be displayed is edited case EDIT_DAYS: if (HIWORD(wParam) == EN_CHANGE) { WORD wNewDays = GetDlgItemInt(hDlg, LOWORD(wParam), NULL, FALSE); if (wNewDays != pDlg->_filter.wDaysBefore) { pDlg->_filter.wDaysBefore = wNewDays; pDlg->RebuildList(); } } break; // the filter selection of the filter combobox has changed case COMBO_VIEW: if (HIWORD(wParam) == CBN_SELCHANGE) { pDlg->_filter.bFilterIndex = ComboBox_GetCurSel((HWND)lParam); pDlg->RebuildList(); } } } break; case WM_DRAWITEM: return Menu_DrawItem((LPDRAWITEMSTRUCT)lParam); case WM_MEASUREITEM: return Menu_MeasureItem((LPMEASUREITEMSTRUCT)lParam); case WM_WINDOWPOSCHANGING: if (PtrIsValid(pDlg)) { WINDOWPOS *wndPos = (WINDOWPOS *)lParam; if (!pDlg->_wmINIT && (wndPos->cx != 0 || wndPos->cy != 0)) { //win pos change if ((wndPos->cx == pDlg->_rcWin.right - pDlg->_rcWin.left) && (wndPos->cy == pDlg->_rcWin.bottom - pDlg->_rcWin.top)) //win pos change (store new pos) GetWindowRect(hDlg, &pDlg->_rcWin); //win size change else { // l change if ((wndPos->cx < pDlg->_sizeMin.cx) && (wndPos->x > pDlg->_rcWin.left)) { wndPos->x = wndPos->x + wndPos->cx - pDlg->_sizeMin.cx; wndPos->cx = pDlg->_sizeMin.cx; } // r change else if (wndPos->cx < pDlg->_sizeMin.cx) wndPos->cx = pDlg->_sizeMin.cx; // t change if ((wndPos->cy < pDlg->_sizeMin.cy) && (wndPos->y > pDlg->_rcWin.top)) { wndPos->y = wndPos->y + wndPos->cy - pDlg->_sizeMin.cy; wndPos->cy = pDlg->_sizeMin.cy; } // b change else if (wndPos->cy < pDlg->_sizeMin.cy) wndPos->cy = pDlg->_sizeMin.cy; pDlg->_rcWin.left = wndPos->x; pDlg->_rcWin.right = wndPos->x + wndPos->cx; pDlg->_rcWin.top = wndPos->y; pDlg->_rcWin.bottom = wndPos->y + wndPos->cy; } } CAnchor anchor(wndPos, pDlg->_sizeMin); int anchorPos = CAnchor::ANCHOR_LEFT | CAnchor::ANCHOR_RIGHT | CAnchor::ANCHOR_TOP; anchor.MoveCtrl(IDC_HEADERBAR, anchorPos); anchor.MoveCtrl(GROUP_STATS, anchorPos); // birthday list anchor.MoveCtrl(EDIT_ANNIVERSARY_DATE, CAnchor::ANCHOR_ALL); anchorPos = CAnchor::ANCHOR_RIGHT | CAnchor::ANCHOR_BOTTOM; // filter group anchor.MoveCtrl(GROUP_FILTER, anchorPos); anchor.MoveCtrl(COMBO_VIEW, anchorPos); anchor.MoveCtrl(CHECK_DAYS, anchorPos); anchor.MoveCtrl(EDIT_DAYS, anchorPos); anchor.MoveCtrl(TXT_DAYS, anchorPos); // filter group anchor.MoveCtrl(GROUP_REMINDER, anchorPos); anchor.MoveCtrl(CHECK_REMIND, anchorPos); anchor.MoveCtrl(EDIT_REMIND, anchorPos); anchor.MoveCtrl(SPIN_REMIND, anchorPos); anchor.MoveCtrl(TXT_REMIND6, anchorPos); anchor.MoveCtrl(CHECK_POPUP, anchorPos); } break; // This message is sent if eighter the user clicked on the close button or // Miranda fires the ME_SYSTEM_SHUTDOWN event. case WM_CLOSE: DestroyWindow(hDlg); break; // If the anniversary list is destroyed somehow, the data class must be deleted, too. case WM_DESTROY: if (PtrIsValid(pDlg)) { SetUserData(hDlg, NULL); delete pDlg; } break; } return FALSE; }
/* * FindDlgProc * * Purpose: * * Find Dialog window procedure. * */ INT_PTR CALLBACK FindDlgProc( _In_ HWND hwndDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam ) { WCHAR search_string[MAX_PATH + 1], type_name[MAX_PATH + 1]; LPWSTR pnamestr = (LPWSTR)search_string, ptypestr = (LPWSTR)type_name; PFO_LIST_ITEM flist, plist; ULONG cci; LPNMLISTVIEW nhdr = (LPNMLISTVIEW)lParam; switch (uMsg) { case WM_NOTIFY: FindDlgHandleNotify(nhdr); break; case WM_GETMINMAXINFO: if (lParam) { ((PMINMAXINFO)lParam)->ptMinTrackSize.x = 548; ((PMINMAXINFO)lParam)->ptMinTrackSize.y = 230; } break; case WM_INITDIALOG: supCenterWindow(hwndDlg); FindDlgResize(hwndDlg); break; case WM_SIZE: FindDlgResize(hwndDlg); break; case WM_CLOSE: if (FindDlgGrip) DestroyWindow(FindDlgGrip); DestroyWindow(hwndDlg); FindDialog = NULL; g_wobjDialogs[WOBJ_FINDDLG_IDX] = NULL; return TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDCANCEL) { SendMessage(hwndDlg, WM_CLOSE, 0, 0); return TRUE; } if (LOWORD(wParam) == ID_SEARCH_FIND) { supSetWaitCursor(TRUE); EnableWindow(GetDlgItem(hwndDlg, ID_SEARCH_FIND), FALSE); ListView_DeleteAllItems(FindDlgList); RtlSecureZeroMemory(&search_string, sizeof(search_string)); RtlSecureZeroMemory(&type_name, sizeof(type_name)); SendMessageW(GetDlgItem(hwndDlg, ID_SEARCH_NAME), WM_GETTEXT, MAX_PATH, (LPARAM)&search_string); SendMessageW(GetDlgItem(hwndDlg, ID_SEARCH_TYPE), WM_GETTEXT, MAX_PATH, (LPARAM)&type_name); flist = NULL; if (search_string[0] == 0) pnamestr = NULL; if (type_name[0] == '*') ptypestr = 0; FindObject(L"\\", pnamestr, ptypestr, &flist); cci = 0; while (flist != NULL) { FindDlgAddListItem(FindDlgList, flist->ObjectName, flist->ObjectType); plist = flist->Prev; HeapFree(GetProcessHeap(), 0, flist); flist = plist; cci++; } ultostr(cci, search_string); _strcat(search_string, L" Object(s) found"); SendMessageW(GetDlgItem(hwndDlg, ID_SEARCH_GROUPBOX), WM_SETTEXT, 0, (LPARAM)search_string); ListView_SortItemsEx(FindDlgList, &FindDlgCompareFunc, FindDlgSortColumn); supSetWaitCursor(FALSE); EnableWindow(GetDlgItem(hwndDlg, ID_SEARCH_FIND), TRUE); } break; } return FALSE; }
/* * extrasCreatePNDialog * * Purpose: * * Create and initialize Private Namespaces Dialog. * */ VOID extrasCreatePNDialog( _In_ HWND hwndParent ) { LVCOLUMNW col; WCHAR szBuffer[MAX_PATH + 1]; //allow only one dialog if (g_wobjDialogs[WOBJ_PNDLG_IDX]) { SetActiveWindow(g_wobjDialogs[WOBJ_PNDLG_IDX]); return; } RtlSecureZeroMemory(&PnDlgContext, sizeof(PnDlgContext)); PnDlgContext.hwndDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG_PNAMESPACE), hwndParent, &PNDialogProc, 0); if (PnDlgContext.hwndDlg == NULL) { return; } g_wobjDialogs[WOBJ_PNDLG_IDX] = PnDlgContext.hwndDlg; PnDlgContext.ListView = GetDlgItem(PnDlgContext.hwndDlg, ID_NAMESPACELIST); if (PnDlgContext.ListView) { ListView_SetImageList(PnDlgContext.ListView, ListViewImages, LVSIL_SMALL); ListView_SetExtendedListViewStyle(PnDlgContext.ListView, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_GRIDLINES | LVS_EX_LABELTIP); //create ObjectList columns RtlSecureZeroMemory(&col, sizeof(col)); col.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_FMT | LVCF_WIDTH | LVCF_ORDER | LVCF_IMAGE; col.iSubItem = 1; col.pszText = L"Name"; col.fmt = LVCFMT_LEFT | LVCFMT_BITMAP_ON_RIGHT; col.iOrder = 0; col.iImage = ImageList_GetImageCount(ListViewImages) - 1; col.cx = 400; ListView_InsertColumn(PnDlgContext.ListView, 1, &col); col.iSubItem = 2; col.pszText = L"Type"; col.iOrder = 1; col.iImage = -1; col.cx = 100; ListView_InsertColumn(PnDlgContext.ListView, 2, &col); col.iSubItem = 3; col.pszText = L"Namespace"; col.iOrder = 2; col.iImage = -1; col.cx = 100; ListView_InsertColumn(PnDlgContext.ListView, 3, &col); //remember columns count PnDlgContext.lvColumnCount = 3; if (PNDlgQueryInfo()) { ListView_SortItemsEx(PnDlgContext.ListView, &PNListCompareFunc, 0); RtlSecureZeroMemory(&szBuffer, sizeof(szBuffer)); wsprintfW(szBuffer, T_NAMESPACEOBJECTCNT, ListView_GetItemCount(PnDlgContext.ListView)); SetDlgItemText(PnDlgContext.hwndDlg, ID_PNAMESPACESINFO, szBuffer); } else { SetDlgItemText(PnDlgContext.hwndDlg, ID_PNAMESPACESINFO, T_NAMESPACEQUERYFAILED); } } }
/* * extrasCreateSSDTDialog * * Purpose: * * Create and initialize KiServiceTable Dialog. * */ VOID extrasCreateSSDTDialog( _In_ HWND hwndParent ) { LVCOLUMNW col; HANDLE hIcon; //allow only one dialog if (g_wobjDialogs[WOBJ_SSDTDLG_IDX]) { if (IsIconic(g_wobjDialogs[WOBJ_SSDTDLG_IDX])) ShowWindow(g_wobjDialogs[WOBJ_SSDTDLG_IDX], SW_RESTORE); else SetActiveWindow(g_wobjDialogs[WOBJ_SSDTDLG_IDX]); return; } RtlSecureZeroMemory(&SdtDlgContext, sizeof(SdtDlgContext)); SdtDlgContext.hwndDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG_EXTRASLIST), hwndParent, &SdtDialogProc, 0); if (SdtDlgContext.hwndDlg == NULL) { return; } g_wobjDialogs[WOBJ_SSDTDLG_IDX] = SdtDlgContext.hwndDlg; SetWindowText(SdtDlgContext.hwndDlg, TEXT("System Service Table")); hIcon = LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_ICON_MAIN), IMAGE_ICON, 0, 0, LR_SHARED); if (hIcon) { SetClassLongPtr(SdtDlgContext.hwndDlg, GCLP_HICON, (LONG_PTR)hIcon); DestroyIcon(hIcon); } SdtDlgContext.ListView = GetDlgItem(SdtDlgContext.hwndDlg, ID_EXTRASLIST); if (SdtDlgContext.ListView) { ListView_SetImageList(SdtDlgContext.ListView, ListViewImages, LVSIL_SMALL); ListView_SetExtendedListViewStyle(SdtDlgContext.ListView, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_GRIDLINES | LVS_EX_LABELTIP); //create ObjectList columns RtlSecureZeroMemory(&col, sizeof(col)); col.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_FMT | LVCF_WIDTH | LVCF_ORDER | LVCF_IMAGE; col.iSubItem = 1; col.pszText = L"Id"; col.fmt = LVCFMT_LEFT | LVCFMT_BITMAP_ON_RIGHT; col.iOrder = 0; col.iImage = ImageList_GetImageCount(ListViewImages) - 1; col.cx = 80; ListView_InsertColumn(SdtDlgContext.ListView, 1, &col); col.iSubItem = 2; col.pszText = L"Service Name"; col.iOrder = 1; col.iImage = -1; col.cx = 200; ListView_InsertColumn(SdtDlgContext.ListView, 2, &col); col.iSubItem = 3; col.pszText = L"Address"; col.iOrder = 2; col.iImage = -1; col.cx = 130; ListView_InsertColumn(SdtDlgContext.ListView, 3, &col); col.iSubItem = 4; col.pszText = L"Module"; col.iOrder = 3; col.iImage = -1; col.cx = 200; ListView_InsertColumn(SdtDlgContext.ListView, 4, &col); //remember columns count SdtDlgContext.lvColumnCount = 4; SdtListTable(); SendMessage(SdtDlgContext.hwndDlg, WM_SIZE, 0, 0); ListView_SortItemsEx(SdtDlgContext.ListView, &SdtDlgCompareFunc, 0); } }
/* * extrasCreateSSDTDialog * * Purpose: * * Create and initialize KiServiceTable Dialog. * */ VOID extrasCreateSSDTDialog( _In_ HWND hwndParent ) { LVCOLUMN col; //allow only one dialog if (g_wobjDialogs[WOBJ_SSDTDLG_IDX]) { if (IsIconic(g_wobjDialogs[WOBJ_SSDTDLG_IDX])) ShowWindow(g_wobjDialogs[WOBJ_SSDTDLG_IDX], SW_RESTORE); else SetActiveWindow(g_wobjDialogs[WOBJ_SSDTDLG_IDX]); return; } RtlSecureZeroMemory(&SdtDlgContext, sizeof(SdtDlgContext)); SdtDlgContext.hwndDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_DIALOG_EXTRASLIST), hwndParent, &SdtDialogProc, 0); if (SdtDlgContext.hwndDlg == NULL) { return; } g_wobjDialogs[WOBJ_SSDTDLG_IDX] = SdtDlgContext.hwndDlg; SdtDlgContext.SizeGrip = supCreateSzGripWindow(SdtDlgContext.hwndDlg); SetWindowText(SdtDlgContext.hwndDlg, TEXT("System Service Table")); extrasSetDlgIcon(SdtDlgContext.hwndDlg); SdtDlgContext.ListView = GetDlgItem(SdtDlgContext.hwndDlg, ID_EXTRASLIST); if (SdtDlgContext.ListView) { ListView_SetImageList(SdtDlgContext.ListView, ListViewImages, LVSIL_SMALL); ListView_SetExtendedListViewStyle(SdtDlgContext.ListView, LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER | LVS_EX_GRIDLINES | LVS_EX_LABELTIP); //columns RtlSecureZeroMemory(&col, sizeof(col)); col.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_FMT | LVCF_WIDTH | LVCF_ORDER | LVCF_IMAGE; col.iSubItem++; col.pszText = TEXT("Id"); col.fmt = LVCFMT_LEFT | LVCFMT_BITMAP_ON_RIGHT; col.iImage = ImageList_GetImageCount(ListViewImages) - 1; col.cx = 80; ListView_InsertColumn(SdtDlgContext.ListView, col.iSubItem, &col); col.iSubItem++; col.pszText = TEXT("Service Name"); col.iOrder++; col.iImage = -1; col.cx = 200; ListView_InsertColumn(SdtDlgContext.ListView, col.iSubItem, &col); col.iSubItem++; col.pszText = TEXT("Address"); col.iOrder++; col.cx = 130; ListView_InsertColumn(SdtDlgContext.ListView, col.iSubItem, &col); col.iSubItem++; col.pszText = TEXT("Module"); col.iOrder++; col.cx = 200; ListView_InsertColumn(SdtDlgContext.ListView, col.iSubItem, &col); //remember columns count SdtDlgContext.lvColumnCount = col.iSubItem; SdtListTable(); SendMessage(SdtDlgContext.hwndDlg, WM_SIZE, 0, 0); ListView_SortItemsEx(SdtDlgContext.ListView, &SdtDlgCompareFunc, 0); } }
/** * @brief WM_NOTIFY handler of Preview dialog. * @param hwnd - window handle. * @param idCtrl - identifier of the common control sending the message. * @param pnmh - pointer to an NMHDR structure that contains the notification code and additional information. */ static LRESULT PreviewDlg_OnNotify(HWND hwnd, int idCtrl, LPNMHDR pnmh) { switch (pnmh->code) { case LVN_ITEMCHANGED: { if (idCtrl != IDC_FILESLIST) break; LPNMLISTVIEW pnmv = (LPNMLISTVIEW)pnmh; if ((pnmv->uNewState & LVIS_SELECTED) != (pnmv->uOldState & LVIS_SELECTED)) { if (pnmv->uNewState & LVIS_SELECTED) { _ASSERTE(g_hFile == INVALID_HANDLE_VALUE && g_hBitmap == NULL); HWND hwndFileList = GetDlgItem(hwnd, IDC_FILESLIST); LVITEM lvi; ZeroMemory(&lvi, sizeof(lvi)); lvi.mask = LVIF_PARAM; lvi.iItem = pnmv->iItem; ListView_GetItem(hwndFileList, &lvi); FILE_ITEM_INFO* pFileItemInfo = (FILE_ITEM_INFO*)lvi.lParam; if (pFileItemInfo != NULL) { CWaitCursor wait(true); if (! OpenImageFile(hwnd, pFileItemInfo->szFileName)) OpenRegularFile(hwnd, pFileItemInfo->szFileName); } } else CloseViewPane(hwnd); } } break; case LVN_COLUMNCLICK: { if (idCtrl != IDC_FILESLIST) break; LPNMLISTVIEW pnmv = (LPNMLISTVIEW)pnmh; HWND hwndFileList = GetDlgItem(hwnd, IDC_FILESLIST); g_FilesListOrder.ToggleSortParams(hwndFileList, pnmv->iSubItem); LISTVIEW_SORT_PARAMS lvSortParams; lvSortParams.hwndList = hwndFileList; lvSortParams.iColumnNumber = pnmv->iSubItem; lvSortParams.bAscending = g_FilesListOrder.GetSortOrder(); switch (pnmv->iSubItem) { case CID_FILE_NAME: case CID_FILE_TYPE: lvSortParams.eCompareType = LISTVIEW_SORT_PARAMS::ICT_STRING; ListView_SortItemsEx(hwndFileList, &ListViewCompareFunc, (LPARAM)&lvSortParams); break; case CID_FILE_SIZE: lvSortParams.eCompareType = LISTVIEW_SORT_PARAMS::ICT_INTEGER; ListView_SortItems(hwndFileList, &FileSizeCompareFunc, (LPARAM)&lvSortParams); break; } } break; case TTN_GETDISPINFO: { LPTOOLTIPTEXT ptt = (LPTOOLTIPTEXT)pnmh; ptt->hinst = g_hInstance; ptt->uFlags |= TTF_DI_SETITEM; switch (ptt->hdr.idFrom) { case IDC_ZOOMIN: ptt->lpszText = MAKEINTRESOURCE(IDS_ZOOMIN); break; case IDC_ZOOMOUT: ptt->lpszText = MAKEINTRESOURCE(IDS_ZOOMOUT); break; case IDC_RESETSIZE: ptt->lpszText = MAKEINTRESOURCE(IDS_RESETSIZE); break; case IDC_FITIMAGE: ptt->lpszText = MAKEINTRESOURCE(IDS_FITIMAGE); break; } } break; } return FALSE; }
LRESULT FilterOnColumnClick( IN HWND hWnd, IN NMLISTVIEW *lpNmlv ) { HWND hWndList; HWND hWndHeader; int ColumnCount; int i; HDITEM hdi; LISTVIEW_OBJECT *Object; PDIALOG_OBJECT Dialog; PFILTER_CONTEXT Context; Dialog = (PDIALOG_OBJECT)SdkGetObject(hWnd); Context = SdkGetContext(Dialog, FILTER_CONTEXT); Object = Context->ListObject; ASSERT(Object != NULL); if (Object->SortOrder == SortOrderNone){ return 0; } if (Object->LastClickedColumn == lpNmlv->iSubItem) { Object->SortOrder = (LIST_SORT_ORDER)!Object->SortOrder; } else { Object->SortOrder = SortOrderAscendent; } hWndList = GetDlgItem(hWnd, IDC_LIST_FILTER); hWndHeader = ListView_GetHeader(hWndList); ASSERT(hWndHeader); ColumnCount = Header_GetItemCount(hWndHeader); for (i = 0; i < ColumnCount; i++) { hdi.mask = HDI_FORMAT; Header_GetItem(hWndHeader, i, &hdi); if (i == lpNmlv->iSubItem) { hdi.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP); if (Object->SortOrder == SortOrderAscendent){ hdi.fmt |= HDF_SORTUP; } else { hdi.fmt |= HDF_SORTDOWN; } } else { hdi.fmt &= ~(HDF_SORTDOWN | HDF_SORTUP); } Header_SetItem(hWndHeader, i, &hdi); } Object->LastClickedColumn = lpNmlv->iSubItem; Object->hWnd = lpNmlv->hdr.hwndFrom; Object->CtrlId = lpNmlv->hdr.idFrom; ListView_SortItemsEx(hWndList, FilterSortCallback, (LPARAM)Object); return 0L; }
void CSubtitleUpDlg::OnRightClick(NMHDR* pNMHDR, LRESULT* pResult) { LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR; if (lpnmlv->iItem >= 0 && lpnmlv->iSubItem >= 0) { auto& s = AfxGetAppSettings(); SubtitlesProvider& provider = *(SubtitlesProvider*)(m_list.GetItemData(lpnmlv->iItem)); enum { SET_CREDENTIALS = 0x1000, RESET_CREDENTIALS, MOVE_UP, MOVE_DOWN, OPEN_URL }; CMenu m; m.CreatePopupMenu(); m.AppendMenu(MF_STRING | (provider.Flags(SPF_LOGIN) ? MF_ENABLED : MF_DISABLED), SET_CREDENTIALS, ResStr(IDS_SUBMENU_SETUP)); m.AppendMenu(MF_STRING | (provider.Flags(SPF_LOGIN) && !provider.UserName().empty() ? MF_ENABLED : MF_DISABLED), RESET_CREDENTIALS, ResStr(IDS_SUBMENU_RESET)); m.AppendMenu(MF_SEPARATOR); m.AppendMenu(MF_STRING | (lpnmlv->iItem > 0 ? MF_ENABLED : MF_DISABLED), MOVE_UP, ResStr(IDS_SUBMENU_MOVEUP)); m.AppendMenu(MF_STRING | (lpnmlv->iItem < m_list.GetItemCount() - 1 ? MF_ENABLED : MF_DISABLED), MOVE_DOWN, ResStr(IDS_SUBMENU_MOVEDOWN)); m.AppendMenu(MF_SEPARATOR); m.AppendMenu(MF_STRING | MF_ENABLED, OPEN_URL, ResStr(IDS_SUBMENU_OPENURL)); CPoint pt = lpnmlv->ptAction; ::MapWindowPoints(lpnmlv->hdr.hwndFrom, HWND_DESKTOP, &pt, 1); switch (m.TrackPopupMenu(TPM_LEFTBUTTON | TPM_RETURNCMD, pt.x, pt.y, this)) { case OPEN_URL: provider.OpenUrl(); break; case SET_CREDENTIALS: { CString szUser(UTF8To16(provider.UserName().c_str())); CString szPass(UTF8To16(provider.Password().c_str())); CString szDomain(provider.Name().c_str()); if (ERROR_SUCCESS == PromptForCredentials(GetSafeHwnd(), ResStr(IDS_SUB_CREDENTIALS_TITLE), ResStr(IDS_SUB_CREDENTIALS_MSG) + CString(provider.Url().c_str()), szDomain, szUser, szPass, /*&bSave*/nullptr)) { provider.UserName((const char*)UTF16To8(szUser)); provider.Password((const char*)UTF16To8(szPass)); m_list.SetItemText(lpnmlv->iItem, 1, szUser); s.strSubtitlesProviders = CString(m_pMainFrame->m_pSubtitlesProviders->WriteSettings().c_str()); s.SaveSettings(); } break; } case RESET_CREDENTIALS: provider.UserName(""); provider.Password(""); m_list.SetItemText(lpnmlv->iItem, 1, _T("")); s.strSubtitlesProviders = CString(m_pMainFrame->m_pSubtitlesProviders->WriteSettings().c_str()); s.SaveSettings(); break; case MOVE_UP: { m_pMainFrame->m_pSubtitlesProviders->MoveUp(lpnmlv->iItem); ListView_SortItemsEx(m_list.GetSafeHwnd(), SortCompare, m_list.GetSafeHwnd()); s.strSubtitlesProviders = CString(m_pMainFrame->m_pSubtitlesProviders->WriteSettings().c_str()); s.SaveSettings(); break; } case MOVE_DOWN: { m_pMainFrame->m_pSubtitlesProviders->MoveDown(lpnmlv->iItem); ListView_SortItemsEx(m_list.GetSafeHwnd(), SortCompare, m_list.GetSafeHwnd()); s.strSubtitlesProviders = CString(m_pMainFrame->m_pSubtitlesProviders->WriteSettings().c_str()); s.SaveSettings(); break; } default: break; } } }
//this is the history list window handler INT_PTR CALLBACK DlgProcHistLst(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { static int bInitializing; switch (msg) { case WM_INITDIALOG: bInitializing = 1; { int renderer = lstPopupHistory.GetRenderer(); SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)IcoLib_GetIcon(ICO_HISTORY,0)); SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM)IcoLib_GetIcon(ICO_HISTORY,1)); LoadRenderer(hWnd, renderer); TranslateDialogDefault(hWnd); HWND hHistoryList = GetDlgItem(hWnd, IDC_LST_HISTORY); ListView_SetExtendedListViewStyleEx(hHistoryList, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT); mir_subclassWindow(hHistoryList, PopupsListSubclassProc); LoadHistoryColumns(hHistoryList); RefreshPopupHistory(hWnd, renderer); } bInitializing = 0; return TRUE; case WM_DESTROY: UnloadRenderer(hWnd, lstPopupHistory.GetRenderer()); hHistoryWindow = NULL; break; case WM_CLOSE: DestroyWindow(hWnd); break; case WM_WINDOWPOSCHANGING: { WINDOWPOS *wndPos = (WINDOWPOS *) lParam; if (wndPos->cx < MIN_HISTORY_WIDTH) wndPos->cx = MIN_HISTORY_WIDTH; if (wndPos->cy < MIN_HISTORY_HEIGHT) wndPos->cy = MIN_HISTORY_HEIGHT; RECT rParent; GetWindowRect(hWnd, &rParent); HDWP hdWnds = BeginDeferWindowPos(4); AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_CLOSE), &rParent, wndPos, ANCHOR_RIGHT | ANCHOR_BOTTOM); AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_HISTORY_FILTER), &rParent, wndPos, ANCHOR_LEFT | ANCHOR_BOTTOM); AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_HISTORY_FILTER_CASESENSITIVE), &rParent, wndPos, ANCHOR_LEFT | ANCHOR_RIGHT | ANCHOR_BOTTOM); AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_LST_HISTORY), &rParent, wndPos, ANCHOR_ALL); EndDeferWindowPos(hdWnds); MoveCustomControl(hWnd, lstPopupHistory.GetRenderer()); //move the custom control too, if any } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_CLOSE: SendMessage(hWnd, WM_CLOSE, 0, 0); break; case IDC_HISTORY_FILTER_CASESENSITIVE: if (HIWORD(wParam) == BN_CLICKED) RefreshPopupHistory(hWnd, lstPopupHistory.GetRenderer()); case IDC_HISTORY_FILTER: if (HIWORD(wParam) == EN_CHANGE) if (!bInitializing) RefreshPopupHistory(hWnd, lstPopupHistory.GetRenderer()); break; } break; case WM_NOTIFY: switch(((LPNMHDR)lParam)->idFrom) { case IDC_LST_HISTORY: switch (((LPNMHDR)lParam)->code) { case LVN_COLUMNCLICK: { LPNMLISTVIEW lv = (LPNMLISTVIEW) lParam; int column = lv->iSubItem; SortParams params = {0}; params.hList = GetDlgItem(hWnd, IDC_LST_HISTORY); params.column = column; ListView_SortItemsEx(params.hList, PopupsCompare, (LPARAM) ¶ms); lastColumn = (params.column == lastColumn) ? -1 : params.column; break; } } } break; } return 0; }