Solved

Two CEditView questions...

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

743 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now