当前位置: 首页>>代码示例>>C++>>正文


C++ CEdit::GetSel方法代码示例

本文整理汇总了C++中CEdit::GetSel方法的典型用法代码示例。如果您正苦于以下问题:C++ CEdit::GetSel方法的具体用法?C++ CEdit::GetSel怎么用?C++ CEdit::GetSel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CEdit的用法示例。


在下文中一共展示了CEdit::GetSel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnClickedDecodeh

void CStationDlg::OnClickedDecodeh(void)
{
	CEdit *cetodo = (CEdit *) CWnd::GetDlgItem(IDC_TODO1);
	int i,j;
	cetodo->GetSel(i,j);

	// NT SPECIFIC
   HLOCAL h = cetodo->GetHandle();
   LPCTSTR lpszText = (LPCTSTR)LocalLock(h);
	char res[1000];
	strncpy(res,&(lpszText[i]),j-i);
	SetDlgItemText(IDC_DECDEC,res);
	unsigned short f;
	unsigned char *pf;
	unsigned int b1,b2;
	pf = (unsigned char *)&f;
	sscanf(res,"%x %x",&b1,&b2);
	pf[0] = b1;
	pf[1] = b2;
	CString sres;
	sres.Format("%04X = %d",f,f);
	SetDlgItemText(IDC_DECFLOAT,sres);
	
   LocalUnlock(h);
	// END OF NT SPECIFIC
}
开发者ID:AllegianceZone,项目名称:ICE,代码行数:26,代码来源:StationDlg.cpp

示例2: OnClickedDecodesel

void CStationDlg::OnClickedDecodesel(void)
{
	CEdit *cetodo = (CEdit *) CWnd::GetDlgItem(IDC_TODO1);
	int i,j;
	cetodo->GetSel(i,j);

	// NT SPECIFIC
   HLOCAL h = cetodo->GetHandle();
   LPCTSTR lpszText = (LPCTSTR)LocalLock(h);
	char res[1000];
	strncpy(res,&(lpszText[i]),j-i);res[j-i] = 0;
	CString sres = res;
	sres.Replace("\r\n","");
	SetDlgItemText(IDC_DECDEC,sres);
	float f;
	unsigned char *pf;
	unsigned int b1,b2,b3,b4;
	pf = (unsigned char *)&f;
	sscanf(sres,"%x %x %x %x",&b1,&b2,&b3,&b4);
	pf[0] = b1;
	pf[1] = b2;
	pf[2] = b3;
	pf[3] = b4;
	sres.Format("%g",f);
	SetDlgItemText(IDC_DECFLOAT,sres);
	
   LocalUnlock(h);
	// END OF NT SPECIFIC
}
开发者ID:AllegianceZone,项目名称:ICE,代码行数:29,代码来源:StationDlg.cpp

示例3: OnTextChanged

LRESULT FavHubProperties::OnTextChanged(WORD /*wNotifyCode*/, WORD wID, HWND hWndCtl, BOOL& /*bHandled*/)
{
	TCHAR buf[256];

	GetDlgItemText(wID, buf, 256);
	tstring old = buf;

	// Strip '$', '|' and ' ' from text
	TCHAR *b = buf, *f = buf, c;
	while( (c = *b++) != 0 )
	{
		if(c != '$' && c != '|' && (wID == IDC_HUBUSERDESCR || c != ' ') && ( (wID != IDC_HUBNICK) || (c != '<' && c != '>')) )
			*f++ = c;
	}

	*f = '\0';

	if(old != buf)
	{
		// Something changed; update window text without changing cursor pos
		CEdit tmp;
		tmp.Attach(hWndCtl);
		int start, end;
		tmp.GetSel(start, end);
		tmp.SetWindowText(buf);
		if(start > 0) start--;
		if(end > 0) end--;
		tmp.SetSel(start, end);
		tmp.Detach();
	}

	return TRUE;
}
开发者ID:strogo,项目名称:StrongDC,代码行数:33,代码来源:FavHubProperties.cpp

示例4: OnChar

