Solved

Two CEditView questions...

Posted on 1998-01-13
4
356 Views
Last Modified: 2013-11-20
First question:
How can i display text lines(like in devstudio debug window) in a CEditView derived window quickly and simply? code avaliable?
Second question:
How can i make a full line selection function with the SetSel member function(How can i find the starting and ending char)

Thanx in advance.
Mário Guedes
0
Comment
Question by:mguedes
  • 2
4 Comments
 

Expert Comment

by:gurushree
ID: 1313957
First Question:

I guess u want to display something like a file in the EditView.
{
    CStdioFile file;
  BOOL bOpenOK = file.Open( sFileName,
                    CFile::modeRead );
if (FALSE == bOpenOK)
{
            .....
            return ;
};
fileOut.ReadString( sLine );
while(fileOut.ReadString( sLine ))
{
source += sLine + "\r\n";
}
fileOut.Close();
}

In InitialUpdate of EditView, do the following,
{
 GetEditCtrl().SetWindowText(source);
}


Second Question:
 i am assuming that u know the line no., if not get the line number using,
int nLine_no = GetEditCtrl().LineFromChar(-1) // i.e get the line no, for the                                                                                                                                                                                // current cursor  position

int nStartIndex = GetEditCtrl().LineIndex(nLine_no);
int nCnt = GetEditCtrl().GetLine(nLine_no, (LPCTSTR)buffer);
// Now select the whole line
GetEditCtrl().SetSel(nStartIndex, nStartIndex + (strlen) buffer);




0
 

Author Comment

by:mguedes
ID: 1313958
I'm very sorry if you don´t understand my first question.I want display text lines while i´m execute some operation(like in devstudio debug window). Do you no if there is anyway to "send" one line of text to my CEditview window.
Thanx anyway for your response to my second question.
0
 
LVL 4

Accepted Solution

by:
jtwine100697 earned 10 total points
ID: 1313959
  If I understand the first part right, you are trying to make a status display, and just add lines to it as some operation progresses, all you need to to is do a CEditCtrl::SetSel(...) to place the caret at the end of the text, and then a CEditCtrl::ReplaceSel(...) with the text you want to add (use CEditView::GetEditCtrl() to gain a reference to the CEditView's Edit Control).

For Example:

   int         iTextLen = 0;
   CEditCtrl   &ecEdit = CEditView::GetEditCtrl();

   iTextLen = ecEdit.GetWindowTextLength();
   ecEdit.SetSel( iTextLen, iTextLen );
   ecEdit.ReplaceSel( "This Text Will Be Added\r\n" );

-=- James.

0
 

Author Comment

by:mguedes
ID: 1313960
Thank´s you for help me James. If you are any problem that i can help´s mail me.

Mário Guedes

mguedes@utad.pt
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question