void SaveColumnSizes(HWND hwndResults) { int columnOrder[NUM_COLUMNID]; int columnCount; char szSetting[32]; int i; struct FindAddDlgData *dat; dat = (struct FindAddDlgData*)GetWindowLongPtr(GetParent(hwndResults), GWLP_USERDATA); columnCount = Header_GetItemCount(ListView_GetHeader(hwndResults)); if (columnCount != NUM_COLUMNID) return; ListView_GetColumnOrderArray(hwndResults, columnCount, columnOrder); for (i=0; i < NUM_COLUMNID; i++) { mir_snprintf(szSetting, SIZEOF(szSetting), "ColOrder%d", i); db_set_b(NULL, "FindAdd", szSetting, (BYTE)columnOrder[i]); if (i>=columnCount) continue; mir_snprintf(szSetting, SIZEOF(szSetting), "ColWidth%d", i); db_set_w(NULL, "FindAdd", szSetting, (WORD)ListView_GetColumnWidth(hwndResults, i)); } db_set_b(NULL, "FindAdd", "SortColumn", (BYTE)dat->iLastColumnSortIndex); db_set_b(NULL, "FindAdd", "SortAscending", (BYTE)dat->bSortAscending); }
int CCListBox::GetColumnIndexesAndSizes(LIST_COLUMNORDER* p) { int nColumns = this->GetColumnCount(); int i; int* pOrder = NULL; // Get column orders. pOrder = new int[nColumns]; if(pOrder == 0) return -1; ListView_GetColumnOrderArray(m_hWnd, nColumns, pOrder); // Now get the column sizes and stick ALL the info in the outgoing struct for(i=0;i<nColumns;i++) { if(p) p[i].Set(pOrder[i], ListView_GetColumnWidth(m_hWnd, i)); } delete [] pOrder; return nColumns; }
uint32 FolderWindow::onMessage(uint32 message, uint32 wParam, uint32 lParam) { switch (message) { case WM_CONTEXTMENU: { POINT pt; GetCursorPos(&pt); int count = ListView_GetSelectedCount(list->getHandle()); int item = ListView_GetNextItem(list->getHandle(), -1, LVNI_SELECTED); if (item >= 0) { int pos = list->getItemParam(item); while (count > 1 && item >= 0 && items[pos].type != ITEM_FOLDER && items[pos].type != ITEM_REPLAY) { item = ListView_GetNextItem(list->getHandle(), item, LVNI_SELECTED); pos = (item > 0 ? list->getItemParam(item) : -1); } EnableMenuItem(ctxMenu, ID_MENU_OPEN, count > 1 ? MF_GRAYED : MF_ENABLED); if (pos >= 0 && (items[pos].type == ITEM_FOLDER || items[pos].type == ITEM_REPLAY)) { EnableMenuItem(ctxMenu, ID_MENU_BACKUP, MF_ENABLED); EnableMenuItem(ctxMenu, ID_MENU_COPY, MF_ENABLED); EnableMenuItem(ctxMenu, ID_MENU_DELETE, MF_ENABLED); EnableMenuItem(ctxMenu, ID_MENU_RENAME, count > 1 ? MF_GRAYED : MF_ENABLED); } else { EnableMenuItem(ctxMenu, ID_MENU_BACKUP, MF_GRAYED); EnableMenuItem(ctxMenu, ID_MENU_COPY, MF_GRAYED); EnableMenuItem(ctxMenu, ID_MENU_DELETE, MF_GRAYED); EnableMenuItem(ctxMenu, ID_MENU_RENAME, MF_GRAYED); } } else { EnableMenuItem(ctxMenu, ID_MENU_OPEN, MF_GRAYED); EnableMenuItem(ctxMenu, ID_MENU_BACKUP, MF_GRAYED); EnableMenuItem(ctxMenu, ID_MENU_COPY, MF_GRAYED); EnableMenuItem(ctxMenu, ID_MENU_DELETE, MF_GRAYED); EnableMenuItem(ctxMenu, ID_MENU_RENAME, MF_GRAYED); } ClipboardReader cbReader(CF_HDROP); EnableMenuItem(ctxMenu, ID_MENU_PASTE, cbReader.getData() ? MF_ENABLED : MF_GRAYED); int result = TrackPopupMenuEx(ctxMenu, TPM_HORIZONTAL | TPM_LEFTALIGN | TPM_RETURNCMD | TPM_NONOTIFY, pt.x, pt.y, list->getHandle(), NULL); switch (result) { case ID_MENU_OPEN: { NMITEMACTIVATE ia; memset(&ia, 0, sizeof ia); ia.hdr.code = LVN_ITEMACTIVATE; ia.hdr.hwndFrom = list->getHandle(); ia.iItem = item; onMessage(WM_NOTIFY, 0, (uint32) &ia); } break; case ID_MENU_BACKUP: { BatchDialog batch(BatchDialog::mCopy); for (int item = ListView_GetNextItem(list->getHandle(), -1, LVNI_SELECTED); item >= 0; item = ListView_GetNextItem(list->getHandle(), item, LVNI_SELECTED)) { int pos = list->getItemParam(item); if (pos >= 0 && items[pos].type == ITEM_REPLAY) batch.addReplay(items[pos].path); else if (pos >= 0 && items[pos].type == ITEM_FOLDER) batch.addFolder(items[pos].path); } batch.run(list->getHandle()); } break; case ID_MENU_COPY: case ID_MENU_PASTE: case ID_MENU_DELETE: case ID_MENU_RENAME: { NMLVKEYDOWN kd; memset(&kd, 0, sizeof kd); kd.hdr.code = LVN_KEYDOWN; kd.hdr.hwndFrom = list->getHandle(); if (result == ID_MENU_COPY) kd.wVKey = 'C'; else if (result == ID_MENU_PASTE) kd.wVKey = 'V'; else if (result == ID_MENU_DELETE) kd.wVKey = VK_DELETE; else if (result == ID_MENU_RENAME) kd.wVKey = VK_F2; onMessage(WM_NOTIFY, VK_CONTROL, (uint32) &kd); } break; case ID_MENU_FOLDER: { String newdir = "New Folder"; String fulldir = String::buildFullName(path, newdir); FileInfo fi; for (int num = 1; pathFileExists(fulldir); num++) { newdir = String::format("New Folder (%d)", num); fulldir = String::buildFullName(path, newdir); } if (CreateDirectory(fulldir, NULL)) { int pos = list->addItem(newdir, getApp()->getImageLibrary()->getListIndex("IconClosedFolder"), items.length()); ViewItem& item = items.push(); item.path = fulldir; item.pos = pos; item.type = ITEM_FOLDER; ListView_EditLabel(list->getHandle(), pos); } } break; } } break; case WM_NOTIFY: { NMHDR* pnm = (NMHDR*) lParam; if (pnm->code == LVN_ITEMACTIVATE) { NMITEMACTIVATE* pia = (NMITEMACTIVATE*) pnm; int pos = -1; if (pia->iItem >= 0) pos = list->getItemParam(pia->iItem); if (pos >= 0 && pos < items.length()) { if (items[pos].type == ITEM_UPFOLDER || items[pos].type == ITEM_FOLDER) mainWnd->pushView(new FolderViewItem(items[pos].path)); else if (items[pos].type == ITEM_REPLAY) mainWnd->pushView(new ReplayViewItem(items[pos].path)); } } else if (pnm->code == LVN_BEGINDRAG) { Array<String> sel; getSelList(sel); if (sel.length()) { HGLOBAL data = CreateFileDrop(sel); if (data) { selfDrag = true; DoDragDrop(CF_HDROP, data, DROPEFFECT_MOVE | DROPEFFECT_COPY | DROPEFFECT_LINK); selfDrag = false; } } return TRUE; } else if (pnm->code == LVN_BEGINLABELEDIT) { NMLVDISPINFO* di = (NMLVDISPINFO*) lParam; int pos = -1; if (di->item.iItem >= 0) pos = list->getItemParam(di->item.iItem); if (pos >= 0 && pos < items.length() && (items[pos].type == ITEM_FOLDER || items[pos].type == ITEM_REPLAY)) return FALSE; return TRUE; } else if (pnm->code == LVN_ENDLABELEDIT) { NMLVDISPINFO* di = (NMLVDISPINFO*) lParam; int pos = -1; if (di->item.iItem >= 0) pos = list->getItemParam(di->item.iItem); if (di->item.pszText && pos >= 0 && pos < items.length() && (items[pos].type == ITEM_FOLDER || items[pos].type == ITEM_REPLAY)) { String src = items[pos].path; String dst = String::buildFullName(String::getPath(src), di->item.pszText); src += '\0'; if (items[pos].type == ITEM_REPLAY) dst += ".w3g"; dst += '\0'; SHFILEOPSTRUCT op; memset(&op, 0, sizeof op); op.wFunc = FO_RENAME; op.pFrom = src; op.pTo = dst; if (SHFileOperationEx(&op) == 0) { items[pos].path = String::buildFullName(String::getPath(items[pos].path), di->item.pszText); if (items[pos].type == ITEM_REPLAY) items[pos].path += ".w3g"; return TRUE; } } rebuild(); return FALSE; } else if (pnm->code == LVN_COLUMNCLICK) { NMLISTVIEW* lv = (NMLISTVIEW*) lParam; bool colShow[colCount] = {true, cfg.selColumns & COL_SAVED, cfg.selColumns & COL_SIZE, cfg.selColumns & COL_NAME, cfg.selColumns & COL_RATIO, cfg.selColumns & COL_LENGTH, cfg.selColumns & COL_MODE }; int col = lv->iSubItem; for (int i = 0; i < col && col < colCount - 1; i++) if (!colShow[i]) col++; int pos = 0; while (pos < colCount - 1 && cfg.colSort[pos] != col && cfg.colSort[pos] != ~col) pos++; if (pos == 0) cfg.colSort[0] = ~cfg.colSort[0]; else { for (int i = pos; i > 0; i--) cfg.colSort[i] = cfg.colSort[i - 1]; cfg.colSort[0] = col; } rebuild(); } else if (pnm->code == HDN_ENDDRAG) PostMessage(list->getHandle(), WM_POSTHEADERDRAG, 0, 0); else if (pnm->code == HDN_ENDTRACK) { NMHEADER* nhdr = (NMHEADER*) pnm; bool colShow[colCount] = {true, cfg.selColumns & COL_SAVED, cfg.selColumns & COL_SIZE, cfg.selColumns & COL_NAME, cfg.selColumns & COL_RATIO, cfg.selColumns & COL_LENGTH, cfg.selColumns & COL_MODE }; int count = 0; int colUnpos[colCount]; for (int i = 0; i < colCount; i++) if (colShow[i]) colUnpos[count++] = i; if (nhdr->iItem >= 0 && nhdr->iItem < count && nhdr->pitem && nhdr->pitem->mask & HDI_WIDTH) { int col = colUnpos[nhdr->iItem]; cfg.colWidth[col] = nhdr->pitem->cxy; } } else if (pnm->code == LVN_KEYDOWN) { NMLVKEYDOWN* kd = (NMLVKEYDOWN*) lParam; bool controlKey = ((GetAsyncKeyState(VK_CONTROL) & 0x8000) || wParam == VK_CONTROL); if (kd->wVKey == 'C' && controlKey) { Array<String> sel; getSelList(sel); if (sel.length()) { HGLOBAL hDrop = CreateFileDrop(sel); SetClipboard(CF_HDROP, hDrop); } } else if (kd->wVKey == 'V' && controlKey) { ClipboardReader clip(CF_HDROP); HGLOBAL hDrop = clip.getData(); if (hDrop) doPaste(hDrop, DROPEFFECT_COPY, path); } else if (kd->wVKey == VK_DELETE) { Array<String> sel; getSelList(sel); if (sel.length()) { char* str = FileListToString(sel); SHFILEOPSTRUCT fileop; memset(&fileop, 0, sizeof fileop); fileop.wFunc = FO_DELETE; fileop.pFrom = str; SHFileOperationEx(&fileop); } } else if (kd->wVKey == VK_F2) { SetFocus(list->getHandle()); int sel = ListView_GetNextItem(list->getHandle(), -1, LVNI_FOCUSED); if (sel < 0) sel = 0; ListView_EditLabel(list->getHandle(), sel); } } } break; case WM_DRAGOVER: case WM_DRAGLEAVE: { LVHITTESTINFO ht; LVITEM lvi; memset(&lvi, 0, sizeof lvi); if (message == WM_DRAGOVER) { ht.pt.x = LOWORD(lParam); ht.pt.y = HIWORD(lParam); ListView_HitTest(list->getHandle(), &ht); if (ht.iItem >= 0) { lvi.iItem = ht.iItem; lvi.mask = LVIF_PARAM | LVIF_STATE; lvi.stateMask = LVIS_SELECTED; ListView_GetItem(list->getHandle(), &lvi); if (lvi.lParam < 0 || lvi.lParam >= items.length() || (items[lvi.lParam].type != ITEM_UPFOLDER && items[lvi.lParam].type != ITEM_FOLDER)) ht.iItem = -1; if (selfDrag && (lvi.state & LVIS_SELECTED)) ht.iItem = -1; } if (wParam && selfDrag && ht.iItem == -1 && *(DWORD*) wParam == DROPEFFECT_MOVE) *(DWORD*) wParam = DROPEFFECT_NONE; } else ht.iItem = -1; if (ht.iItem != list->highlight) { lvi.mask = LVIF_STATE; lvi.stateMask = LVIS_DROPHILITED; if (list->highlight >= 0) { lvi.iItem = list->highlight; ListView_SetItem(list->getHandle(), &lvi); } if (ht.iItem >= 0) { lvi.state = LVIS_DROPHILITED; lvi.iItem = ht.iItem; ListView_SetItem(list->getHandle(), &lvi); } list->highlight = ht.iItem; } } break; case WM_DRAGDROP: if (lParam == DROPEFFECT_MOVE || lParam == DROPEFFECT_COPY) { String opTo = path; if (list->highlight >= 0) { int param = list->getItemParam(list->highlight); if (param >= 0 && param < items.length() && (items[param].type == ITEM_UPFOLDER || items[param].type == ITEM_FOLDER)) opTo = items[param].path; } doPaste((HGLOBAL) wParam, lParam, opTo); } return 0; case WM_POSTHEADERDRAG: { bool colShow[colCount] = {true, cfg.selColumns & COL_SAVED, cfg.selColumns & COL_SIZE, cfg.selColumns & COL_NAME, cfg.selColumns & COL_RATIO, cfg.selColumns & COL_LENGTH, cfg.selColumns & COL_MODE }; int count = 0; int colUnpos[colCount]; for (int i = 0; i < colCount; i++) if (colShow[i]) colUnpos[count++] = i; int colOrder[colCount]; ListView_GetColumnOrderArray(list->getHandle(), count, colOrder); int pos = 0; for (int i = 0; i < colCount; i++) if (colShow[cfg.colOrder[i]]) cfg.colOrder[i] = colUnpos[colOrder[pos++]]; } break; case WM_REBUILDLIST: if (ListView_GetEditControl(list->getHandle()) == NULL) rebuild(); break; case WM_UPDATELISTITEM: updateListItem(wParam, lParam); break; default: return M_UNHANDLED; } return 0; }
void CTableEditHelperV2_ListView::TableEdit_GetColumnOrder(t_size * out, t_size count) const { pfc::array_t<int> temp; temp.set_size(count); WIN32_OP_D( ListView_GetColumnOrderArray( TableEdit_GetParentWnd(), count, temp.get_ptr() ) ); for(t_size walk = 0; walk < count; ++walk) out[walk] = temp[walk]; }
uint32 SearchResults::onMessage(uint32 message, uint32 wParam, uint32 lParam) { switch (message) { case WM_ADDFILE: EnterCriticalSection(&lock); while (getCount() < items.length()) addItem(getCount(), true); LeaveCriticalSection(&lock); return 0; case WM_NOTIFY: { NMHDR* pnm = (NMHDR*) lParam; if (pnm->code == LVN_ITEMACTIVATE) { NMITEMACTIVATE* pia = (NMITEMACTIVATE*) pnm; if (pia->iItem >= 0 && pia->iItem < items.length()) { SendMessage(getApp()->getMainWindow(), WM_PUSHVIEW, (uint32) new ReplayViewItem(items[pia->iItem].path), 0); } return 0; } else if (pnm->code == LVN_BEGINDRAG) { Array<String> sel; getSelList(sel); if (sel.length()) { HGLOBAL data = CreateFileDrop(sel); if (data) DoDragDrop(CF_HDROP, data, DROPEFFECT_MOVE | DROPEFFECT_COPY | DROPEFFECT_LINK); } return TRUE; } else if (pnm->code == LVN_COLUMNCLICK) { NMLISTVIEW* lv = (NMLISTVIEW*) lParam; bool colShow[colCount] = {true, cfg.selColumns & COL_SAVED, cfg.selColumns & COL_SIZE, cfg.selColumns & COL_NAME, cfg.selColumns & COL_RATIO, cfg.selColumns & COL_LENGTH, cfg.selColumns & COL_MODE }; int col = lv->iSubItem; for (int i = 0; i < col && col < colCount - 1; i++) if (!colShow[i]) col++; int pos = 0; while (pos < colCount - 1 && cfg.colSort[pos] != col && cfg.colSort[pos] != ~col) pos++; if (pos == 0) cfg.colSort[0] = ~cfg.colSort[0]; else { for (int i = pos; i > 0; i--) cfg.colSort[i] = cfg.colSort[i - 1]; cfg.colSort[0] = col; } rebuild(); } else if (pnm->code == HDN_ENDDRAG) PostMessage(hWnd, WM_POSTHEADERDRAG, 0, 0); else if (pnm->code == HDN_ENDTRACK) { NMHEADER* nhdr = (NMHEADER*) pnm; bool colShow[colCount] = {true, cfg.selColumns & COL_SAVED, cfg.selColumns & COL_SIZE, cfg.selColumns & COL_NAME, cfg.selColumns & COL_RATIO, cfg.selColumns & COL_LENGTH, cfg.selColumns & COL_MODE }; int count = 0; int colUnpos[colCount]; for (int i = 0; i < colCount; i++) if (colShow[i]) colUnpos[count++] = i; if (nhdr->iItem >= 0 && nhdr->iItem < count && nhdr->pitem && nhdr->pitem->mask & HDI_WIDTH) { int col = colUnpos[nhdr->iItem]; cfg.colWidth[col] = nhdr->pitem->cxy; } } else if (pnm->code == LVN_KEYDOWN) { NMLVKEYDOWN* kd = (NMLVKEYDOWN*) lParam; bool controlKey = ((GetAsyncKeyState(VK_CONTROL) & 0x8000) || wParam == VK_CONTROL); if (kd->wVKey == 'C' && controlKey) { Array<String> sel; getSelList(sel); if (sel.length()) { HGLOBAL hDrop = CreateFileDrop(sel); SetClipboard(CF_HDROP, hDrop); } } else if (kd->wVKey == VK_DELETE) { Array<String> sel; getSelList(sel); if (sel.length()) { char* str = FileListToString(sel); SHFILEOPSTRUCT fileop; memset(&fileop, 0, sizeof fileop); fileop.wFunc = FO_DELETE; fileop.pFrom = str; SHFileOperationEx(&fileop); } } return 0; } } break; case WM_POSTHEADERDRAG: { bool colShow[colCount] = {true, cfg.selColumns & COL_SAVED, cfg.selColumns & COL_SIZE, cfg.selColumns & COL_NAME, cfg.selColumns & COL_RATIO, cfg.selColumns & COL_LENGTH, cfg.selColumns & COL_MODE }; int count = 0; int colUnpos[colCount]; for (int i = 0; i < colCount; i++) if (colShow[i]) colUnpos[count++] = i; int colOrder[colCount]; ListView_GetColumnOrderArray(hWnd, count, colOrder); int pos = 0; for (int i = 0; i < colCount; i++) if (colShow[cfg.colOrder[i]]) cfg.colOrder[i] = colUnpos[colOrder[pos++]]; } return 0; } return ListFrame::onMessage(message, wParam, lParam); }
BOOL Picker_SaveColumnWidths(HWND hwndPicker) { struct PickerInfo *pPickerInfo; int *widths; int *order; int *tmpOrder; int nColumnMax = 0, i = 0; BOOL bSuccess = FALSE; BOOL res = 0; pPickerInfo = GetPickerInfo(hwndPicker); /* allocate space for the column info */ widths = (int*)malloc(pPickerInfo->nColumnCount * sizeof(*widths)); order = (int*)malloc(pPickerInfo->nColumnCount * sizeof(*order)); tmpOrder = (int*)malloc(pPickerInfo->nColumnCount * sizeof(*tmpOrder)); if (!widths || !order || !tmpOrder) goto done; /* retrieve the values */ memset(widths, 0, pPickerInfo->nColumnCount * sizeof(*widths)); memset(order, 0, pPickerInfo->nColumnCount * sizeof(*order)); pPickerInfo->pCallbacks->pfnGetColumnWidths(widths); pPickerInfo->pCallbacks->pfnGetColumnOrder(order); /* switch the list view to LVS_REPORT style so column widths reported correctly */ SetWindowLong(hwndPicker, GWL_STYLE, (GetWindowLong(hwndPicker, GWL_STYLE) & ~LVS_TYPEMASK) | LVS_REPORT); nColumnMax = Picker_GetNumColumns(hwndPicker); if (GetUseOldControl()) { for (i = 0; i < nColumnMax; i++) { widths[Picker_GetRealColumnFromViewColumn(hwndPicker, i)] = ListView_GetColumnWidth(hwndPicker, i); } } else { /* Get the Column Order and save it */ res = ListView_GetColumnOrderArray(hwndPicker, nColumnMax, tmpOrder); for (i = 0; i < nColumnMax; i++) { widths[Picker_GetRealColumnFromViewColumn(hwndPicker, i)] = ListView_GetColumnWidth(hwndPicker, i); order[i] = Picker_GetRealColumnFromViewColumn(hwndPicker, tmpOrder[i]); } } pPickerInfo->pCallbacks->pfnSetColumnWidths(widths); pPickerInfo->pCallbacks->pfnSetColumnOrder(order); bSuccess = TRUE; done: if (widths) free(widths); if (order) free(order); if (tmpOrder) free(tmpOrder); res++; return bSuccess; }
void Picker_HandleDrawItem(HWND hWnd, LPDRAWITEMSTRUCT lpDrawItemStruct) { struct PickerInfo *pPickerInfo; HDC hDC = lpDrawItemStruct->hDC; RECT rcItem = lpDrawItemStruct->rcItem; UINT uiFlags = ILD_TRANSPARENT; HIMAGELIST hImageList; int nItem = lpDrawItemStruct->itemID; COLORREF clrTextSave = 0; COLORREF clrBkSave = 0; COLORREF clrImage = GetSysColor(COLOR_WINDOW); static TCHAR szBuff[MAX_PATH]; BOOL bFocus = (GetFocus() == hWnd); LPCTSTR pszText; UINT nStateImageMask = 0; BOOL bSelected = 0; LV_COLUMN lvc; LV_ITEM lvi; RECT rcAllLabels; RECT rcLabel; RECT rcIcon; int offset = 0; SIZE size; int i = 0, j = 0; int nColumn = 0; int nColumnMax = 0; int *order; BOOL bDrawAsChild = 0; int indent_space = 0; BOOL bColorChild = FALSE; BOOL bParentFound = FALSE; int nParent = 0; HBITMAP hBackground = GetBackgroundBitmap(); MYBITMAPINFO *pbmDesc = GetBackgroundInfo(); BOOL res = 0; pPickerInfo = GetPickerInfo(hWnd); order = (int*)malloc(pPickerInfo->nColumnCount * sizeof(*order)); if (!order) return; nColumnMax = Picker_GetNumColumns(hWnd); if (GetUseOldControl()) { pPickerInfo->pCallbacks->pfnGetColumnOrder(order); } else { /* Get the Column Order and save it */ res = ListView_GetColumnOrderArray(hWnd, nColumnMax, order); /* Disallow moving column 0 */ if (order[0] != 0) { for (i = 0; i < nColumnMax; i++) { if (order[i] == 0) { order[i] = order[0]; order[0] = 0; } } res = ListView_SetColumnOrderArray(hWnd, nColumnMax, order); } } /* Labels are offset by a certain amount */ /* This offset is related to the width of a space character */ GetTextExtentPoint32(hDC, TEXT(" "), 1, &size); offset = size.cx; lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_PARAM; lvi.iItem = nItem; lvi.iSubItem = order[0]; lvi.pszText = szBuff; lvi.cchTextMax = sizeof(szBuff) / sizeof(szBuff[0]); lvi.stateMask = 0xFFFF; /* get all state flags */ res = ListView_GetItem(hWnd, &lvi); bSelected = ((lvi.state & LVIS_DROPHILITED) || ( (lvi.state & LVIS_SELECTED) && ((bFocus) || (GetWindowLong(hWnd, GWL_STYLE) & LVS_SHOWSELALWAYS)))); /* figure out if we indent and draw grayed */ if (pPickerInfo->pCallbacks->pfnFindItemParent) nParent = pPickerInfo->pCallbacks->pfnFindItemParent(hWnd, lvi.lParam); else nParent = -1; bDrawAsChild = (pPickerInfo->pCallbacks->pfnGetViewMode() == VIEW_GROUPED && (nParent >= 0)); /* only indent if parent is also in this view */ if ((nParent >= 0) && bDrawAsChild) { for (i = 0; i < ListView_GetItemCount(hWnd); i++) { lvi.mask = LVIF_PARAM; lvi.iItem = i; res = ListView_GetItem(hWnd, &lvi); if (lvi.lParam == nParent) { bParentFound = TRUE; break; } } } if (pPickerInfo->pCallbacks->pfnGetOffsetChildren && pPickerInfo->pCallbacks->pfnGetOffsetChildren()) { if (!bParentFound && bDrawAsChild) { /*Reset it, as no Parent is there*/ bDrawAsChild = FALSE; bColorChild = TRUE; } else { nParent = -1; bParentFound = FALSE; } } res = ListView_GetItemRect_Modified(hWnd, nItem, &rcAllLabels, LVIR_BOUNDS); res = ListView_GetItemRect_Modified(hWnd, nItem, &rcLabel, LVIR_LABEL); rcAllLabels.left = rcLabel.left; if (hBackground != NULL) { RECT rcClient; HRGN rgnBitmap; RECT rcTmpBmp = rcItem; RECT rcFirstItem; HPALETTE hPAL; HDC htempDC; HBITMAP oldBitmap; htempDC = CreateCompatibleDC(hDC); oldBitmap = (HBITMAP)SelectObject(htempDC, hBackground); GetClientRect(hWnd, &rcClient); rcTmpBmp.right = rcClient.right; /* We also need to check whether it is the last item The update region has to be extended to the bottom if it is */ if (nItem == ListView_GetItemCount(hWnd) - 1) rcTmpBmp.bottom = rcClient.bottom; rgnBitmap = CreateRectRgnIndirect(&rcTmpBmp); SelectClipRgn(hDC, rgnBitmap); DeleteBitmap(rgnBitmap); hPAL = GetBackgroundPalette(); if (hPAL == NULL) hPAL = CreateHalftonePalette(hDC); if (GetDeviceCaps(htempDC, RASTERCAPS) & RC_PALETTE && hPAL != NULL) { SelectPalette(htempDC, hPAL, FALSE); RealizePalette(htempDC); } res = ListView_GetItemRect_Modified(hWnd, 0, &rcFirstItem, LVIR_BOUNDS); for (i = rcFirstItem.left; i < rcClient.right; i += pbmDesc->bmWidth) for (j = rcFirstItem.top; j < rcClient.bottom; j += pbmDesc->bmHeight) BitBlt(hDC, i, j, pbmDesc->bmWidth, pbmDesc->bmHeight, htempDC, 0, 0, SRCCOPY); SelectObject(htempDC, oldBitmap); DeleteDC(htempDC); if (GetBackgroundPalette() == NULL) { DeletePalette(hPAL); hPAL = NULL; } } indent_space = 0; if (bDrawAsChild) { RECT rect; res = ListView_GetItemRect_Modified(hWnd, nItem, &rect, LVIR_ICON); /* indent width of icon + the space between the icon and text * so left of clone icon starts at text of parent */ indent_space = rect.right - rect.left + offset; } rcAllLabels.left += indent_space; if (bSelected) { HBRUSH hBrush; HBRUSH hOldBrush; if (bFocus) { clrTextSave = SetTextColor(hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); clrBkSave = SetBkColor(hDC, GetSysColor(COLOR_HIGHLIGHT)); hBrush = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT)); } else { clrTextSave = SetTextColor(hDC, GetSysColor(COLOR_BTNTEXT)); clrBkSave = SetBkColor(hDC, GetSysColor(COLOR_BTNFACE)); hBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); } hOldBrush = (HBRUSH)SelectObject(hDC, hBrush); FillRect(hDC, &rcAllLabels, hBrush); SelectObject(hDC, hOldBrush); DeleteBrush(hBrush); } else { if (hBackground == NULL) { HBRUSH hBrush; hBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW)); FillRect(hDC, &rcAllLabels, hBrush); DeleteBrush(hBrush); } if (pPickerInfo->pCallbacks->pfnGetOffsetChildren && pPickerInfo->pCallbacks->pfnGetOffsetChildren()) { if (bDrawAsChild || bColorChild) clrTextSave = SetTextColor(hDC, GetListCloneColor()); else clrTextSave = SetTextColor(hDC, GetListFontColor()); } else { if (bDrawAsChild) clrTextSave = SetTextColor(hDC, GetListCloneColor()); else clrTextSave = SetTextColor(hDC, GetListFontColor()); } clrBkSave = SetBkColor(hDC, GetSysColor(COLOR_WINDOW)); } if (lvi.state & LVIS_CUT) { clrImage = GetSysColor(COLOR_WINDOW); uiFlags |= ILD_BLEND50; } else if (bSelected) { if (bFocus) clrImage = GetSysColor(COLOR_HIGHLIGHT); else clrImage = GetSysColor(COLOR_BTNFACE); uiFlags |= ILD_BLEND50; } nStateImageMask = lvi.state & LVIS_STATEIMAGEMASK; if (nStateImageMask) { int nImage = (nStateImageMask >> 12) - 1; hImageList = ListView_GetImageList(hWnd, LVSIL_STATE); if (hImageList) ImageList_Draw(hImageList, nImage, hDC, rcItem.left, rcItem.top, ILD_TRANSPARENT); } res = ListView_GetItemRect_Modified(hWnd, nItem, &rcIcon, LVIR_ICON); rcIcon.left += indent_space; res = ListView_GetItemRect_Modified(hWnd, nItem, &rcItem, LVIR_LABEL); hImageList = ListView_GetImageList(hWnd, LVSIL_SMALL); if (hImageList) { UINT nOvlImageMask = lvi.state & LVIS_OVERLAYMASK; if (rcIcon.left + 16 + indent_space < rcItem.right) { ImageList_DrawEx(hImageList, lvi.iImage, hDC, rcIcon.left, rcIcon.top, 16, 16, GetSysColor(COLOR_WINDOW), clrImage, uiFlags | nOvlImageMask); } } res = ListView_GetItemRect_Modified(hWnd, nItem, &rcItem, LVIR_LABEL); pszText = MakeShortString(hDC, szBuff, rcItem.right - rcItem.left, 2*offset + indent_space); rcLabel = rcItem; rcLabel.left += offset + indent_space; rcLabel.right -= offset; DrawText(hDC, pszText, -1, &rcLabel, DT_LEFT | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER); for (nColumn = 1; nColumn < nColumnMax; nColumn++) { int nRetLen; UINT nJustify; LV_ITEM lvItem; lvc.mask = LVCF_FMT | LVCF_WIDTH; res = ListView_GetColumn(hWnd, order[nColumn], &lvc); lvItem.mask = LVIF_TEXT; lvItem.iItem = nItem; lvItem.iSubItem = order[nColumn]; lvItem.pszText = szBuff; lvItem.cchTextMax = sizeof(szBuff) / sizeof(szBuff[0]); if (ListView_GetItem(hWnd, &lvItem) == FALSE) continue; rcItem.left = rcItem.right; rcItem.right += lvc.cx; nRetLen = _tcslen(szBuff); if (nRetLen == 0) continue; pszText = MakeShortString(hDC, szBuff, rcItem.right - rcItem.left, 2 * offset); nJustify = DT_LEFT; if (pszText == szBuff) { switch (lvc.fmt & LVCFMT_JUSTIFYMASK) { case LVCFMT_RIGHT: nJustify = DT_RIGHT; break; case LVCFMT_CENTER: nJustify = DT_CENTER; break; default: break; } } rcLabel = rcItem; rcLabel.left += offset; rcLabel.right -= offset; DrawText(hDC, pszText, -1, &rcLabel, nJustify | DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER); } if (lvi.state & LVIS_FOCUSED && bFocus) DrawFocusRect(hDC, &rcAllLabels); SetTextColor(hDC, clrTextSave); SetBkColor(hDC, clrBkSave); free(order); res++; }
void ListView::ColumnsProxy::GetOrder(int* const array,const uint count) const { ListView_GetColumnOrderArray( control, count, array ); }