//只允许输入数字 小数点
void CCheckEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	//只接受 数字、小数点、退格
	if( (nChar < '0' || nChar > '9') && nChar != '.' && nChar != VK_BACK )
		return ;

	CString strCheck;
	CEdit *pEdit = (CEdit*)GetFocus();
	pEdit->GetWindowTextW(strCheck);
	DWORD dwSel = pEdit->GetSel();

	//光标在最左边  1.不允许输入小数点	2.除了个位为0外,最高位不能为 0
	if(dwSel == 0){
		if(nChar == '.' || (nChar == '0' && !strCheck.IsEmpty()))
			return ;
	}
	//光标不在最左边  1.只允许输入一个小数点	2.只有一个0的情况下,除了小数点外任何数字均覆盖掉0(这里要做的就是清空)
	else{
		if(nChar == '.' && strCheck.Find(_T('.')) != -1)
			return ;
		if(strCheck.Compare(_T("0")) == 0 && (nChar != '.'&& nChar != VK_BACK))
			pEdit->SetWindowTextW(NULL);
	}

	CEdit::OnChar(nChar, nRepCnt, nFlags);
}
开发者ID:jxhot85,项目名称:counter,代码行数:27,代码来源:CheckEdit.cpp

示例5: OnChangeEnteredtext

void CStringDlg::OnChangeEnteredtext() 
{
	CString		sText;
	CString		sNew;
	char		letter[2] = {0,0};
	int			i;

	CEdit		*pEdit = (CEdit*)GetDlgItem( IDC_ENTEREDTEXT );
	int			selStart, selEnd;


	// Validate the string.
	pEdit->GetWindowText( sText );

	for( i=0; i < sText.GetLength(); i++ )
	{
		if( m_bAllowLetters )
		{
			if( isalpha(sText[i]) )
			{
				letter[0] = sText[i];
				sNew += letter;
			}
		}
	
		if( m_bAllowNumbers )
		{
			if( isdigit(sText[i]) )
			{
				letter[0] = sText[i];
				sNew += letter;
			}
		}

		if( m_bAllowOthers )
		{
			if( !isdigit(sText[i]) && !isalpha(sText[i]) )
			{
				letter[0] = sText[i];
				sNew += letter;
			}
		}
	}

	if( (sNew.GetLength() != sText.GetLength()) || (sNew.GetLength() > m_MaxStringLen) )
	{
		if( sNew.GetLength() > m_MaxStringLen )
			sNew = sNew.Left(m_MaxStringLen);

		pEdit->GetSel( selStart, selEnd );
		pEdit->SetWindowText( sNew );
		pEdit->SetSel( selStart-1, selEnd-1 );
	
		if( m_bBeeping )
			MessageBeep(0);
	}

	GetDlgItem(IDOK)->EnableWindow(strlen(sNew) > 0 ? TRUE : FALSE);	
}
开发者ID:Joincheng,项目名称:lithtech,代码行数:59,代码来源:StringDlg.cpp

示例6: OnUpdateEditDelete

void CBibitemView::OnUpdateEditDelete(CCmdUI* pCmdUI) 
{
	CEdit* edit = GetFocusEdit();
	if (edit) {
		int s, e;
		edit->GetSel(s, e);
		pCmdUI->Enable(edit && s != e);
	} else
		pCmdUI->Enable(FALSE);
}
开发者ID:stievie,项目名称:bibedt,代码行数:10,代码来源:BibitemView.cpp

示例7: setColorCount

void CGridDlg::setColorCount(int value) {
  if(value >= 2 || (value == 0)) {
    CEdit *e = (CEdit*)GetDlgItem(IDC_EDITCOLORCOUNT);
    const DWORD sel = e->GetSel();
    m_colorCount = value;
    flushData();
    windowToValue();
    e->SetSel(sel);
  }
}
开发者ID:JesperMikkelsen,项目名称:Big-Numbers,代码行数:10,代码来源:GridDlg.cpp

示例8: Py_BuildValue

// @pymethod (start, end)|PyCEdit|GetSel|Returns the start and end of the current selection.
static PyObject *PyCEdit_get_sel(PyObject *self, PyObject *args)
{
	CHECK_NO_ARGS(args);
	CEdit *pEdit = GetEditCtrl(self);
	if (!pEdit)
		return NULL;
	int start,end;
	GUI_BGN_SAVE;
	pEdit->GetSel(start,end); // @pyseemfc CEdit|GetSel
	GUI_END_SAVE;
	return Py_BuildValue("(ii)",start,end);
	// @rdesc The return tuple is (the first character in the current selection, first nonselected character past the end of the current selection)
}
开发者ID:DavidGuben,项目名称:rcbplayspokemon,代码行数:14,代码来源:win32ctledit.cpp

