本文整理汇总了C++中CEdit::GetLine方法的典型用法代码示例。如果您正苦于以下问题:C++ CEdit::GetLine方法的具体用法?C++ CEdit::GetLine怎么用?C++ CEdit::GetLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CEdit
的用法示例。
在下文中一共展示了CEdit::GetLine方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetEditText
CString CozyKnightModifyDlg::GetEditText(const CEdit& editCtrl)
{
int nLenght = editCtrl.LineLength(1);
CString strValue;
editCtrl.GetLine(1, strValue.GetBuffer(nLenght), nLenght);
strValue.ReleaseBuffer(nLenght);
return strValue;
}
示例2:
// TODO: factor this code
static void concatEdit2Lines(CEdit &edit)
{
const uint lineLen= 1000;
uint n;
// retrieve the 2 lines.
char tmp0[2*lineLen];
char tmp1[lineLen];
n= edit.GetLine(0, tmp0, lineLen); tmp0[n]= 0;
n= edit.GetLine(1, tmp1, lineLen); tmp1[n]= 0;
// concat and update the CEdit.
edit.SetWindowText(strcat(tmp0, tmp1));
}
示例3: GetCDInfo
/**
* Gets change directory info from previous lines, feature only
* for cmdl and compiler tab, all other tabs return sFile unchanged.
*
* @param iLine: zero based line index from where to
* search cd [path] commands backward until
* first line or cd <fullpath> or special cd $(prjdir)
* is found
* @param editCtrl: holds the text data
* @param sFile: in/out. gets updated to point to final path
* @param (HACK) pMsgFrame: CMsgFrame, used to check if cmdl, compiler tab
* @param (HACK) pDoc: CMsgDoc, used to check if cmdl, compiler tab
* may still be a (project) relative path on exit.
* @see -
*/
static void GetCDInfo(int iLine, CEdit& editCtrl, CString& sFile, CMsgFrame* pMsgFrame, CMsgDoc* pDoc)
{
int nLen;
const TCHAR* pszDir;
TCHAR buffer[2*MAX_PATH];
if(FC_StringIsAbsPath(sFile))
return;
if(iLine >= editCtrl.GetLineCount())
return;
//feature only for compiler tab (HACK):
ASSERT (pMsgFrame != NULL);
if (!pMsgFrame)
return;
int iIndex=-1;
pMsgFrame->m_tabWnd.GetActiveTab(iIndex);
if(!pDoc || iIndex<0 || iIndex >= pDoc->m_arrMsgData.GetSize())
{
ASSERT (!"bad pDoc, iIndex");
return;
}
MSG_VIEWER_TYPE msgTyp = pDoc->m_arrMsgData[iIndex].m_MsgViewerType;
if(msgTyp != MSG_CmdLineMsgViewer && msgTyp != MSG_CompileMsgViewer)
return;
while(iLine>=0)
{
nLen = editCtrl.GetLine(iLine, buffer, FC_ARRAY_LEN(buffer)-10);
iLine--;
if(nLen<=0)
continue;
buffer[nLen] = 0;//<-needed ?
FC_StringTrim(buffer);
if((pszDir = IsLineCDInfo(buffer)) != NULL)
{
if(!*pszDir)
break;//cd $(prjdir): don't prepend default prj dir as an abs path to sFile
//all other rel or abs cd commands must be prepended:
sFile.Insert(0, '\\');
sFile.Insert(0, pszDir);
//if is abs must stop here:
if(FC_StringIsAbsPath(pszDir))
break;
}
}
}
示例4: atoi
void
mfc_goto::OnOK()
{
CEdit *ce = (CEdit *)GetDlgItem(IDC_GOTO_LINE);
char line[16];
int n = ce->GetLine(0, line, 12);
if (n>0) {
line[n] = '\0';
n = atoi(line)-1;
if (n < 0) n = 0;
n = view->GetRichEditCtrl().LineIndex(n);
view->GetRichEditCtrl().SetSel(n,n);
}
CDialog::OnOK();
}
示例5: PyWinObject_FromTCHAR
// @pymethod int|PyCEdit|GetLine|Returns the text in a specified line.
static PyObject *
PyCEdit_get_line(PyObject *self, PyObject *args)
{
CEdit *pEdit = GetEditCtrl(self);
if (!pEdit)
return NULL;
GUI_BGN_SAVE;
int lineNo = pEdit->LineFromChar();
GUI_END_SAVE;
// @pyparm int|lineNo|current|Contains the zero-based index value for the desired line.
// @comm This function is not an MFC wrapper.
if (!PyArg_ParseTuple(args, "|i:GetLine", &lineNo))
return NULL;
int size = 1024; // ahhhhh-this fails with 128, even when line len==4!
// god damn it - try and write a fairly efficient normal case,
// and handle worst case, and look what happens!
CString csBuffer; // use dynamic mem for buffer
TCHAR *buf;
int bytesCopied;
// this TRACE _always_ returns the length of the first line - hence the
// convaluted code below.
// TRACE("LineLength for line %d is %d\n", lineNo, pView->GetEditCtrl().LineLength(lineNo));
// loop if buffer too small, increasing each time.
while (size<0x7FFF) // reasonable line size max? - maxuint on 16 bit.
{
buf = csBuffer.GetBufferSetLength(size);
if (buf==NULL)
RETURN_ERR("Out of memory getting Edit control line value");
GUI_BGN_SAVE;
bytesCopied = pEdit->GetLine(lineNo, buf, size);
GUI_END_SAVE;
if (bytesCopied!=size) // ok - get out.
break;
// buffer too small
size += size; // try doubling!
TRACE0("Doubling buffer for GetLine value\n");
}
if (bytesCopied==size) // hit max.
--bytesCopied; // so NULL doesnt overshoot.
if (buf[bytesCopied-1]=='\r' || buf[bytesCopied-1]=='\n') // kill newlines.
--bytesCopied;
buf[bytesCopied] = '\0';
return PyWinObject_FromTCHAR(buf);
}
示例6: showlog
void CLogView::showlog(WPARAM wParam, LPARAM lParam)
{
UINT nlength = (UINT)wParam;
CString log =(char*)lParam;
char tmpstr[100];
CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDIT1);
UpdateData(TRUE);
m_log+=log;
if (m_log.GetLength()>2048)
{
m_log = m_log.Right(1024);//先去掉512字节
UpdateData(FALSE);
pEdit->GetLine(0,tmpstr,100);
int nlength = strlen(tmpstr); //得到可能乱码的长度
m_log = m_log.Right(1024-nlength);//去掉nlength长度
}
UpdateData(FALSE);
pEdit->LineScroll(pEdit->GetLineCount(),0);
delete (char*)lParam;
lParam =NULL;
}