int TListViewCtrl::GetSelIndexes(int* indexes, int maxCount) const { if (GetStyle() & LVS_SINGLESEL) return -1; // Get the index of the first selected item. // int index = static_cast<int>( SendMessage(LVM_GETNEXTITEM, TParam1(-1), MkParam2(LVNI_ALL|LVNI_SELECTED, 0))); // Loop while index indicates a selected item. // int count = 0; // number of selected items found while (index != -1 && count < maxCount) { indexes[count] = index; count++; // Get the next selected item. // index = static_cast<int>( SendMessage(LVM_GETNEXTITEM, TParam1(index), MkParam2(LVNI_ALL|LVNI_SELECTED, 0))); } return count; }
int TListViewCtrl::GetSelStrings(tchar** strs, int maxCount, int maxChars, int subitemIndex) const { // This function is for multiselect list views only. // if (GetStyle() & LVS_SINGLESEL) return -1; // Get the index of the first selected item. // int index = static_cast<int>( SendMessage(LVM_GETNEXTITEM, TParam1(-1), MkParam2(LVNI_ALL|LVNI_SELECTED, 0))); // Loop through selected items. // int count = 0; while (index != -1) { GetItemText(index, subitemIndex, strs[count], maxChars); count++; if (count > maxCount) break; // Get the next selected item. // index = static_cast<int>( SendMessage(LVM_GETNEXTITEM, TParam1(index), MkParam2(LVNI_ALL|LVNI_SELECTED, 0))); } return count; }
bool TListViewCtrl::GetItemRect(int index, TRect& r, TItemRectType type) { PRECONDITION(GetHandle()); r.left = type; return ToBool(SendMessage(LVM_GETITEMRECT, TParam1(index), TParam2(&r))); }
// /// Informs the sheet that the information in the specified page has reverted to the /// previously saved state. The sheet disables the 'Apply' button if no other pages /// have registered changes with the property sheet. // void TPropertySheet::PageUnchanged(TPropertyPage& pg) { PRECONDITION(HPROPSHEETPAGE(pg)); CHECK(GetHandle()); SendMessage(PSM_UNCHANGED, TParam1(pg.GetHandle())); }
bool TListViewCtrl::GetColumn(int index, LVCOLUMN* column) { PRECONDITION(column); PRECONDITION(GetHandle()); return ToBool(SendMessage(LVM_GETCOLUMN, TParam1(index), TParam2(column))); }
// /// Intercepts the WM_MDICREATE message sent when MDI child windows are created, /// and, if the client's style includes MDIS_ALLCHILDSTYLES, and the child window's /// specified style is 0, then changes the child window style attributes to /// WS_VISIBLE, WS_CHILD, WS_CLIPSIBLINGS, WS_CLIPCHILDREN, WS_SYSMENU, WS_CAPTION, /// WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX. // TResult TMDIClient::EvMDICreate(MDICREATESTRUCT & createStruct) { // Fill in default child window styles if they request style 0 since this // client by default has set allchildstyles // if ((Attr.Style&MDIS_ALLCHILDSTYLES) && !createStruct.style) createStruct.style = WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_SYSMENU | WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX; // Work around a Windows MDI bug w/ bad menus if MDI child is created // maximized, by hiding child now & maximizing later // uint32 origStyle = createStruct.style; if (createStruct.style & WS_MAXIMIZE) createStruct.style &= ~(WS_MAXIMIZE | WS_VISIBLE); TResult result = DefaultProcessing(); // Finish up maximized MDI child workaround // if (THandle(result) && (origStyle & WS_MAXIMIZE)) { HandleMessage(WM_MDIMAXIMIZE, TParam1(result)); HandleMessage(WM_MDIREFRESHMENU); } return result; }
bool TListViewCtrl::SetItemPosition(int index, const TPoint& pt) { PRECONDITION(GetHandle()); if (!IsRepresentable<uint16>(pt.x) || !IsRepresentable<uint16>(pt.y)) throw TXOwl(_T("TListViewCtrl:SetItemPosition: Argument is outside valid range")); return ToBool(SendMessage(LVM_SETITEMPOSITION, TParam1(index), MkParam2(pt.x, pt.y))); }
bool TListViewCtrl::GetSubItemRect(TRect& rect, int subidx, int paridx, int flag) const { PRECONDITION(GetHandle()); rect.top = subidx; rect.left = flag; return ToBool(SendMessage(LVM_GETSUBITEMRECT, TParam1(paridx), TParam2(&rect))); }
bool TListViewCtrl::SortItemsEx(const TCompareFunc& comparator, LPARAM lParam) { TListCompareThunk ct; ct.This = &comparator; ct.ItemData = lParam; return ToBool(SendMessage(LVM_SORTITEMSEX, TParam1(&ct), TParam2(OwlListViewCompare))); }
void TListViewCtrl::SetIconSpacing(int x, int y) { PRECONDITION(GetHandle()); if (y != -1 && (x < 0 || y < 0)) throw TXOwl(_T("TListViewCtrl:SetIconSpacing: Argument is outside valid range")); SendMessage(LVM_SETICONSPACING, TParam1(x), y); }
int TListViewCtrl::GetItemText(int index, int subitemIndex, LPTSTR buffer, int bufferSize) const { PRECONDITION(GetHandle()); TLvItem item; item.SetTextBuffer(buffer, bufferSize); item.SetSubItem(subitemIndex); return static_cast<int>(SendMessage(LVM_GETITEMTEXT, TParam1(index), TParam2(&item))); }
TSize TListViewCtrl::GetApproxRect(int x, int y, int count) const { PRECONDITION(GetHandle()); if (x != -1 && !IsRepresentable<uint16>(x) || y != -1 && !IsRepresentable<uint16>(y)) throw TXOwl(_T("TListViewCtrl:GetApproxRect: Argument is outside valid range")); TResult r = SendMessage(LVM_APPROXIMATEVIEWRECT, TParam1(count), MkParam2(x, y)); return TPoint(static_cast<DWORD>(r)); }
tstring TListViewCtrl::GetItemText(int index, int subitemIndex) const { PRECONDITION(GetHandle()); TLvItem item; item.SetSubItem(subitemIndex); SendMessage(LVM_GETITEMTEXT, TParam1(index), TParam2(&item)); return item.GetText(); }
bool TListViewCtrl::Update(int index) { PRECONDITION(GetHandle()); // If the list window has LVS_AUTOARRANGE, the items are automatically // arranged to their proper locations. return ToBool(SendMessage(LVM_UPDATE, TParam1(index))); }
// /// Searches for the MDI child menu in the new menu bar and updates the child menu /// position with the specified menu index. Then sends the client window an /// WM_MDISETMENU message to set the new menu and invokes TWindow::DrawMenuBar to /// redraw the menu. Returns false if the MDI client indicates that there was no /// previous menu; otherwise returns true. // bool TMDIFrame::SetMenu(HMENU newMenu) { PRECONDITION(newMenu); if (IsFlagSet(wfMainWindow)) GetApplication()->PreProcessMenu(newMenu); if (GetHandle()) { HMENU childMenu = FindChildMenu(newMenu); HMENU oldMenu = (HMENU)ClientWnd->HandleMessage(WM_MDISETMENU, TParam1(newMenu), TParam2(childMenu)); DrawMenuBar(); if (!oldMenu) return false; } return true; }
// /// Activates the page at the specified index in the property sheet. Returns true if /// successful or false otherwise. /// \note The page that's losing activation receives a PSN_KILLACTIVE notification /// while the window that's gaining activation receives a PSN_SETACTIVE /// notification. // bool TPropertySheet::SelectPage(int pgIndex) { PRECONDITION(GetHandle()); return SendMessage(PSM_SETCURSEL, TParam1(pgIndex)) != 0; }
// /// Simulates the choice of a property sheet button. The button parameter can be one /// of the following: /// - \c \b PSBTN_APPLYNOW Apply Now button. /// - \c \b PSBTN_BACK Back button. /// - \c \b PSBTN_CANCEL Cancel button. /// - \c \b PSBTN_FINISH Finish button. /// - \c \b PSBTN_HELP Help button. /// - \c \b PSBTN_NEXT Next button. /// - \c \b PSBTN_OK OK button // void TPropertySheet::PressButton(int button) { CHECK(GetHandle()); SendMessage(PSM_PRESSBUTTON, TParam1(button)); }
// /// Informs the sheet that information in a sheet has changed. The sheet enables the /// 'Apply' button. // void TPropertySheet::PageChanged(const TPropertyPage& pg) { PRECONDITION(HPROPSHEETPAGE(pg)); SendMessage(PSM_CHANGED, TParam1(pg.GetHandle())); }
void TListViewCtrl::SetItemCount(int numItems, uint32 flags) { PRECONDITION(GetHandle()); SendMessage(LVM_SETITEMCOUNT, TParam1(numItems), flags); }
bool TListViewCtrl::SetImageList(HIMAGELIST list, TImageListType type) { PRECONDITION(GetHandle()); return ToBool(SendMessage(LVM_SETIMAGELIST, TParam1(type), TParam2(list))); }
bool TListViewCtrl::SetColumnWidth(int index, int width) { PRECONDITION(GetHandle()); return ToBool(SendMessage(LVM_SETCOLUMNWIDTH, TParam1(index), MkParam2(width, 0))); }
HIMAGELIST TListViewCtrl::GetImageList(TImageListType type) { PRECONDITION(GetHandle()); return reinterpret_cast<HIMAGELIST>(SendMessage(LVM_GETIMAGELIST, TParam1(type))); }
bool TListViewCtrl::RedrawItems(int startIndex, int endIndex) { PRECONDITION(GetHandle()); return ToBool(SendMessage(LVM_REDRAWITEMS, TParam1(startIndex), TParam2(endIndex))); }
int TListViewCtrl::GetNextItem(int index, TNextItemCode code) const { PRECONDITION(GetHandle()); return static_cast<int>(SendMessage(LVM_GETNEXTITEM, TParam1(index), MkParam2(code, 0))); }
uint TListViewCtrl::GetItemState(int index, uint mask) const { PRECONDITION(GetHandle()); return static_cast<uint>(SendMessage(LVM_GETITEMSTATE, TParam1(index), TParam2(mask))); }
int TListViewCtrl::InsertColumn(int colNum, const TLvColumn& colItem) { PRECONDITION(GetHandle()); return static_cast<int>(SendMessage(LVM_INSERTCOLUMN, TParam1(colNum), TParam2(&colItem))); }
bool TListViewCtrl::GetItemPosition(int index, TPoint& pt) const { PRECONDITION(GetHandle()); return ToBool(SendMessage(LVM_GETITEMPOSITION, TParam1(index), TParam2(&pt))); }
// /// Sets the title of a property sheet. If 'style' parameter is the PSH_PROPTITLE /// value, the prefix "Properties of" is included with the specified title ('txt') /// parameter. // void TPropertySheet::SetTitle(LPCTSTR txt, uint32 style) { CHECK(GetHandle()); SendMessage(PSM_SETTITLE, TParam1(style), TParam2(txt)); }
bool TListViewCtrl::SetColumn(int index, const TLvColumn& column) { PRECONDITION(GetHandle()); return ToBool(SendMessage(LVM_SETCOLUMN, TParam1(index), TParam2(&column))); }
int TListViewCtrl::GetColumnWidth(int index) const { PRECONDITION(GetHandle()); return static_cast<int>(SendMessage(LVM_GETCOLUMNWIDTH, TParam1(index))); }