示例9: DoPaste

void CEditBar::DoPaste()
{
    CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT);
    ASSERT(pEdit);
    if ( !OpenClipboard() ) 
        return;
    HANDLE hData = GetClipboardData(CF_TEXT);
    ASSERT(hData);
    if ( hData == NULL ) 
        return;

    CString str = (LPSTR)GlobalLock(hData);
    GlobalUnlock(hData);
    CloseClipboard();
    CString strIns, strAdd;
    pEdit->GetWindowText(strIns);
    char* src = (LPSTR)(LPCSTR)str;
    int StartSel, EndSel;
    pEdit->GetSel(StartSel, EndSel);
    CWnd* pWnd = ((CMainFrame*)AfxGetMainWnd())->GetActiveView();

    do {
        switch (*src ) {
        case '\n':
            strIns = "";
            pEdit->SetWindowText(strAdd);
            if ( pWnd ) 
                pWnd->SendMessage(WM_USER+100 , 0 , 0 );
            strAdd = "";
            break;
        case '\r':
            break;
        case 0:
            break;
        default:
            strAdd += *src;
            break;
        };

    } while (*src++);
    if ( strAdd.GetLength() ) {
        int size = strAdd.GetLength();
        strAdd = strIns.Left(StartSel) + strAdd + strIns.Right(strIns.GetLength() - EndSel);
        
        pEdit->SetWindowText(strAdd);
        pEdit->SetSel(StartSel+ size, StartSel+size, TRUE);
    }
}
开发者ID:Liscar,项目名称:jmc,代码行数:48,代码来源:EditBar.cpp

示例10: OnChangeEnteredtext

void CStringDlg::OnChangeEnteredtext() 
{
	CString		sText;
	CString		sNew;
	int			i;

	CEdit		*pEdit = (CEdit*)GetDlgItem( IDC_ENTEREDTEXT );
	int			selStart, selEnd;


	// Validate the string.
	pEdit->GetWindowText( sText );

	for( i=0; i < sText.GetLength(); i++ )
	{
		bool bAddChar = FALSE;

		// Filter out invalid characters based on the flags
		bAddChar |= (m_bAllowLetters) && isalpha(sText[i]);
		bAddChar |= (m_bAllowNumbers) && isdigit(sText[i]);
			// Note : Spaces are not allowed in file names to facilitate command line parsing
		bAddChar |= (m_bAllowFile) && (!strchr("\\/:*?\"<>| ", sText[i]));
		bAddChar |= (m_bAllowOthers) && (!isdigit(sText[i]) && !isalpha(sText[i]));

		if (bAddChar)
			sNew += sText[i];
	}

	if( (sNew.GetLength() != sText.GetLength()) || (sNew.GetLength() > m_MaxStringLen) )
	{
		if( sNew.GetLength() > m_MaxStringLen )
			sNew = sNew.Left(m_MaxStringLen);

		pEdit->GetSel( selStart, selEnd );
		pEdit->SetWindowText( sNew );
		pEdit->SetSel( selStart-1, selEnd-1 );
	
		if( m_bBeeping )
			MessageBeep(0);
	}

	GetDlgItem(IDOK)->EnableWindow(strlen(sNew) > 0 ? TRUE : FALSE);	
}
开发者ID:Joincheng,项目名称:lithtech,代码行数:43,代码来源:StringDlg.cpp

示例11: CheckDir

