// Greg Stitt, Ann Gordon-Ross // RotateDlg.cpp : implementation file // #include "stdafx.h" #include "vahid.h" #include "RotateDlg.h" #define LCD_SIZE 16 #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CRotateDlg dialog CRotateDlg::CRotateDlg(CWnd* pParent /*=NULL*/) : CDialog(CRotateDlg::IDD, pParent) { char_counter = 0; //{{AFX_DATA_INIT(CRotateDlg) m_nSpeed = 0; //}}AFX_DATA_INIT } void CRotateDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CRotateDlg) DDX_Text(pDX, IDC_EDITSPEED, m_nSpeed); DDV_MinMaxInt(pDX, m_nSpeed, 1, 10); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CRotateDlg, CDialog) //{{AFX_MSG_MAP(CRotateDlg) ON_WM_TIMER() ON_WM_VSCROLL() //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CRotateDlg message handlers BOOL CRotateDlg::OnInitDialog() { m_rich = (CRichEditCtrl*) GetDlgItem(IDC_RICHEDIT_PREVIEW); // set spin range CSpinButtonCtrl* spin = (CSpinButtonCtrl*) GetDlgItem(IDC_SPINSPEED); CEdit* edit = (CEdit*) GetDlgItem(IDC_EDITSPEED); spin->SetRange(1,10); spin->SetPos(m_nSpeed); // fills in extra space in preview text CString temp; for (int i = 0; i < LCD_SIZE; i ++) temp += " "; preview_text = temp + preview_text; // create and change font CHARFORMAT cf; cf.cbSize = sizeof(CHARFORMAT); cf.dwMask = CFM_BOLD | CFM_FACE | CFM_SIZE; cf.dwEffects = CFE_BOLD; cf.yHeight = 14 * 20; strcpy(cf.szFaceName, "Courier"); cf.bCharSet = 0; cf.bPitchAndFamily = 0; m_rich->SetDefaultCharFormat(cf); CDialog::OnInitDialog(); // TODO: Add extra initialization here SetTimer(1, 100 * m_nSpeed, NULL); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CRotateDlg::OnTimer(UINT nIDEvent) { // rotates text m_rich->SetWindowText(preview_text.Mid(char_counter, char_counter + LCD_SIZE)); char_counter = char_counter < preview_text.GetLength() ? char_counter + 1 : 0; } // changes the rotate speed when the scroll bar is used void CRotateDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) { m_nSpeed = ((CSpinButtonCtrl*) pScrollBar)->GetPos(); SetTimer(1, 100 * m_nSpeed, NULL); }