TipsDialog.cpp
Upload User: zengj883
Upload Date: 2013-02-03
Package Size: 670k
Code Size: 2k
Development Platform:

C/C++

  1. // TipsDialog.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "ScrollerTest.h"
  5. #include "TipsDialog.h"
  6. // CTipsDialog dialog
  7. IMPLEMENT_DYNAMIC(CTipsDialog, CDialog)
  8. CTipsDialog::CTipsDialog(CWnd* pParent /*=NULL*/)
  9. : CDialog(CTipsDialog::IDD, pParent)
  10. {
  11. }
  12. CTipsDialog::~CTipsDialog()
  13. {
  14. }
  15. void CTipsDialog::DoDataExchange(CDataExchange* pDX)
  16. {
  17. CDialog::DoDataExchange(pDX);
  18. }
  19. BEGIN_MESSAGE_MAP(CTipsDialog, CDialog)
  20.    ON_COMMAND(1, SwitchTip)
  21. END_MESSAGE_MAP()
  22. // CTipsDialog message handlers
  23. BOOL CTipsDialog::OnInitDialog()
  24. {
  25.    CDialog::OnInitDialog();
  26.    m_scroller.SetFont("Microsoft Sans Serif", 10, FW_SEMIBOLD);
  27.    m_scroller.SetText("tHello!");
  28.    m_scroller.SetWrapping(FALSE);
  29.    // short messages, read while paused, not scrolling
  30.    // so scroll quickly and pause for a 6 secs.
  31.    m_scroller.SetScrollDelay(0);
  32.    m_scroller.SetScrollPause(6000);
  33. CRect rect;
  34. GetClientRect(&rect);
  35. m_scroller.Create(rect, this, WS_CHILD|WS_VISIBLE, 1);
  36.    return TRUE;  // return TRUE unless you set the focus to a control
  37.    // EXCEPTION: OCX Property Pages should return FALSE
  38. }
  39. void CTipsDialog::SwitchTip()
  40. {
  41.    static const CString astrTips[] = {
  42.       "This is an example of using CScrollerCtrl to present alternating messages.",
  43.       "All public methods except Create() can be called before or after creation.",
  44.       "Text shadows are displayed only when a pattern is set, and are a combination of the foreground and background colors.",
  45.       "I'm too lazy to think up any more tips.",
  46.       "nntt-o-"};
  47.    static const int nNumTips = sizeof(astrTips)/sizeof(CString);
  48.    static int nCurrentTip = 0;
  49.    m_scroller.SetText(astrTips[nCurrentTip%nNumTips]);
  50.    ++nCurrentTip;
  51. }