|
// sockDoc.cpp : implementation of the CSockDoc class
//
#include "stdafx.h"
#include "sock.h"
#include "sockDoc.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSockDoc
IMPLEMENT_DYNCREATE(CSockDoc, CDocument)
BEGIN_MESSAGE_MAP(CSockDoc, CDocument)
//{{AFX_MSG_MAP(CSockDoc)
ON_UPDATE_COMMAND_UI(ID_VIEW_SCROLL, OnUpdateViewScroll)
ON_COMMAND(ID_VIEW_SCROLL, OnViewScroll)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSockDoc construction/destruction
CSockDoc::CSockDoc()
{
m_bScroll=TRUE;
}
CSockDoc::~CSockDoc()
{
}
BOOL CSockDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CSockDoc serialization
void CSockDoc::Serialize(CArchive& ar)
{
// CEditView contains an edit control which handles all serialization
((CEditView*)m_viewList.GetHead())->SerializeRaw(ar);
}
/////////////////////////////////////////////////////////////////////////////
// CSockDoc diagnostics
#ifdef _DEBUG
void CSockDoc::AssertValid() const
{
CDocument::AssertValid();
}
void CSockDoc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CSockDoc commands
void CSockDoc::AddMessage(CString &szMessage)
{
POSITION pos=GetFirstViewPosition();
CSockView *pView=(CSockView *)GetNextView(pos);
ASSERT_VALID(pView);
CString szMan;
pView->GetEditCtrl().GetWindowText(szMan);
szMan+=szMessage;
szMan+=_T("\r\n");
int x=pView->GetEditCtrl().GetFirstVisibleLine();
pView->GetEditCtrl().SetWindowText(szMan);
pView->GetEditCtrl().LineScroll(m_bScroll ? pView->
GetEditCtrl().GetLineCount() : x);
SetModifiedFlag();
}
void CSockDoc::OnUpdateViewScroll(CCmdUI* pCmdUI)
{
pCmdUI->SetCheck(m_bScroll);
}
void CSockDoc::OnViewScroll()
{
m_bScroll=m_bScroll ? FALSE : TRUE;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.