// This routine updates the directory/file list display using the directory
// name given.  It does this by putting the name in the (hidden) edit control
// and simulating a press of the (hidden) IDOK button.  If the directory is
// invalid in some way the currently displayed list will not be changed and
// some sort of error message may be displayed.
void CDlgWnd::CheckDir(const CString &ss)
{
    // Put the new directory into the old (hidden) edit box
    CEdit *pOld = (CEdit *)GetDlgItem(edt1);
    ASSERT(pOld != NULL);
    pOld->SetWindowText(ss);

    // Save the current text/selection in the edit control
    CString strSaved;                       // Current text in edit box
    int start, end;                         // Current selection in edit box
    CEdit *pEdit = (CEdit *)GetDlgItem(IDC_DIR);
    ASSERT(pEdit != NULL);
    pEdit->GetWindowText(strSaved);
    pEdit->GetSel(start, end);

    CWnd *pOK = GetDlgItem(IDOK);
    pOK->SendMessage(WM_LBUTTONDOWN);
    pOK->SendMessage(WM_LBUTTONUP);

    CString strNew;
    pEdit->GetWindowText(strNew);

    // Usually we want to keep what the user has typed (strSaved) rather than what has been
    // put in the edit control due to OnFolderChange.  One exception is if the user has
    // used "..", "..." etc to change to an ancestor directory in which case we don't want to
    // leave this the same as it will cause repeated changes to ancestor directories whenever
    // the user types backslash (\).  Also don;t set the edit string back to what the user
    // typed if it would be empty or unchanged except for case (as the case probably looks
    // better the way it was filled in).
    if (strSaved.IsEmpty() || strSaved[0] == '.' ||
        strNew.CompareNoCase(strSaved) == 0 || strNew.CompareNoCase(strSaved + '\\') == 0)
    {
        pEdit->SetSel(strNew.GetLength(), -1);
    }
    else
    {
        // Restore the edit control the way the user typed it
        pEdit->SetWindowText(strSaved);
        pEdit->SetSel(start, end);
    }
}
开发者ID:QAndot,项目名称:Advanced-Tray-Service-Manager,代码行数:46,代码来源:DirDialog.cpp

示例12: PreTranslateMessage

BOOL CValueDescriptionDlg::PreTranslateMessage(MSG* pMsg)
{
    // Do not process non-hexadecimal characters
    // in signal value edit control
    BOOL bSkip = FALSE;
    CEdit* omEditCtrlName   = (CEdit*) GetDlgItem(IDC_EDIT_VAL);
    CEdit* omEditFocusName  = (CEdit*) GetFocus();
    if ( pMsg->message == WM_CHAR )
    {
        if ( omEditCtrlName == omEditFocusName )
        {
            int nStart, nEnd;
            omEditCtrlName->GetSel(nStart, nEnd);
            if (nStart == 0 &&
                    pMsg->wParam == MINUS_SIGN)
            {
                bSkip = FALSE;
            }
            else if ( ( pMsg->wParam >= 0x61 && pMsg->wParam<=0x66 )|| // A-F
                      ( pMsg->wParam >= 0x41 && pMsg->wParam<=0x46 )||// a-f
                      ( pMsg->wParam >= '0' && pMsg->wParam <='9' ) ||// 0-9
                      pMsg->wParam == 0x08 )// BackSpace
            {
                bSkip = FALSE;
            }
            else
            {
                bSkip = TRUE;
            }
        }
    }
    if ( bSkip == FALSE )
    {
        bSkip = CDialog::PreTranslateMessage(pMsg);
    }

    return bSkip;
}
开发者ID:redfoxhb,项目名称:busmaster,代码行数:38,代码来源:ValueDescriptionDlg.cpp

示例13: CheckDir

// This routine updates the directory/file list display using the directory
// name given.  It does this by putting the name in the (hidden) edit control
// and simulating a press of the (hidden) IDOK button.  If the directory is
// invalid in some way the currently displayed list will not be changed and
// some sort of error message may be displayed.
void CDlgWnd::CheckDir(const CString &ss)
{
	// Put the new directory into the old (hidden) edit box
	CWnd *pOld = GetDlgItem(edt1);
	if (pOld == NULL)
		pOld = GetDlgItem(cmb13);    // edit control replaced with combo in newer Windows versions
	ASSERT(pOld != NULL);
	pOld->SetWindowText(ss);

	// Save the current text/selection in the edit control
	CString strSaved;                       // Current text in edit box
	int start, end;                         // Current selection in edit box
	CEdit *pEdit = (CEdit *)GetDlgItem(IDC_DIR);
	ASSERT(pEdit != NULL);
	pEdit->GetWindowText(strSaved);
	pEdit->GetSel(start, end);

	CWnd *pOK = GetDlgItem(IDOK);
	ASSERT(pOK != NULL);
	pOK->SendMessage(WM_LBUTTONDOWN);
	pOK->SendMessage(WM_LBUTTONUP);

	CString strNew;
	pEdit->GetWindowText(strNew);

	if (strSaved.GetLength() >= 1 && strSaved[0] == '\\' ||
		 strSaved.GetLength() >= 3 && strSaved[1] == ':' && strSaved[2] == '\\')
	{
		// Keep the text the way the user typed it if we can
		pEdit->SetWindowText(strSaved);
		pEdit->SetSel(start, end);
	}
	else
	{
		// Move cursor to the end
		pEdit->SetSel(strNew.GetLength(), -1);
	}
}
开发者ID:Andrew-Phillips,项目名称:HexEdit,代码行数:43,代码来源:DirDialog.cpp

