void CDropListBox::OnLButtonDown(UINT nFlags, CPoint point) { //Click in the client area? CRect rcClient; GetClientRect( rcClient ); if( !rcClient.PtInRect( point ) ) { ReleaseCapture(); GetParent()->SendMessage( WM_VRC_SETCAPTURE ); } //Click on the disabled item is disallowed int nPos = PointTest(point); if(nPos != LB_ERR) { PLIST_ITEM pItem = (PLIST_ITEM)GetItemDataPtr(nPos); if((DWORD)pItem != -1 && pItem != NULL && (pItem->state & ACBIS_DISABLED)) { return; } } //Get current selected item nPos = GetCurSel(); if(nPos != LB_ERR) { PLIST_ITEM pItem = (PLIST_ITEM)GetItemDataPtr(nPos); if((DWORD)pItem != -1 && pItem != NULL && (pItem->state & ACBIS_DISABLED)) { return; } //parent node can not be selected if(pItem->GetChildCount() > 0) { CRect rcItem; GetItemRect(nPos, &rcItem); if(PointTestState(point, rcItem)) { Expand(pItem, LBE_TOGGLE); } return; } //send current selection to combobox m_pComboParent->PostMessage( WM_SELECTED_ITEM, (WPARAM)nPos, 0 ); } //Destroy the dropdown list ReleaseCapture(); m_pComboParent->PostMessage( WM_DESTROY_DROPLIST ); // // Return so that the listbox can be destroyed // CListBox::OnLButtonDown(nFlags, point); }
int CCrossfaderBar::CMyComboBox::UpdateString(int nIndex, LPCTSTR lpszString) { PVOID pCurSel = GetItemDataPtr(GetCurSel()); PVOID pData = GetItemDataPtr(nIndex); if (DeleteString(nIndex) == CB_ERR) return(CB_ERR); int pos = AddString(lpszString); SetItemDataPtr(pos, pData); SetCurSel(FindItemDataPtr(pCurSel)); return(pos); }
void CBetPoolListBox::DeleteAllIndex() { for (int i=0; i< GetCount(); i++) { PoolBox_AppendData * pData = (PoolBox_AppendData *)GetItemDataPtr(i); if ( NULL != pData ) { delete pData->pSta0; pData->pSta0 = NULL ; delete pData->pBut2; pData->pBut2 = NULL ; delete pData->pSta1; pData->pSta1 = NULL ; delete pData->pSta3; pData->pSta3 = NULL; delete pData->pSta2; pData->pSta2 = NULL ; delete pData; pData = NULL; } } ResetContent(); m_mButton.clear(); }
void CBetPoolListBox::OnDestroy() { CListBox::OnDestroy(); // TODO: 在此处添加消息处理程序代码 int iCount = GetCount(); for (int i=0; i<iCount; i++) { PoolBox_AppendData * pData = (PoolBox_AppendData *)GetItemDataPtr(i); if ( NULL != pData ) { delete pData->pSta0; pData->pSta0 = NULL ; delete pData->pBut2; pData->pBut2 = NULL ; delete pData->pSta1; pData->pSta1 = NULL ; delete pData->pSta3; pData->pSta3 = NULL; delete pData->pSta2; pData->pSta2 = NULL ; delete pData; pData = NULL; } } }
void CBetPoolListBox::DeleteIndex(int iIndex) { PoolBox_AppendData * pData = (PoolBox_AppendData *)GetItemDataPtr(iIndex); if ( NULL != pData ) { delete pData->pSta0; pData->pSta0 = NULL ; delete pData->pBut2; pData->pBut2 = NULL ; delete pData->pSta1; pData->pSta1 = NULL ; delete pData->pSta3; pData->pSta3 = NULL; delete pData->pSta2; pData->pSta2 = NULL ; delete pData; pData = NULL; } DeleteString(iIndex); button_betmap::iterator iter = m_mButton.find(iIndex); if (iter != m_mButton.end()) { m_mButton.erase(iter); } }
void CXTPPropertyGridInplaceList::Apply() { int nIndex = GetCurSel(); if (nIndex != LB_ERR && m_pItem) { CXTPPropertyGridItemConstraint* pConstraint = (CXTPPropertyGridItemConstraint*)GetItemDataPtr(nIndex); if (pConstraint && !pConstraint->m_bEnabled) return; CXTPPropertyGridItem* pItem = m_pItem; m_pItem = NULL; CXTPPropertyGridItemConstraints* pList = pItem->GetConstraints(); pList->SetCurrent(nIndex); CString str; GetText(nIndex, str); if (pItem->OnAfterEdit(str) && str != pItem->GetValue()) pItem->OnValueChanged(str); } if (m_hWnd && ::GetFocus() == m_hWnd) { GetOwner()->SetFocus(); } }
//----------------------------------------------------------------------------- // Purpose: // Input : wParam - // lParam - // Output : LRESULT //----------------------------------------------------------------------------- LRESULT CTextureBox::OnSelectString(WPARAM wParam, LPARAM lParam) { LPCTSTR pszSelect = LPCTSTR(lParam); int iLen = strlen(pszSelect); int nCount = GetCount(); IEditorTexture *pTex; for(int i = wParam + 1; i < nCount; i++) { pTex = (IEditorTexture *)GetItemDataPtr(i); if (pTex != NULL) { char szName[MAX_PATH]; pTex->GetShortName(szName); if (!stricmp(szName, pszSelect)) { SetCurSel(i); return i; } } } return LB_ERR; }
void CXTPReportInplaceList::Apply() { if (!pControl) return; CXTPReportControl* pReportControl = pControl; int nIndex = GetCurSel(); if (nIndex != LB_ERR) { m_bApply = TRUE; CXTPReportRecordItemConstraint* pConstraint = (CXTPReportRecordItemConstraint*)GetItemDataPtr(nIndex); XTP_REPORTRECORDITEM_ARGS itemArgs = *((XTP_REPORTRECORDITEM_ARGS*)this); itemArgs.AddRef(); pItem->OnConstraintChanged(&itemArgs, pConstraint); pReportControl->RedrawControl(); pReportControl->SendMessageToParent(itemArgs.pRow, itemArgs.pItem, itemArgs.pColumn, XTP_NM_REPORT_VALUECHANGED, 0); itemArgs.Release(); } pReportControl->SetFocus(); }
int CDropListBox::SetCurSel(PLIST_ITEM pItem) { int nSelected = -1, i = 0, nCount = GetCount(); for(i = 0; i < nCount; i++) { PLIST_ITEM pListItem = (PLIST_ITEM)GetItemDataPtr( i ); if(pListItem == pItem) { nSelected = i; break; } } if((nSelected < 0) || (pItem->state & ACBIS_DISABLED)) { return nSelected; } int nr = CListBox::SetCurSel( nSelected ); if( nr != -1 ) { // // Set scrollbar int nTopIdx = GetTopIndex(); SCROLLINFO info; info.cbSize = sizeof(SCROLLINFO); if( m_pDropWnd->GetScrollBarPtr()->GetScrollInfo( &info, SIF_ALL|SIF_DISABLENOSCROLL ) ) { info.nPos = nTopIdx; m_pDropWnd->GetScrollBarPtr()->SetScrollInfo( &info ); } } return nr; }
void CDropListBox::OnLButtonDblClk(UINT nFlags, CPoint point) { //Click in the client area? CRect rcClient; GetClientRect( rcClient ); if( !rcClient.PtInRect( point ) ) { ReleaseCapture(); GetParent()->SendMessage( WM_VRC_SETCAPTURE ); } int nPos = PointTest(point); if(nPos != LB_ERR) { PLIST_ITEM pItem = (PLIST_ITEM)GetItemDataPtr(nPos); if((int)pItem != -1 && pItem != NULL) { if(pItem->state & ACBIS_DISABLED) { return; } if(pItem->GetChildCount() > 0) { Expand(pItem, LBE_TOGGLE); return; } } } CListBox::OnLButtonDblClk(nFlags, point); }
void CPropertyList::OnChangeEditBox() { CString newStr; m_editBox.GetWindowText(newStr); CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel); pItem->m_curValue = newStr; }
int CCrossfaderBar::CMyComboBox::FindItemDataPtr(PVOID pData) const { for (int i = 0; i < GetCount(); i++) { if (GetItemDataPtr(i) == pData) return(i); } return(-1); }
BOOL CDropListBox::DestroyWindow() { PLIST_ITEM pItem; for( int i = 0; i < GetCount(); i++ ) { pItem = (PLIST_ITEM)GetItemDataPtr( i ); delete pItem; } return CListBox::DestroyWindow(); }
void CPropertyList::OnSelchangeCmbBox() { CString selStr; if (m_cmbBox) { m_cmbBox.GetLBText(m_cmbBox.GetCurSel(),selStr); CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel); pItem->m_curValue = selStr; if (updateInspectors) { g_Inspectors->entityDlg.UpdateFromListBox(); } } }
void CLogListBox::Clear() { SetRedraw(false); int n = GetCount(); for(int i= 0; i<n; i++) { LogListBoxItem * item =(LogListBoxItem *)GetItemDataPtr(i); delete item; } ResetContent(); SetRedraw(true); }
void CXTPPropertyGridInplaceList::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC); CRect rc(lpDrawItemStruct->rcItem); CXTPPropertyGridItemConstraint* pConstraint = (CXTPPropertyGridItemConstraint*)GetItemDataPtr(lpDrawItemStruct->itemID); BOOL bSelected = (lpDrawItemStruct->itemState & ODS_SELECTED); if (m_pItem) { m_pItem->OnDrawItemConstraint(pDC, pConstraint, rc, bSelected); } }
void CPropertyList::ResetContent() { if (m_btnCtrl.GetSafeHwnd()) { m_btnCtrl.ShowWindow(SW_HIDE); } int c = this->GetCount(); for (int i = 0; i < c; i++) { CPropertyItem *pi = reinterpret_cast<CPropertyItem*>(GetItemDataPtr(i)); if (pi) { delete pi; } } CListBox::ResetContent(); }
DWORD CInPlaceList::GetItemData(int nIndex) const { if(CB_ERR == nIndex) return nIndex; DWORD dwItemData = CB_ERR; CItemData* pData = (CItemData*)GetItemDataPtr(nIndex); if(NULL != pData) dwItemData = pData->m_dwItemData; return dwItemData; }
int CInPlaceList::SetItemData(int nIndex, DWORD dwItemData) { if(CB_ERR == nIndex) return nIndex; CItemData* pData = (CItemData*)GetItemDataPtr(nIndex); if(NULL != pData) { pData->m_dwItemData = dwItemData; return 0; } return CB_ERR; }
void CBetPoolListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) { return ; if (GetCount() == 0) { return; } PoolBox_AppendData * pData =(PoolBox_AppendData *) GetItemDataPtr(lpDrawItemStruct->itemID); TRACE1("DrawItem:%d\r\n",lpDrawItemStruct->itemID); ASSERT(pData); InvalidateListBox(); UpdateWindow(); Invalidate(); }
void CPPageInternalFiltersListBox::UpdateCheckState() { for (int i = 0; i < FILTER_TYPE_NB; i++) { m_nbFiltersPerType[i] = m_nbChecked[i] = 0; } for (int i = 0; i < GetCount(); i++) { filter_t* filter = (filter_t*) GetItemDataPtr(i); m_nbFiltersPerType[filter->type]++; if (GetCheck(i)) { m_nbChecked[filter->type]++; } } }
void CDropListBox::OnMouseMove(UINT nFlags, CPoint point) { // // Is mouse within listbox CRect rcClient; GetClientRect( rcClient ); if( !rcClient.PtInRect( point ) ) { ReleaseCapture(); GetParent()->SendMessage( WM_VRC_SETCAPTURE ); } // // Set selection item under mouse int nPos = point.y / GetItemHeight(0) + GetTopIndex(); PLIST_ITEM pItem = (PLIST_ITEM)GetItemDataPtr(nPos); if( (DWORD)pItem != -1 ) { if( GetCurSel() != nPos && !pItem->bDisabled ) { SetCurSel( nPos ); } } // // Check if we have autoscrolled if( m_nLastTopIdx != GetTopIndex() ) { int nDiff = m_nLastTopIdx - GetTopIndex(); m_nLastTopIdx = GetTopIndex(); SCROLLINFO info; info.cbSize = sizeof(SCROLLINFO); if( m_pScroll->GetScrollInfo( &info, SIF_ALL|SIF_DISABLENOSCROLL ) ) { info.nPos = m_nLastTopIdx; m_pScroll->SetScrollInfo( &info ); } } // OutputDebugString( "DropListBox MouseMove\n" ); CListBox::OnMouseMove(nFlags, point); }
int CDropListBox::GetItemIndex(PLIST_ITEM pItem) { PLIST_ITEM ptr; for(int i = GetCount() - 1; i >= 0; i--) { ptr = (PLIST_ITEM)GetItemDataPtr(i); ASSERT(ptr != NULL && ((int)ptr != -1)); if(ptr != NULL && ((int)ptr != -1)) { if(ptr == pItem) { return i; } } } return -1; }
BOOL CComboBoxEx2::SelectItemDataStringA(LPCSTR pszText) { CComboBox* pctrlCB = GetComboBoxCtrl(); if (pctrlCB != NULL) { int iCount = pctrlCB->GetCount(); for (int i = 0; i < iCount; i++) { void* pvItemData = GetItemDataPtr(i); if (pvItemData && strcmp((LPCSTR)pvItemData, pszText) == 0) { SetCurSel(i); GetParent()->SendMessage(WM_COMMAND, MAKELONG((WORD)GetWindowLong(m_hWnd, GWL_ID), CBN_SELCHANGE), (LPARAM)m_hWnd); return TRUE; } } } return FALSE; }
LRESULT CInPlaceList::OnDeleteString(WPARAM wParam, LPARAM lParam) { POSITION pos = (POSITION)lParam; if(NULL == pos) { CItemData* pData = (CItemData*)GetItemDataPtr((int)wParam); if(NULL != pData) { POSITION pos = m_PtrList.Find(pData); if(NULL != pos) { delete pData; m_PtrList.RemoveAt(pos); } } } return Default(); }
BOOL CPPageInternalFiltersListBox::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult) { TOOLTIPTEXT* pTTT = (TOOLTIPTEXT*)pNMHDR; filter_t* f = (filter_t*)GetItemDataPtr(static_cast<int>(pNMHDR->idFrom)); if (f->nHintID == 0) { return FALSE; } ::SendMessage(pNMHDR->hwndFrom, TTM_SETMAXTIPWIDTH, 0, 1000); static CString strTipText; // static string strTipText.LoadString(f->nHintID); pTTT->lpszText = strTipText.GetBuffer(); *pResult = 0; return TRUE; // message was handled }
void CDropListBox::OnMouseMove(UINT nFlags, CPoint point) { // // Is mouse within listbox CRect rcClient; GetClientRect( rcClient ); if( !rcClient.PtInRect( point ) ) { ReleaseCapture(); GetParent()->SendMessage( WM_VRC_SETCAPTURE ); } // // Set selection item under mouse int nPos = PointTest(point); PLIST_ITEM pItem = (PLIST_ITEM)GetItemDataPtr(nPos); if( nPos != LB_ERR && (DWORD)pItem != -1 && pItem != NULL) { if( GetCurSel() != nPos && !(pItem->state & ACBIS_DISABLED) ) { SetCurSel( nPos ); } } // // Check if we have auto scrolled if( m_nLastTopIdx != GetTopIndex() ) { int nDiff = m_nLastTopIdx - GetTopIndex(); m_nLastTopIdx = GetTopIndex(); SCROLLINFO info; info.cbSize = sizeof(SCROLLINFO); if( m_pDropWnd->GetScrollBarPtr()->GetScrollInfo( &info, SIF_ALL|SIF_DISABLENOSCROLL ) ) { info.nPos = m_nLastTopIdx; m_pDropWnd->GetScrollBarPtr()->SetScrollInfo( &info ); } } CListBox::OnMouseMove(nFlags, point); }
// Delete item from dropdown list int CInPlaceList::DeleteItem(CItemData* pData) { int nIndex = CB_ERR; if(NULL == pData || FALSE == pData->m_bState) return nIndex; pData->m_bState = FALSE; const int nCount = GetCount(); for(int i = 0; i < nCount; ++i) { if(pData == (CItemData*)GetItemDataPtr(i)) { nIndex = (int)SendMessage(CB_DELETESTRING, (WPARAM)i, (LPARAM)m_PtrList.Find(pData)); break; } } return nIndex; }
void CPropertyList::OnButton() { CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(m_curSel); //display the appropriate common dialog depending on what type //of chooser is associated with the property if (pItem->m_nItemType == PIT_COLOR) { idVec3 color; sscanf(pItem->m_curValue, "%f %f %f", &color.x, &color.y, &color.z); COLORREF cr = (int)(color.x * 255) + (((int)(color.y * 255))<<8) + (((int)(color.z * 255))<<16); CDialogColorPicker dlg(cr); dlg.UpdateParent = UpdateRadiantColor; if (dlg.DoModal() == IDOK) { color.x = (dlg.GetColor() & 255)/255.0; color.y = ((dlg.GetColor() >> 8)&255)/255.0; color.z = ((dlg.GetColor() >> 16)&255)/255.0; pItem->m_curValue = color.ToString(4); }
void CPropertyList::DrawItem(LPDRAWITEMSTRUCT lpDIS) { CDC dc; dc.Attach(lpDIS->hDC); CRect rectFull = lpDIS->rcItem; CRect rect = rectFull; if (m_nDivider==0) { m_nDivider = rect.Width() / 2; } rect.left = m_nDivider; CRect rect2 = rectFull; rect2.right = rect.left - 1; UINT nIndex = lpDIS->itemID; if (nIndex != (UINT) -1) { //get the CPropertyItem for the current row CPropertyItem* pItem = (CPropertyItem*) GetItemDataPtr(nIndex); //draw two rectangles, one for each row column if (pItem->m_nItemType == PIT_VAR) { dc.FillSolidRect(rect2,RGB(220,220,220)); } else { dc.FillSolidRect(rect2,RGB(192,192,192)); } dc.DrawEdge(rect2,EDGE_SUNKEN,BF_BOTTOMRIGHT); dc.DrawEdge(rect,EDGE_SUNKEN,BF_BOTTOM); if (lpDIS->itemState == ODS_SELECTED) { dc.DrawFocusRect(rect2); } //write the property name in the first rectangle dc.SetBkMode(TRANSPARENT); dc.DrawText(pItem->m_propName,CRect(rect2.left+3,rect2.top+3, rect2.right-3,rect2.bottom+3), DT_LEFT | DT_SINGLELINE); //write the initial property value in the second rectangle dc.DrawText(pItem->m_curValue,CRect(rect.left+3,rect.top+3, rect.right+3,rect.bottom+3), DT_LEFT | (pItem->m_nItemType == PIT_VAR) ? DT_WORDBREAK : DT_SINGLELINE); } dc.Detach(); }