How do I output text to my main SDI window ?
-
The documentation is pretty self-explanatory. Here's another example.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
You don't. It's passed as a parameter to the
OnDraw()
method.void CMyView::OnDraw( CDC *pDC )
{
pDC->TextOut(...);
}
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
You don't. It's passed as a parameter to the
OnDraw()
method.void CMyView::OnDraw( CDC *pDC )
{
pDC->TextOut(...);
}
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
Thanks for the info but I'm getting confused. I have a have a ClientSocket::OnReceive() method that reads a CString from a socket(). I want to print this CString directly to my SDI (CView) window. Do I call OnDraw() from this method ?? Thanks again !
You never call
OnDraw()
manually. It is called by the framework when drawing needs to take place. At this point, the framework is basically asking, "What do you want to draw?". It might be wise to read up on the relationship between the document and the view. In a nutshell, the document holds the data that the view renders, or to put it another way, the view renders the data that the document holds. So, when you receive data via a socket, the document needs to be updated with the received data. The document, in turn, tells the view that something has changed and that a redraw is needed.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
Thanks for the info but I'm getting confused. I have a have a ClientSocket::OnReceive() method that reads a CString from a socket(). I want to print this CString directly to my SDI (CView) window. Do I call OnDraw() from this method ?? Thanks again !
Derive your view from
CEditView
. Then, each time you want to append a line of text to the view, do this:CString strTextReadBySocket = ...;
CString strText;
myEditView.GetEditCtrl().GetWindowText (strText);
strText += _T("\r\n") + strTextReadBySocket;
myEditView.GetEditCtrl().SetWindowText (strText);/ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com
-
Derive your view from
CEditView
. Then, each time you want to append a line of text to the view, do this:CString strTextReadBySocket = ...;
CString strText;
myEditView.GetEditCtrl().GetWindowText (strText);
strText += _T("\r\n") + strTextReadBySocket;
myEditView.GetEditCtrl().SetWindowText (strText);/ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com
-
Ravi Thanks, this works but after a while of printing text to the window I get an Out of memory errors. Is there a limit to how much data can be written to the window ?? Thanks Gary
-
I increased by buffer size to 4096 when receiving data and the memory errors are gone. How can I get the cursor to stay at the bottom of the window ?? Thanks Gary
Gary, you might find it convenient to use a
CFormView
instead of aCEditView
and use my History Edit Control[^] class. Also, Joseph Newcomer has written an excellent Logging List Control[^] class. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com -
Derive your view from
CEditView
. Then, each time you want to append a line of text to the view, do this:CString strTextReadBySocket = ...;
CString strText;
myEditView.GetEditCtrl().GetWindowText (strText);
strText += _T("\r\n") + strTextReadBySocket;
myEditView.GetEditCtrl().SetWindowText (strText);/ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com
I am trying to subclass a CEditView in an sdi app and am having a few problems. Basically I have the above SetWindowText statment in a class which extends from CEdit. Now If I create a CEdit control at resource time and put it on a dialog and then call SubclassDlgItem everything is ok. However I would would really like to mimic the Visual Studio Output Window. What I did was to try and call SubClassWindow in my CEditView derived SDI view in the OnCreate Handler. However this fails and I read I need to Call SubClassDlgItem for the CEdit Dialog obtained by GetEditCtrl() which is defined in the CView. However how do I work out the resource id of the CEdit which is created in the CEditView? I guess if I Create a CEdit control dynamically on a CFormView I would know the resource ID. Basically I am trying to get a general debugging routine which I can attach to any CEdit or CEditView (Which is dynamically created). I would prefer this than a log window which is a separate window from my application. Regards, Axe,
-
I increased by buffer size to 4096 when receiving data and the memory errors are gone. How can I get the cursor to stay at the bottom of the window ?? Thanks Gary
// Scroll the edit view to the bottom
myEditView.LineScroll (myEditView.GetLineCount(), 0);/ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com