Click here to Skip to main content
15,886,722 members
Articles / Desktop Programming / MFC

2D LUA Based Robot Simulator

Rate me:
Please Sign up or sign in to vote.
4.89/5 (26 votes)
14 Apr 2014Public Domain9 min read 130.8K   7.9K   119  
An article on designing your own robot simulator
// LogDlg.cpp : implementation file
//

#include "stdafx.h"
#include "NICE.h"
#include "LogDlg.h"


// CLogDlg dialog

IMPLEMENT_DYNAMIC(CLogDlg, CDialog)

CLogDlg::CLogDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CLogDlg::IDD, pParent)
{
	AfxInitRichEdit2();
}

CLogDlg::~CLogDlg()
{
}

void CLogDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_RICHEDITLOG, m_ctrlLog);
}


BEGIN_MESSAGE_MAP(CLogDlg, CDialog)
	ON_COMMAND(IDC_BUTTON_CLEAR, CLogDlg::OnClear)
END_MESSAGE_MAP()


// CLogDlg message handlers
int CLogDlg::AppendToLog(CString str, COLORREF color)
{
  int nOldLines = 0, nNewLines = 0, nScroll = 0;
  long nInsertionPoint = 0;
  CHARFORMAT cf;
  // Save number of lines before insertion of new text

  nOldLines = m_ctrlLog.GetLineCount();
  // Initialize character format structure

  cf.cbSize = sizeof(CHARFORMAT);
  cf.dwMask = CFM_COLOR;
  cf.dwEffects = 0; // To disable CFE_AUTOCOLOR

  cf.crTextColor = color;
  // Set insertion point to end of text

  nInsertionPoint = m_ctrlLog.GetWindowTextLength();
  m_ctrlLog.SetSel(nInsertionPoint, -1);
  // Set the character format

  m_ctrlLog.SetSelectionCharFormat(cf);
  // Replace selection. Because we have nothing 

  // selected, this will simply insert

  // the string at the current caret position.

  m_ctrlLog.ReplaceSel(str);
  // Get new line count

  nNewLines = m_ctrlLog.GetLineCount();
  // Scroll by the number of lines just inserted

  nScroll = nNewLines - nOldLines;
  m_ctrlLog.LineScroll(nScroll);
  return 0;
}

void CLogDlg::OnClear()
{

}

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.

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication


Written By
Student
Indonesia Indonesia
http://kataauralius.com/

Comments and Discussions