| 9732 | |
| 9733 | |
| 9734 | void GuiType::ControlSetListViewOptions(GuiControlType &aControl, GuiControlOptionsType &aOpt) |
| 9735 | // Caller has ensured that aControl.type is ListView. |
| 9736 | // Caller has ensured that aOpt.color_bk is CLR_INVALID if no change should be made to the |
| 9737 | // current background color. |
| 9738 | { |
| 9739 | if (aOpt.limit) |
| 9740 | { |
| 9741 | if (ListView_GetItemCount(aControl.hwnd) > 0) |
| 9742 | SendMessage(aControl.hwnd, LVM_SETITEMCOUNT, aOpt.limit, 0); // Last parameter should be 0 for LVS_OWNERDATA (verified if you look at the definition of ListView_SetItemCount macro). |
| 9743 | else |
| 9744 | // When the control has no rows, work around the fact that LVM_SETITEMCOUNT delivers less than 20% |
| 9745 | // of its full benefit unless done after the first row is added (at least on XP SP1). The message |
| 9746 | // is deferred until later by setting this flag: |
| 9747 | aControl.union_lv_attrib->row_count_hint = aOpt.limit; |
| 9748 | } |
| 9749 | if (aOpt.color != CLR_INVALID || aOpt.color_bk != CLR_INVALID) |
| 9750 | { |
| 9751 | if (aOpt.color != CLR_INVALID) // Explicit color change was requested. |
| 9752 | { |
| 9753 | // Although MSDN doesn't say, ListView_SetTextColor() appears to support CLR_DEFAULT. |
| 9754 | ListView_SetTextColor(aControl.hwnd, aOpt.color); |
| 9755 | aOpt.color = CLR_INVALID; // Let ControlParseOptions() know we handled it. |
| 9756 | } |
| 9757 | if (aOpt.color_bk != CLR_INVALID) // Explicit color change was requested. |
| 9758 | { |
| 9759 | // Making both the same seems the best default because BkColor only applies to the portion |
| 9760 | // of the control that doesn't have text in it, which is typically very little. |
| 9761 | // Unlike ListView_SetTextBkColor, ListView_SetBkColor() treats CLR_DEFAULT as black. |
| 9762 | // therefore, make them both GetSysColor(COLOR_WINDOW) for consistency. This color is |
| 9763 | // probably the default anyway: |
| 9764 | COLORREF color = (aOpt.color_bk == CLR_DEFAULT) ? GetSysColor(COLOR_WINDOW) : aOpt.color_bk; |
| 9765 | ListView_SetTextBkColor(aControl.hwnd, color); |
| 9766 | ListView_SetBkColor(aControl.hwnd, color); |
| 9767 | } |
| 9768 | // It used to work without this; I don't know what conditions changed, but apparently it's needed |
| 9769 | // at least sometimes. The last param must be TRUE otherwise an space not filled by rows or columns |
| 9770 | // doesn't get updated: |
| 9771 | InvalidateRect(aControl.hwnd, NULL, TRUE); |
| 9772 | } |
| 9773 | } |
| 9774 | |
| 9775 | |
| 9776 |
nothing calls this directly
no outgoing calls
no test coverage detected