示例14: OnKillFocus

void CEditBar::OnKillFocus()
{
    CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT);
    pEdit->GetSel(m_nCurSelStart , m_nCurSelEnd);
}
开发者ID:Liscar,项目名称:jmc,代码行数:5,代码来源:EditBar.cpp

示例15: SpellCheckCommand

long CMUSHclientDoc::SpellCheckCommand(long StartCol, long EndCol) 
{
  if (!App.m_bSpellCheckOK)
    return -1;

  CEdit * pEdit = NULL;
  CWnd * pWnd = NULL;

  // find command window

  for(POSITION pos = GetFirstViewPosition(); pos != NULL; )
	  {
	  CView* pView = GetNextView(pos);
	  
	  if (pView->IsKindOf(RUNTIME_CLASS(CSendView)))
  	  {
		  CSendView* pmyView = (CSendView*)pView;

      // what is the current selection?

      pWnd = pmyView;
      pEdit = & (pmyView->GetEditCtrl());
      break;
      
      }	  // end of being a CSendView
    }   // end of loop through views

  if (pEdit == NULL)
	  return -1;    // couldn't find it

  int nStartChar, 
      nEndChar;

  // get current selection
  pEdit->GetSel (nStartChar, nEndChar); 

  // make wanted selection 1-relative
  if (StartCol > 0)
    StartCol--;

  bool bHaveSelection = EndCol > StartCol &&
                         StartCol >= 0 &&
                         EndCol >= 0;

  // select what the scripter wanted
  if (bHaveSelection)
     pEdit->SetSel (StartCol, EndCol); 

  if (App.m_SpellChecker_Lua)
    {

    lua_settop(App.m_SpellChecker_Lua, 0);   // clear stack

    lua_getglobal (App.m_SpellChecker_Lua, SPELLCHECKFUNCTION);  
    if (!lua_isfunction (App.m_SpellChecker_Lua, -1))
      return true;  // assume ok, what can we do?

    CString strText;
    bool bAll = GetSelection (pEdit, strText);
    
    lua_pushstring (App.m_SpellChecker_Lua, strText);  // string to be checked
    lua_pushboolean (App.m_SpellChecker_Lua, bAll);    // doing all?

    int narg = lua_gettop(App.m_SpellChecker_Lua) - 1;  // all but the function
    int error = CallLuaWithTraceBack (App.m_SpellChecker_Lua, narg, 1);
    
    if (error)
      {
      LuaError (App.m_SpellChecker_Lua, "Run-time error", SPELLCHECKFUNCTION, "Command-line spell-check");
      lua_close (App.m_SpellChecker_Lua);
      App.m_SpellChecker_Lua = NULL;
      App.m_bSpellCheckOK = false;
      return -1;    
      }  

    if (lua_isstring (App.m_SpellChecker_Lua, -1))
      {
      const char * p = lua_tostring (App.m_SpellChecker_Lua, -1);
      if (bAll)
        pEdit->SetSel (0, -1, TRUE);
      pEdit->ReplaceSel (p, true);
      // put original selection back
      pEdit->SetSel (nStartChar, nEndChar); 
      return 1;   // spell checked ok
      }

    // put original selection back
    pEdit->SetSel (nStartChar, nEndChar); 
    return 0;      // they cancelled
    }

  return -1;

} // end of CMUSHclientDoc::SpellCheckCommand
开发者ID:RKelson93,项目名称:mushclient,代码行数:94,代码来源:methods_spellchecker.cpp


注:本文中的CEdit::GetSel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。