Solved

Two CEditView questions...

Posted on 1998-01-13
4
352 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Is it possible to combine several text files into one big one? (redhat v5 enterprise) 4 92
Replacement selected text 2 61
sumHeights  challenge 17 70
Message not shown 5 50
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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 …
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.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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