int TListViewCtrl::InsertItem(const TLvItem& item, int index) { PRECONDITION(GetHandle()); if (index != -1) { LVITEM temp = item; // Make s shallow copy, just to pass to LVM_INSERTITEM temp.iItem = index; return static_cast<int>(SendMessage(LVM_INSERTITEM, 0, TParam2(&temp))); } else return static_cast<int>(SendMessage(LVM_INSERTITEM, 0, TParam2(&item))); }
// /// If NotifyParent is true, SelectionChanged notifies the parent window of the /// group box that one of its selections has changed by sending it a child-ID-based /// message. This member function can be redefined to allow the group box to handle /// selection changes in its group of controls. // void TGroupBox::SelectionChanged(int controlId) { if (NotifyParent) GetParentO()->PostMessage(WM_COMMAND, MkParam1(Attr.Id, controlId), TParam2(GetHandle())); }
// /// Post a OWL-defined message regarding an event [identified by the 'id' /// parameter] related to the specified document ('doc'). // /// If the current document changes, posts a WM_OWLDOCUMENT message to indicate a /// change in the status of the document. // void TDocManager::PostEvent(int id, TDocument& doc) { TWindow* win = GetApplication()->GetMainWindow(); if (win && win->GetHandle()) win->SendMessage(WM_OWLDOCUMENT, id, TParam2(&doc)); }
bool TListViewCtrl::GetColumn(int index, LVCOLUMN* column) { PRECONDITION(column); PRECONDITION(GetHandle()); return ToBool(SendMessage(LVM_GETCOLUMN, TParam1(index), TParam2(column))); }
// /// Activates the specified page 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(TPropertyPage& pg) { PRECONDITION(GetHandle()); PRECONDITION(HPROPSHEETPAGE(pg)); return SendMessage(PSM_SETCURSEL, 0, TParam2(HPROPSHEETPAGE(pg))) != 0; }
// /// Post a OWL-defined message regarding an event [identified by the 'id' /// parameter] related to the specified view ('view'). // /// If the current view changes, posts a WM_OWLVIEW message to indicate a change in /// the status of the view. // void TDocManager::PostEvent(int id, TView& view) { TWindow* win = GetApplication()->GetMainWindow(); if (win && win->GetHandle()) win->SendMessage(WM_OWLVIEW, id, TParam2(&view)); }
bool TListViewCtrl::GetItemRect(int index, TRect& r, TItemRectType type) { PRECONDITION(GetHandle()); r.left = type; return ToBool(SendMessage(LVM_GETITEMRECT, TParam1(index), TParam2(&r))); }
uint TListViewCtrl::GetNumOfWorkAreas() const { PRECONDITION(GetHandle()); uint retval; SendMessage(LVM_GETNUMBEROFWORKAREAS, 0, TParam2(&retval)); return retval; }
// /// This method retrieves the size and position of a header control /// within a given rectangle. It determines the appropriate dimensions /// of a new header control that is to occupy the given rectangle. /// Upon entry the 'boundingRect' parameter specifies the rectangle /// within which the columnHeader must lie. The control then updates /// the WINDOWPOS structure to contain the desired/appropriate dimensions /// for the control to occupy within the specified rectangle. // bool TColumnHeader::Layout(TRect& boundingRect, WINDOWPOS& wp) { HD_LAYOUT hdl; hdl.prc = &boundingRect; hdl.pwpos = ℘ return SendMessage(HDM_LAYOUT, 0, TParam2(&hdl)) != 0; }
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))); }
bool TListViewCtrl::SetItemState(int index, uint state, uint mask) { LVITEM item; item.state = state; item.stateMask = mask; return ToBool(SendMessage(LVM_SETITEMSTATE, index, TParam2(&item))); }
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))); }
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(); }
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))); }
bool TListViewCtrl::SetItem(const TLvItem& item, int index, int subitemIndex) { PRECONDITION(GetHandle()); if (index != -1 || subitemIndex != -1) { LVITEM temp = item; // Make s shallow copy, just to pass to LVM_INSERTITEM if (index != -1) temp.iItem = index; if (subitemIndex != -1) temp.iSubItem = subitemIndex; return ToBool(SendMessage(LVM_SETITEM, 0, TParam2(&temp))); } else return ToBool(SendMessage(LVM_SETITEM, 0, TParam2(&item))); }
bool TListViewCtrl::GetItem(TLvItem& item, int index, int subitemIndex) const { PRECONDITION(GetHandle()); if (index != -1) item.iItem = index; if (subitemIndex != -1) item.iSubItem = subitemIndex; return ToBool(SendMessage(LVM_GETITEM, 0, TParam2(&item))); }
// /// Removes the specified page from the property sheet // void TPropertySheet::RemovePage(TPropertyPage& pg) { PRECONDITION(HPROPSHEETPAGE(pg)); CHECK(GetHandle()); SendMessage(PSM_REMOVEPAGE, 0, TParam2(HPROPSHEETPAGE(pg))); // // Should we actually invoke 'DestroyPropertySheetPage' for // Pages which are added then removed from the PropertySheet?? }
void TDynamicTextGadget::CommandEnable() { PRECONDITION(GetGadgetWindow()); // Must send, not post here, since a ptr to a temp is passed // // This might be called during idle processing before the // HWND has created. Therefore, confirm handle exists. // if (GetGadgetWindow()->GetHandle()){ TDynamicTextGadgetEnabler ge(*GetGadgetWindow(), this); GetGadgetWindow()->HandleMessage(WM_COMMAND_ENABLE,0,TParam2(&ge)); } }
// /// Toggle the "checked" state when the mouse is clicked in the checkbox. // void TCheckList::EvLButtonDown(uint modKeys, const TPoint& point) { TListBox::EvLButtonDown(modKeys, point); TCheckListItem* item = GetItem(GetCaretIndex()); if(item && item->IsEnabled() && point.x < CheckList_BoxWidth){ item->Toggle(); Update(); // Inform parent of change with BN_CLICKED message if(GetParentO()) GetParentO()->HandleMessage(WM_COMMAND, MkParam2(Attr.Id, BN_CLICKED), TParam2(GetHandle())); } }
// /// Adds a new page to the end of the PropertySheet. /// \note The 'pg' must have been created via a call to /// 'TPropertyPage::CreatePropertyPage' before invoking the 'AddPage' method. /// \note The property sheet is not resized to fit the new page. The new page should /// be no larger than the largest page already in the property sheet. // void TPropertySheet::AddPage(TPropertyPage& pg) { // Update pointer to parent object // if (pg.GetParentO() != this) pg.SetParent(this); // Have page create itself it necessary // pg.CreatePropertyPage(); CHECK(HPROPSHEETPAGE(pg)); // Inform sheet about new page // CHECK(HWND(*this)); SendMessage(PSM_ADDPAGE, 0, TParam2(HPROPSHEETPAGE(pg))); }
// /// 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; }
// /// Tests a point to determine which header item, if any, is at the /// specified point. /// Returns the index of the item at the specified position, if any, or – 1 /// otherwise. ht contains the position to test and receives information about the /// results of the test. /// \note The coordinates are specified via the 'pt' member of the /// THeaderHitTestInfo parameter. // int TColumnHeader::HitTest(THeaderHitTestInfo& ht) { return (int)SendMessage(HDM_HITTEST, 0, TParam2(&ht)); }
// /// Updates the attribute(s) a the item at the specified 'index'. The /// 'itemInfo' structure contains the new attributes of the item. // bool TColumnHeader::SetItem(const THdrItem& itemInfo, int index) { return SendMessage(HDM_SETITEM, index, TParam2(&itemInfo)) != 0; }
// /// Retrieves information about the item at the specified index by filling /// out the 'itemInfo' structure passed in. The 'msk' contains one or more /// HDI_xxxx constants and can be used to specify which information should /// be copied. // bool TColumnHeader::GetItem(THdrItem& itemInfo, int index, uint msk) { itemInfo.mask |= msk; return SendMessage(HDM_GETITEM, index, TParam2(&itemInfo)) != 0; }
// /// Inserts a new item after the specified location, 'index', in the column Header /// control. The new item is inserted at the end of the header control if index is /// greater than or equal to the number of items in the control. If index is zero, /// the new item is inserted at the beginning of the header control. The following /// illustrates a typical use of the 'Insert' method: /// \code /// THdrItem hdrItem(GetModule().LoadBitmap(IDB_COMPANYLOGO)); /// hdr.Insert(hdrItem, 0); /// \endcode /// If the operation succeeds, the return value is the index of the new item. If the /// operation fails, the return value is - 1. // int TColumnHeader::Insert(const THdrItem& item, int index) { return SendMessage(HDM_INSERTITEM, index, TParam2(&item)) != 0; }
// // Enables the 'Back', 'Next' or 'Finish' button in a wizard // property sheet. The 'flags' parameter can be a combination of // the following values: // // PSWIZB_BACK Back button // PSWIZB_NEXT Next button // PSWIZB_FINISH Finish button // void TPropertySheet::SetWizButtons(uint32 flags) { CHECK(GetHandle()); SendMessage(PSM_SETWIZBUTTONS, 0, TParam2(flags)); }
// /// 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)); }
// /// Sets the text for the 'Finish' button in a Wizard property sheet. /// \note The button is enabled while the 'Next' and 'Back' buttons are hidden. // void TPropertySheet::SetFinishText(LPCTSTR txt) { CHECK(GetHandle()); SendMessage(PSM_SETFINISHTEXT, 0, TParam2(txt)); }
// /// Activates the page with the specified resource identifier. 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(TResId pgRes) { CHECK(GetHandle()); return SendMessage(PSM_SETCURSELID, 0, TParam2(static_cast<LPCTSTR>(pgRes))); }
// /// Passes a message to a property sheet dialog box and indicates whether the dialog /// processed the message. Returns true if the message was processed or false /// otherwise. // bool TPropertySheet::IsDialogMessage(MSG& msg) { CHECK(GetHandle()); return SendMessage(PSM_ISDIALOGMESSAGE, 0, TParam2(&msg)) != 0; }