BOOL CIETabBar::SetNextSel() { int nCount = GetItemCount(); int nCurSel = GetCurSel(); if (nCount >= 2) { if ( nCurSel == nCount-1 )//如果选择的是最后一个 { SetCurSel(0); } else { SetCurSel(nCurSel + 1); } } return TRUE; }
BOOL CIETabBar::SetPreSel() { int nCount = GetItemCount(); int nCurSel = GetCurSel(); if (nCount >= 2) { if ( nCurSel == 0 )//如果选择的是第一个 { SetCurSel(nCount-1); } else { SetCurSel(nCurSel - 1); } } return TRUE; }
void CTabCtrlSSL::OnSelChanging (NMHDR* pNMHDR, LRESULT* pResult) { // Notify derived classes that the selection is changing. int nIndex = GetCurSel (); if (nIndex == -1) return; OnDeactivatePage (nIndex, m_nPageIDs[nIndex]); // Save the input focus and hide the old page. TabDelete tabDelete = m_tabs[nIndex]; CTabPageSSL* pDialog = tabDelete.pTabPage; if (pDialog != NULL) { m_hFocusWnd[nIndex] = ::GetFocus (); pDialog->ShowWindow (SW_HIDE); } *pResult = 0; }
CString COdbcValueComboBox::GetSelectedValueKey() const { ASSERT(GetSafeHwnd()); int nSel = GetCurSel(); if (nSel == -1) return _T(""); // else int nKey = GetItemData(nSel); ASSERT(nKey >= 0 && nKey < m_aKeys.GetSize()); if (nKey < 0 || nKey >= m_aKeys.GetSize()) return _T(""); return m_aKeys[nKey]; }
FONTITEM_PPG* CFontComboBox::GetFontItem(int sel) { if (sel == -1) sel = GetCurSel(); if (sel == -1) { CString str; GetWindowText( str ); sel = FindString( -1, str ); if (sel == CB_ERR) sel = 0; } ASSERT( GetItemData(sel) ); return (FONTITEM_PPG*) GetItemData(sel); }
void CJobControlDlg::UpdateUI(int JobIdx) { int jobs = GetJobCount(); if (JobIdx < 0) JobIdx = GetCurSel(); // update job positioning buttons m_MoveUpBtn.EnableWindow(JobIdx > 0); m_MoveDownBtn.EnableWindow(JobIdx >= 0 && JobIdx < jobs - 1); // update job status buttons; don't let user change status of running job bool StatChgOK = JobIdx >= 0 && !IsRunning(JobIdx); m_PostponeBtn.EnableWindow(StatChgOK); m_DeleteBtn.EnableWindow(StatChgOK); // update job control buttons bool BatchMode = m_Main->GetBatchMode(); // true if batch jobs are running m_StartBtn.EnableWindow(jobs && !BatchMode && FindWaiting() >= 0); m_AbortBtn.EnableWindow(jobs && BatchMode); m_SkipBtn.EnableWindow(JobIdx >= 0 && BatchMode); }
int CDomainListBox::SelectItem( int nSel, BOOL bSelected ) { if( GetStyle( ) & LBS_MULTIPLESEL ) { return SetSel( nSel, bSelected ); } else { if( bSelected ) return SetCurSel( nSel ); else { if( GetCurSel() == nSel || -1 == nSel ) return SetCurSel( -1 ); } return -1; } }
void CXTabCtrl::OnSelchange(NMHDR* pNMHDR, LRESULT* pResult) { // TODO: Add your control notification handler code here int iNewTab = GetCurSel(); if (!IsTabEnabled(iNewTab)) { SetCurSel(m_iSelectedTab); } else { TCITEM item; CWnd* pWnd; item.mask = TCIF_PARAM; //** hide the current tab --------- GetItem(m_iSelectedTab, &item); pWnd = reinterpret_cast<CWnd*> (item.lParam); ASSERT_VALID(pWnd); pWnd->ShowWindow(SW_HIDE); //** show the selected tab -------- GetItem(iNewTab, &item); pWnd = reinterpret_cast<CWnd*> (item.lParam); ASSERT_VALID(pWnd); // 改变属性页的大小位置 CRect rc; GetClientRect(rc); rc.top += 20; rc.bottom -= 3; rc.left += 2; rc.right -= 3; pWnd->MoveWindow(&rc); pWnd->ShowWindow(SW_SHOW); // 发送到父窗口Tab项改变 GetParent()->SendMessage(WM_TAB_SEL_CHANGED,0,iNewTab); } *pResult = 0; }
void CListImpl::OnMouseMove(UINT wParam, WTL::CPoint pt) { if (m_last_pt == pt) // not moving return; m_last_pt = pt; int index = GetCurSel(); WTL::CRect mainrc = GetHittestDivideRect(2 * index); WTL::CRect seconrc = GetHittestDivideRect(2 * index + 1); if (PtInRect(&mainrc, pt)) { if (m_highlightstat == 1) return; SetClassLong(m_hWnd, GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_HAND)); ::SetCursor(LoadCursor(NULL, IDC_HAND)); m_highlightstat = 1; Invalidate(FALSE); return; } if (PtInRect(&seconrc, pt)) { if (m_highlightstat == 2) return; SetClassLong(m_hWnd, GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_HAND)); SetCursor(LoadCursor(NULL, IDC_HAND)); m_highlightstat = 2; Invalidate(FALSE); return; } int bhightlightorg = m_highlightstat; m_highlightstat = 0; SetClassLong(m_hWnd, GCL_HCURSOR, (LONG)LoadCursor(NULL, IDC_ARROW)); SetCursor(LoadCursor(NULL, IDC_ARROW)); if (bhightlightorg != m_highlightstat) Invalidate(FALSE); }
BOOL CTDLFindTaskExpressionListCtrl::DeleteSelectedRule() { int nRow = GetCurSel(); if (nRow != -1 && CanDeleteSelectedCell()) { DeleteItem(nRow); m_aSearchParams.RemoveAt(nRow); ValidateListData(); SetCurSel(nRow); EnsureVisible(nRow, FALSE); return TRUE; } return FALSE; }
// Gets the selected class from the listbox CString CClassList::GetSelectedClass() { // Get the current selection int nSelString=GetCurSel(); if (nSelString != LB_ERR) { // Get the string for the current selection CString sString; GetText(nSelString, sString); // Return the string return sString; } else { // Return an empty string return ""; } }
void CUnitComboBox::Tran(CWnd *pWnd) { CString strText; CString strUnit; double dOut = 0; double dOut1 = 0; pWnd->GetWindowText(strText); GetWindowText(strUnit); double dIn = _tcstod(strText, '\0'); TransformToStd(dOut,strUnit,dIn); int nIndex = GetCurSel(); if(CB_ERR != nIndex) { GetLBText(nIndex,strUnit); } TransformFromStd(dOut1,strUnit,dOut); pWnd->SetWindowText(GetValue(dOut1)); }
void CListBoxEx::CreateComboControl() { if(IsWindow(ComboCtrl.m_hWnd)) return; // create edit control int iItem = GetCurSel(); if(iItem == LB_ERR) return; LBEXTITEMSTRUCT& lbis = Items[iItem]; if(lbis.iEditType != lbeChoices) return; CRect r; GetItemRect(iItem, r); r.left += iCaptionWidthPixels; r.bottom += 80; // create combo ctrl ComboCtrl.Create(WS_CHILD | WS_VISIBLE | WS_VSCROLL | CBS_DROPDOWNLIST | WS_TABSTOP, r, this, IDC_EDITPARAMETER); // set font HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); if (hFont == NULL) hFont = (HFONT)GetStockObject(ANSI_VAR_FONT); ComboCtrl.SendMessage(WM_SETFONT, (WPARAM)hFont); // add strings to combo ctrl CStringArray * pChoices = lbis.pChoices; Assert(pChoices); for(int i = 0; i < pChoices->GetSize(); i++) ComboCtrl.AddString(pChoices->GetAt(i)); // set current selection in combo ctrl ComboCtrl.SetCurSel(lbis.iDataValue); ComboCtrl.SetForegroundWindow(); bControlActive = TRUE; iControlItem = iItem; }
TZNotePage * TZNoteBook::GetActivePage( ) { zSHORT nCurrIdx = GetCurSel( ); #ifdef DEBUG_ALL TraceLineI( "TZNoteBook::GetActivePage: ", nCurrIdx ); #endif TZNotePage *pCurrNotePage = m_pZNotePage; while ( pCurrNotePage ) { if ( pCurrNotePage->m_nTabIdx == nCurrIdx ) break; pCurrNotePage = pCurrNotePage->m_pNext; } return( pCurrNotePage ); }
bool CShaderListBox::DeleteCurrentShader() { bool ret = false; int sel = GetCurSel(); if (sel != LB_ERR) { if (DeleteShader(sel) != LB_ERR) { ret = true; if (GetCount() == sel) { sel--; } if (sel >= 0) { VERIFY(SetCurSel(sel) != LB_ERR); } } else { ASSERT(FALSE); } } return ret; }
/****************************************************************************** Function Name : OnRButtonDown Description : The framework calls this member function when the user right clicks on the list box Input(s) : nFlags - point - Output : - Functionality : Shows a popup menu to clear the contents of the listbox Member of : CNotificListbox Author(s) : Ravikumar Patil Date Created : 27-03-2003 ******************************************************************************/ void CNotificListbox::OnRButtonDown(UINT nFlags, CPoint point) { if (GetCount() > 0) { CMenu* pomContextMenu = new CMenu; if (pomContextMenu != NULL) { // Load the Menu from the resource pomContextMenu->DestroyMenu(); pomContextMenu->LoadMenu(IDM_OPERATION_LIST); CMenu* pomSubMenu = pomContextMenu->GetSubMenu(0); if (pomSubMenu != NULL) { CPoint omSrcPt = point; ClientToScreen(&omSrcPt); UINT unEnable; /* If no item is selected, make "Clear" and "Delete" menu items disabled */ if (GetCurSel() == -1) { unEnable = MF_BYCOMMAND | MF_DISABLED | MF_GRAYED; } else { unEnable = MF_BYCOMMAND | MF_ENABLED; } pomSubMenu->EnableMenuItem(IDM_OPRTN_CLEAR, unEnable); pomSubMenu->EnableMenuItem(IDM_OPRTN_DELETE, unEnable); pomSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, omSrcPt.x, omSrcPt.y, this, NULL); } delete pomContextMenu; pomContextMenu = NULL; } } CListBox::OnRButtonDown(nFlags, point); }
void CPhonesListBox::OnEditItem() { CEditDialog dlg; CString strItem; int nIndex = GetCurSel (); GetText (nIndex, strItem); int nPos = strItem.Find (_T ('\t')); dlg.m_strName = strItem.Left (nPos); dlg.m_strPhone = strItem.Right (strItem.GetLength () - nPos - 1); if (dlg.DoModal () == IDOK) { strItem = dlg.m_strName + _T ("\t") + dlg.m_strPhone; DeleteString (nIndex); AddString (strItem); } SetFocus (); }
void CSkillEditListBox::OnLButtonDblClk(UINT nFlags, CPoint point) { //get the selected item's skill pointer int iItem = GetCurSel(); CInvestigatorSkill* pInvestigatorSkill = (CInvestigatorSkill*)GetItemData(iItem); //determine how to edit, depending on the item selected if( pInvestigatorSkill->m_pSkill->m_SkillType == ANYSKILL ) { CChooseSkillDlg ChooseSkillDlg; ChooseSkillDlg.m_strCustomPrompt = "Please select a skill as a personal specialty"; ChooseSkillDlg.m_pInvestigator = m_pInvestigator; ChooseSkillDlg.SetAsOccupational(); if( ChooseSkillDlg.DoModal() == IDOK ) { //remove the ANYSKILL m_pInvestigator->RemoveSkill( pInvestigatorSkill ); //reset the list Initialise(); } } else { if( pInvestigatorSkill->m_pSkill->m_SkillType == SUBSKILL ) { //determine x position of double click CRect rcListBox; GetClientRect( &rcListBox ); //prepare the selection rectangle if( point.x < rcListBox.right - 40 || ((CSubSkill*)pInvestigatorSkill->m_pSkill)->m_strName.GetLength() == 0 ) BeginSpecialEditing(); else BeginPercentageEditing(); } else BeginPercentageEditing(); } //don't call base class }
void CVideoSourceListBox::OnRButtonUp(UINT nFlags, CPoint point) { // TODO: Code für die Behandlungsroutine für Nachrichten hier einfügen und/oder Standard aufrufen CMenu* cmPopupMenu; int iIndex; CString cStr; bool bShowMenu=false; cmPopupMenu=new CMenu; cmPopupMenu->CreatePopupMenu(); if (GetCount()) { iIndex=GetCurSel(); if (iIndex!=LB_ERR) { if (bShowMenu) cmPopupMenu->AppendMenu(MF_SEPARATOR,0); if (bShowMenu) cmPopupMenu->AppendMenu(MF_SEPARATOR,0); cStr=LoadString(IDS_VSLB_INFO); cmPopupMenu->AppendMenu(MF_STRING,IDM_VIDEOINFORMATION,cStr); bShowMenu=true; if (bShowMenu) cmPopupMenu->AppendMenu(MF_SEPARATOR,0); CUTF8 utf8Text(LoadString(STR_MAIN_A_EXTRBIN), CHARACTER_ENCODING_UTF8); cmPopupMenu->AppendMenu(MF_STRING, IDM_EXTRACT_BINARY, //LoadString(STR_MAIN_A_EXTRBIN)); utf8Text.TStr()); } } if (bShowMenu) { ClientToScreen(&point); cmPopupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON,point.x,point.y,this); } delete cmPopupMenu; CEnhancedListBox::OnRButtonUp(nFlags, point); CEnhancedListBox::OnRButtonUp(nFlags, point); }
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); }
void CListBoxEx::CreateEditControl() { if(IsWindow(EditCtrl.m_hWnd)) return; // create edit control int iItem = GetCurSel(); if(iItem == LB_ERR) return; LBEXTITEMSTRUCT& lbis = Items[iItem]; if(lbis.iEditType != lbeString && lbis.iEditType != lbeInteger && lbis.iEditType != lbeTexture) return; CRect r; GetItemRect(iItem, r); r.InflateRect(-1, -1); r.left += iCaptionWidthPixels; // create edit ctrl EditCtrl.Create(ES_LEFT | ES_LOWERCASE | WS_VISIBLE | WS_TABSTOP, r, this, IDC_EDITPARAMETER); // set font HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT); if (hFont == NULL) hFont = (HFONT)GetStockObject(ANSI_VAR_FONT); EditCtrl.SendMessage(WM_SETFONT, (WPARAM)hFont); // set current text in edit ctrl char szBuf[128]; GetItemText(iItem, szBuf); EditCtrl.SetWindowText(szBuf); EditCtrl.SetForegroundWindow(); EditCtrl.SetSel(0, -1); bControlActive = TRUE; iControlItem = iItem; }
void CPropTreeItemCombo::DrawAttribute( CDC *pDC, const RECT &rc ) { ASSERT( m_pProp != NULL ); // verify the window has been created if( !IsWindow( m_hWnd ) ) { TRACE0( "CPropTreeItemCombo::DrawAttribute() - The window has not been created\n" ); return; } pDC->SelectObject( IsReadOnly() ? m_pProp->GetNormalFont() : m_pProp->GetBoldFont() ); pDC->SetTextColor( RGB( 0, 0, 0 ) ); pDC->SetBkMode( TRANSPARENT ); CRect r = rc; CString s; LONG idx; if( ( idx = GetCurSel() ) != CB_ERR ) { GetLBText( idx, s ); } else { s = _T( "" ); } pDC->DrawText( s, r, DT_SINGLELINE | DT_VCENTER ); }
// -2 - out of control, -1 - out of tab-labels, 0+ - tab index 0-based int CTabBarClass::ActivateTabByPoint(LPPOINT pptCur, bool bScreen /*= true*/, bool bOverTabHitTest /*= true*/) { int iHoverTab = GetTabFromPoint(NULL); if (iHoverTab < 0) return iHoverTab; if (iHoverTab == GetCurSel()) return iHoverTab; if (!CanActivateTab(iHoverTab)) { iHoverTab = -2; } else { if (!mp_Rebar->FarSendChangeTab(iHoverTab)) iHoverTab = -2; } return iHoverTab; }
//***************************************************************************** // // Function Name: RGridCtrlBase::GetItemState( int nIndex ) // // Description: Determines the state of the item speicifed by nIndex // // Returns: The selection/focus state of the item specified by nIndex // // Exceptions: None // //***************************************************************************** UINT RGridCtrlBase::GetItemState( int nIndex ) const { UINT uiItemState = 0 ; int nCurCell = GetCurSel() ; if ((CWnd *) this == GetFocus()) { if ((LB_ERR == nCurCell && 0 == nIndex) || nIndex == nCurCell) { uiItemState |= ODS_FOCUS ; } } if (nIndex == nCurCell) { uiItemState |= ODS_SELECTED ; } return uiItemState ; }
// AcceptSelection ---------------------------------------------------------- void CCodeListCtrl::AcceptSelection() { // If nothing is selected yet, we'll select the first item in the list // and we won't close the list until next time. // if( -1 == GetCurSel() ) SelectItem( 0 ); else if( !m_bAcceptSel ) { m_bAcceptSel = true; // Notify the parent that something has been selected, and destroy the // list control if the parent has no objections. // if( !NotifyParent( CMN_CODELISTSELMADE ) ) CDispatchWnd::DestroyWindow(); else m_bAcceptSel = false; } }
void CDropDown::OnSelendok() { // theApp.NotificationMessage(m_strID); char str[MAX_PATH]; GetWindowText(str,MAX_PATH); CSeriousSkaStudioDoc *pDoc = theApp.GetDocument(); // set ID of selected item if(m_bSetID) { theApp.m_dlgBarTreeView.ChangeTextureOnSelectedSurfaces(m_strID,str); pDoc->MarkAsChanged(); return; } else { INDEX iIndex = GetCurSel(); pDoc->MarkAsChanged(); theApp.m_dlgBarTreeView.ChangeTextureCoordsOnSelectedSurfaces(m_strID,iIndex); } }
void CPreferencesToolPage::OnEndlabeleditToollist(NMHDR* pNMHDR, LRESULT* pResult) { LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR; if (pDispInfo->item.pszText) { int nSel = GetCurSel(); if (nSel >= 0) { m_lcTools.SetItemText(nSel, 0, pDispInfo->item.pszText); GetDlgItem(IDC_TOOLPATH)->SetFocus(); } } *pResult = 0; CPreferencesPageBase::OnControlChange(); }
BOOL CTDLFindTaskExpressionListCtrl::PreTranslateMessage(MSG* pMsg) { if (pMsg->message == WM_KEYDOWN) { int nSel = GetCurSel(); if (nSel != -1) { // if the focus is on the attrib list and the user hits the spacebar // then toggle the enabled state switch (pMsg->wParam) { case VK_F2: EditSelectedCell(); break; case VK_DELETE: DeleteSelectedRule(); break; case VK_UP: if (Misc::ModKeysArePressed(MKS_CTRL)) { MoveSelectedRuleUp(); return TRUE; // eat it } break; case VK_DOWN: if (Misc::ModKeysArePressed(MKS_CTRL)) { MoveSelectedRuleDown(); return TRUE; // eat it } break; } } } return CInputListCtrl::PreTranslateMessage(pMsg); }
void CInPlaceListBox::OnKillFocus(CWnd* pNewWnd) { CListBox::OnKillFocus(pNewWnd); CString str; GetWindowText(str); LV_DISPINFO dispinfo; dispinfo.hdr.hwndFrom = GetParent()->m_hWnd; dispinfo.hdr.idFrom = GetDlgCtrlID(); dispinfo.hdr.code = LVN_ENDLABELEDIT; dispinfo.item.mask = LVIF_TEXT | LVIF_PARAM; dispinfo.item.iItem = m_iItem; dispinfo.item.iSubItem = m_iSubItem; dispinfo.item.pszText = m_bESC ? nullptr : LPTSTR((LPCTSTR)str); dispinfo.item.cchTextMax = str.GetLength(); dispinfo.item.lParam = GetCurSel(); GetParent()->GetParent()->SendMessage(WM_NOTIFY, GetParent()->GetDlgCtrlID(), (LPARAM)&dispinfo); PostMessage(WM_CLOSE); }
void CTabCtrlSSL::OnSelChange (NMHDR* pNMHDR, LRESULT* pResult) { int nIndex = GetCurSel (); if (nIndex == -1) return; // Show the new page. TabDelete tabDelete = m_tabs[nIndex]; CTabPageSSL* pDialog = tabDelete.pTabPage; if (pDialog != NULL) { ::SetFocus (m_hFocusWnd[nIndex]); CRect rect; GetClientRect (&rect); ResizeDialog (nIndex, rect.Width (), rect.Height ()); pDialog->ShowWindow (SW_SHOW); } // Notify derived classes that the selection has changed. OnActivatePage (nIndex, m_nPageIDs[nIndex]); *pResult = 0; }