CColorStaticST_demoDlg.cpp
上传用户:jnfxs888
上传日期:2021-02-24
资源大小:98k
文件大小:4k
源码类别:

Static控件

开发平台:

Visual C++

  1. // CColorStaticST_demoDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "CColorStaticST_demo.h"
  5. #include "CColorStaticST_demoDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CCColorStaticST_demoDlg dialog
  13. CCColorStaticST_demoDlg::CCColorStaticST_demoDlg(CWnd* pParent /*=NULL*/)
  14. : CDialog(CCColorStaticST_demoDlg::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CCColorStaticST_demoDlg)
  17. // NOTE: the ClassWizard will add member initialization here
  18. //}}AFX_DATA_INIT
  19. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  20. }
  21. void CCColorStaticST_demoDlg::DoDataExchange(CDataExchange* pDX)
  22. {
  23. CDialog::DoDataExchange(pDX);
  24. //{{AFX_DATA_MAP(CCColorStaticST_demoDlg)
  25. // NOTE: the ClassWizard will add DDX and DDV calls here
  26. //}}AFX_DATA_MAP
  27. }
  28. BEGIN_MESSAGE_MAP(CCColorStaticST_demoDlg, CDialog)
  29. //{{AFX_MSG_MAP(CCColorStaticST_demoDlg)
  30. ON_BN_CLICKED(IDB_ABOUT, OnAbout)
  31. //}}AFX_MSG_MAP
  32. ON_MESSAGE(WM_USER + 10, OnDangerBlink)
  33. END_MESSAGE_MAP()
  34. /////////////////////////////////////////////////////////////////////////////
  35. // CCColorStaticST_demoDlg message handlers
  36. BOOL CCColorStaticST_demoDlg::OnInitDialog()
  37. {
  38. CDialog::OnInitDialog();
  39. SetIcon(m_hIcon, TRUE); // Set big icon
  40. SetIcon(m_hIcon, FALSE); // Set small icon
  41. // Reset <Danger> blinks count
  42. m_nDangerCount = 0;
  43. // Create a font
  44. m_Font.CreateFont(-16, 0, 0, 0, FW_BOLD, FALSE, FALSE,0,0,0,0,0,0, "Verdana");
  45. // Create the colored <SoftechSoftware> sign
  46. m_stcSTSign.SubclassDlgItem(IDC_STSIGN, this);
  47. // Set the text color
  48. // Tooltip's foreground color
  49. m_stcSTSign.SetTextColor(::GetSysColor(COLOR_INFOTEXT));
  50. // Set the background color
  51. // Tooltip's background color
  52. m_stcSTSign.SetBkColor(::GetSysColor(COLOR_INFOBK));
  53. // Create the colored and blinking <Incoming call>
  54. m_stcCalling.SubclassDlgItem(IDC_CALLING, this);
  55. // Set background blinking colors
  56. // Medium and light green
  57. m_stcCalling.SetBlinkBkColors(RGB(0, 128, 0), RGB(0,255,0));
  58. // Start background blinking
  59. m_stcCalling.StartBkBlink(TRUE, CColorStaticST::ST_FLS_FAST);
  60. // Set text blinking colors
  61. // Medium green and black
  62. m_stcCalling.SetBlinkTextColors(m_stcCalling.GetBkColor(), RGB(0,0,0));
  63. // Start text blinking
  64. m_stcCalling.StartTextBlink(TRUE, CColorStaticST::ST_FLS_SLOW);
  65. // Create the colored and blinking <Danger>
  66. m_stcDanger.SubclassDlgItem(IDC_DANGER, this);
  67. // Set background blinking colors
  68. // Medium and light red
  69. m_stcDanger.SetBlinkBkColors(RGB(128, 0, 0), RGB(255,0,0));
  70. // Start background blinking
  71. m_stcDanger.StartBkBlink(TRUE, CColorStaticST::ST_FLS_FAST);
  72. // Set text blinking colors
  73. // Medium red and white
  74. m_stcDanger.SetBlinkTextColors(RGB(128,0,0), RGB(255,255,255));
  75. // Start text blinking
  76. m_stcDanger.StartTextBlink(TRUE, CColorStaticST::ST_FLS_FAST);
  77. // Set a special font
  78. m_stcDanger.SetFont(&m_Font);
  79. // We want be notified when the control blinks
  80. m_stcDanger.EnableNotify(this, WM_USER + 10);
  81. // Write class version
  82. CString sVersion;
  83. sVersion.Format("CColorStaticST v%s", CColorStaticST::GetVersionC());
  84. SetWindowText(sVersion);
  85. return TRUE;
  86. } // End of OnInitDialog
  87. // This function will be called each time the <Danger> control blinks
  88. // The notification is sent only on rising blinks (this means only when
  89. // the control goes light red)
  90. LRESULT CCColorStaticST_demoDlg::OnDangerBlink(WPARAM wParam, LPARAM lParam)
  91. {
  92. SetDlgItemInt(IDC_DANGERCOUNT, ++m_nDangerCount);
  93. return 0;
  94. } // End of OnDangerBlink
  95. void CCColorStaticST_demoDlg::OnAbout() 
  96. {
  97. CAboutDlg about;
  98. about.DoModal();
  99. } // End of OnAbout