本文整理汇总了C++中GetSel函数的典型用法代码示例。如果您正苦于以下问题:C++ GetSel函数的具体用法?C++ GetSel怎么用?C++ GetSel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetSel函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetWindowText
void CRichEditCtrlX::UpdateSyntaxColoring()
{
CString strText;
GetWindowText(strText);
if (strText.IsEmpty())
return;
m_bSelfUpdate = true;
long lCurSelStart, lCurSelEnd;
GetSel(lCurSelStart, lCurSelEnd);
SetSel(0, -1);
SetSelectionCharFormat(m_cfDef);
SetSel(lCurSelStart, lCurSelEnd);
LPTSTR pszStart = const_cast<LPTSTR>((LPCTSTR)strText);
LPCTSTR psz = pszStart;
while (*psz != _T('\0'))
{
if (*psz == _T('\"'))
{
LPCTSTR pszEnd = _tcschr(psz + 1, _T('\"'));
if (pszEnd)
psz = pszEnd + 1;
else
break;
}
else
{
bool bFoundKeyword = false;
for (int k = 0; k < m_astrKeywords.GetCount(); k++)
{
const CString& rstrKeyword = m_astrKeywords[k];
int iKwLen = rstrKeyword.GetLength();
if (_tcsncmp(psz, rstrKeyword, iKwLen)==0 && (psz[iKwLen]==_T('\0') || _tcschr(m_strSeperators, psz[iKwLen])!=NULL))
{
long iStart = static_cast<long>(psz - pszStart);
long iEnd = static_cast<long>(iStart + iKwLen);
long lCurSelStart, lCurSelEnd;
GetSel(lCurSelStart, lCurSelEnd);
SetSel(iStart, iEnd);
SetSelectionCharFormat(m_cfKeyword);
SetSel(lCurSelStart, lCurSelEnd);
psz += iKwLen;
bFoundKeyword = true;
break;
}
}
if (!bFoundKeyword)
psz++;
}
}
UpdateWindow();
m_bSelfUpdate = false;
}
示例2: GetItemCount
void WINAPI duListBox::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
int nItemCount = GetItemCount();
if (nItemCount == 0)
return;
if (nChar == VK_UP)
{
int nSel = GetSel();
nSel--;
if (nSel < 0)
nSel = 0;
if (nSel >= nItemCount)
nSel = nItemCount - 1;
SetSel(nSel);
duScroll *pScroll = (duScroll *)GetPluginByName(m_szVertScroll);
if (pScroll)
{
pScroll->SetPos(m_nItemHeight * nSel);
UpdateScroll();
}
if (!m_fCombobox)
{
m_pHotItem = NULL;
Plugin_Redraw(this, TRUE);
}
else
{
FadeRedraw();
}
}
else if (nChar == VK_DOWN)
{
int nSel = GetSel();
_TRACE(_T("nSel :%d\n"), nSel);
nSel++;
if (nSel >= nItemCount)
nSel = nItemCount - 1;
if (nSel < 0)
nSel = 0;
SetSel(nSel);
duScroll *pScroll = (duScroll *)GetPluginByName(m_szVertScroll);
if (pScroll)
{
pScroll->SetPos(m_nItemHeight * nSel);
UpdateScroll();
}
if (!m_fCombobox)
{
m_pHotItem = NULL;
Plugin_Redraw(this, TRUE);
}
else
FadeRedraw();
}
}
示例3: MessageBeep
BOOL CMyDateEdit::CheckChar(UINT nChar)
{
int nTime = 0;
//如果不使用掩码,则返回
if(!m_bUseMask) return TRUE;
//如果是控制字符,则返回
if(!isprint(nChar)) return TRUE;
if(!isdigit(nChar))
{
MessageBeep((UINT)-1);
return FALSE;
}
//如果存在选择区域,则取消选择
int startPos,endPos;
GetSel(startPos,endPos);
SetSel(-1,0);
//重新选中原选择区域的第一个字符
SetSel(startPos,startPos);
GetSel(startPos,endPos);
//确保字符串的长度不超过掩码的长度
if(endPos>=m_strMask.GetLength())
{
MessageBeep((UINT)-1);
return FALSE;
}
//时间格式
if(m_isTime)
{
if(!CheckTime(nChar,startPos,endPos))
{
return FALSE;
}
}
//日期格式
if(m_isDate)
{
if(!CheckDate(nChar,startPos,startPos))
{
return FALSE;
}
}
if(m_isDateTime)
{
if(!CheckDate(nChar,startPos,startPos))
{
return FALSE;
}
if(!CheckTime(nChar,startPos,startPos))
{
return FALSE;
}
}
return TRUE;
}
示例4: GetSel
void NativeTextfieldWin::OnAfterPossibleChange(bool should_redraw_text)
{
// Prevent the user from selecting the "phantom newline" at the end of the
// edit. If they try, we just silently move the end of the selection back to
// the end of the real text.
CHARRANGE new_sel;
GetSel(new_sel);
const int length = GetTextLength();
if(new_sel.cpMax > length)
{
new_sel.cpMax = length;
if(new_sel.cpMin > length)
{
new_sel.cpMin = length;
}
SetSel(new_sel);
}
std::wstring new_text(GetText());
if(new_text != text_before_change_)
{
if(ime_discard_composition_ && ime_composition_start_>=0 &&
ime_composition_length_>0)
{
// A string retrieved with a GetText() call contains a string being
// composed by an IME. We remove the composition string from this search
// string.
new_text.erase(ime_composition_start_, ime_composition_length_);
ime_composition_start_ = 0;
ime_composition_length_ = 0;
if(new_text.empty())
{
return;
}
}
textfield_->SyncText();
UpdateAccessibleValue(textfield_->text());
if(should_redraw_text)
{
CHARRANGE original_sel;
GetSel(original_sel);
std::wstring text = GetText();
ScopedSuspendUndo suspend_undo(GetTextObjectModel());
SelectAll();
ReplaceSel(reinterpret_cast<LPCTSTR>(text.c_str()), true);
SetSel(original_sel);
}
}
}
示例5: GetWindowText
/////////////////////////////////////////////////////////////////////////////
// CMyDateEdit message handlers
void CMyDateEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
CString str;
GetWindowText(str);
for (int i = 0; i<str.GetLength() && i<m_str.GetLength();i++)
m_str.SetAt(i, str.GetAt(i));
if(!m_bMaskKeyInProgress)
if(!CheckChar(nChar)) return;
if(m_bUseMask) //要使用掩码
{
if(isdigit(nChar)) //是可打印字符
{
int startPos,endPos;
GetSel(startPos,endPos);
SetSel(startPos,endPos+1);
if(m_strMask.GetAt(startPos)=='-'||m_strMask.GetAt(startPos)==':'||m_strMask.GetAt(startPos)==' ')
{
SetSel(startPos+1,startPos+1);
SendChar(nChar);
return;
}
}
else if(nChar==VK_BACK)
{
int startPos,endPos;
GetSel(startPos,endPos);
if((startPos==endPos) && (startPos>=1) && (startPos<=m_str.GetLength()))
{
char c;
c=m_strMask.GetAt(startPos-1);
if(c=='-'||c==':'||c==' ')
{
SetSel(startPos-1,startPos-1);
return;
}
////回退光标
SetSel(startPos-1,startPos-1);
SendChar(c);
//再次退回
SendMessage(WM_KEYDOWN,VK_LEFT,0);
}
else //越界或者存在选择区域
MessageBeep((UINT)-1);
return;
}
}
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
示例6: GetWindowText
void CIntEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (!(nChar >= '0' && nChar <= '9' || nChar == '-' || nChar == '\b')) {
return;
}
CString str;
GetWindowText(str);
if (nChar == '-' && !str.IsEmpty() && str[0] == '-') {
return;
}
int nStartChar, nEndChar;
GetSel(nStartChar, nEndChar);
if (nChar == '\b' && nStartChar <= 0) {
return;
}
if (nChar == '-' && (nStartChar != 0 || nEndChar != 0)) {
return;
}
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
示例7: VERIFY
void CPropTreeItemFileEdit::OnContextMenu(CWnd *pWnd, CPoint point)
{
CMenu FloatingMenu;
VERIFY(FloatingMenu.LoadMenu(IDR_ME_EDIT_MENU));
CMenu *pPopupMenu = FloatingMenu.GetSubMenu(0);
if (CanUndo()) {
pPopupMenu->EnableMenuItem(ID_EDIT_UNDO, MF_BYCOMMAND | MF_ENABLED);
} else {
pPopupMenu->EnableMenuItem(ID_EDIT_UNDO, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
}
DWORD dwSel = GetSel();
if (HIWORD(dwSel) != LOWORD(dwSel)) {
pPopupMenu->EnableMenuItem(ID_EDIT_CUT, MF_BYCOMMAND | MF_ENABLED);
pPopupMenu->EnableMenuItem(ID_EDIT_COPY, MF_BYCOMMAND | MF_ENABLED);
pPopupMenu->EnableMenuItem(ID_EDIT_DELETE, MF_BYCOMMAND | MF_ENABLED);
} else {
pPopupMenu->EnableMenuItem(ID_EDIT_CUT, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
pPopupMenu->EnableMenuItem(ID_EDIT_COPY, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
pPopupMenu->EnableMenuItem(ID_EDIT_DELETE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
}
pPopupMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
}
示例8: GetSel
void CPWL_Edit::PasteText() {
if (!CanPaste())
return;
CFX_WideString swClipboard;
if (IFX_SystemHandler* pSH = GetSystemHandler())
swClipboard = pSH->GetClipboardText(GetAttachedHWnd());
if (m_pFillerNotify) {
FX_BOOL bRC = TRUE;
FX_BOOL bExit = FALSE;
CFX_WideString strChangeEx;
int nSelStart = 0;
int nSelEnd = 0;
GetSel(nSelStart, nSelEnd);
m_pFillerNotify->OnBeforeKeyStroke(GetAttachedData(), swClipboard,
strChangeEx, nSelStart, nSelEnd, TRUE,
bRC, bExit, 0);
if (!bRC)
return;
if (bExit)
return;
}
if (swClipboard.GetLength() > 0) {
Clear();
InsertText(swClipboard.c_str());
}
}
示例9: UNUSED_ALWAYS
void CFileListBox::OnContextMenu(CWnd* pWnd, CPoint point)
{
UNUSED_ALWAYS(pWnd);
CMenu menu;
menu.LoadMenu(IDR_TT_CONTEXTMENU);
CMenu *pPopup=menu.GetSubMenu(0);
/*
ScreenToClient(&point);
BOOL bOutside;
m_nIndex=ItemFromPoint(point,bOutside);
CRect rect;
GetItemRect(m_nIndex,rect);
if(bOutside || !rect.PtInRect(point)){
pPopup->EnableMenuItem(IDC_TT_REMOVE,MF_BYCOMMAND|MF_GRAYED);
}
ClientToScreen(&point);
*/
for(int i=0;i<GetCount();i++){
if(GetSel(i)){
break;
}
}
if(i==GetCount()){
pPopup->EnableMenuItem(IDC_TT_REMOVE,MF_BYCOMMAND|MF_GRAYED);
}
pPopup->TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON, point.x,point.y,this);
}
示例10: GetSel
LRESULT CUrlRichEditCtrl::OnDropFiles(WPARAM wp, LPARAM /*lp*/)
{
CHARRANGE crSelOrg;
GetSel(crSelOrg); // save this off
BOOL bEnable = !(GetStyle() & ES_READONLY) && IsWindowEnabled();
if (!bEnable)
return 0;
CStringArray aFiles;
CString sText;
SetSel(m_crDropSel);
int nNumFiles = FileMisc::GetDropFilePaths((HDROP)wp, aFiles);
::DragFinish((HDROP)wp);
::CloseClipboard();
if (nNumFiles > 0)
return CRichEditHelper::PasteFiles(*this, aFiles, REP_ASFILEURL);
// else
return nNumFiles;
}
示例11: ScreenToClient
BOOL CFulEditCtrl::ShowMenu(HWND hWnd, POINT &pt){
ScreenToClient(&pt);
CHARRANGE cr;
GetSel(cr);
if(cr.cpMax != cr.cpMin) {
TCHAR *buf = new TCHAR[cr.cpMax - cr.cpMin + 1];
GetSelText(buf);
searchTerm = Util::replace(buf, _T("\r"), _T("\r\n"));
delete[] buf;
} else {
tstring line;
tstring::size_type ch = TextUnderCursor(pt, line);
if( ch != tstring::npos ) {
tstring::size_type start = line.find_last_of(_T(" \t\r"), ch) + 1;
tstring::size_type end = line.find_first_of(_T(" \t\r"), start);
if(end == tstring::npos) {
end = line.length();
}
searchTerm = line.substr(start, end-start);
}
}
ClientToScreen(&pt);
WinUtil::AppendSearchMenu(searchMenu);
return menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, hWnd );
}
示例12: GetParent
void CInPlaceFloatEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
if (nChar == VK_ESCAPE || nChar == VK_RETURN) {
if (nChar == VK_ESCAPE) {
m_bESC = TRUE;
}
GetParent()->SetFocus();
return;
}
if (nChar == ',') {
nChar = '.';
}
if (!(nChar >= '0' && nChar <= '9' || nChar == '.' || nChar == '\b')) {
return;
}
CString str;
GetWindowText(str);
if ((nChar == '.') && str.Find('.') >= 0) {
int nStartChar, nEndChar;
GetSel(nStartChar, nEndChar);
if (!(nStartChar < nEndChar && str.Mid(nStartChar, nEndChar - nStartChar).Find('.') >= 0)) {
return;
}
}
//CEdit::OnChar(nChar, nRepCnt, nFlags);
DefWindowProc(WM_CHAR, nChar, MAKELONG(nRepCnt, nFlags));
}
示例13: GetObjectMgr
/*
* CTxtEdit::ObjectFromIOB
*
* @mfunc Gets an object based on an IOB type index.
*
* @rdesc:
* pointer to COleObject or NULL if none.
*/
COleObject * CTxtEdit::ObjectFromIOB(LONG iob)
{
COleObject * pobj = NULL;
CObjectMgr * pobjmgr = NULL;
pobjmgr = GetObjectMgr();
if (!pobjmgr)
{
return NULL;
}
// Figure out the index of the selection
if (iob == REO_IOB_SELECTION)
{
CTxtSelection * psel = GetSel();
pobj = pobjmgr->GetFirstObjectInRange(psel->GetCpMin(),
psel->GetCpMost());
}
else
{
// Make sure the IOB is in range
if ((0 <= iob) && (iob < GetObjectCount()))
{
pobj = pobjmgr->GetObjectFromIndex(iob);
}
}
return pobj;
}
示例14: GetSel
/*
================
CSyntaxRichEditCtrl::GetNameBeforeCurrentSelection
================
*/
bool CSyntaxRichEditCtrl::GetNameBeforeCurrentSelection(CString &name, int &charIndex) const
{
long selStart, selEnd;
int line, column, length;
char buffer[1024];
GetSel(selStart, selEnd);
charIndex = selStart;
line = LineFromChar(selStart);
length = GetLine(line, buffer, sizeof(buffer));
column = selStart - LineIndex(line) - 1;
do {
buffer[column--] = '\0';
} while (charType[buffer[column]] == CT_WHITESPACE);
for (length = 0; length < column; length++) {
if (charType[buffer[column-length-1]] != CT_NAME) {
break;
}
}
if (length > 0) {
name = buffer + column - length;
return true;
}
return false;
}
示例15: dlg
void CPropTreeItemFileEdit::OnInsertFile()
{
CFileDialog dlg(TRUE);
dlg.m_ofn.Flags |= OFN_FILEMUSTEXIST;
int startSel, endSel;
GetSel(startSel, endSel);
if (dlg.DoModal()== IDOK) {
idStr currentText = (char *)GetItemValue();
idStr newText = currentText.Left(startSel) + currentText.Right(currentText.Length() - endSel);
idStr filename = fileSystem->OSPathToRelativePath(dlg.m_ofn.lpstrFile);
filename.BackSlashesToSlashes();
newText.Insert(filename, startSel);
SetItemValue((LPARAM)newText.c_str());
m_pProp->RefreshItems(this);
m_pProp->SendNotify(PTN_ITEMCHANGED, this);
}
}