当前位置:VC爱好者用户界面编程Other (其他界面编程) → 正文
数字小键盘练习软件的设计与实现
本文适合中级读者阅读  作者:guoguo    来源:vclover.com    日期: 2008/02/19    浏览:

       简捷有效的小键盘指法练习软件,现提供软件和源码下载。
      小键盘数字键练习工具,程序小巧实用。每次随机产生10~25个数字,只能接受小键盘的数字键输入。输入完成后按回车即产生新的一组数字。程序带有计时,计速度的功能,可以作为你练习小键盘数字键的辅助工具。

    打开程序后,直接敲击回车就可以开始计时了,请使用小键盘来输入数字!软件只能接受小键盘的数字按键和回车键,其他按键不响应。

欢迎使用郭郭的小作品。本软件是VC爱好者原创作品,转载请注明出处!

关于源代码:

本程序的源代码很简洁。在VC++6.0环境下开发,使用了三个类来制作文字的颜色效果和超链接效果。

CHyperLink类,用来设置超链接:

折叠C/C++ Code复制下面的内容
  1. /*www.vclover.com VC-爱好者vc_Lover_Com*/  
  2. class CHyperLink : public CStatic   
  3. {   
  4. // Construction/destruction   
  5. public:   
  6.     CHyperLink();   
  7.     virtual ~CHyperLink();   
  8.   
  9. public:   
  10.     enum UnderLineOptions { ulHover = -1, ulNone = 0, ulAlways = 1};   
  11.   
  12. // Attributes   
  13. public:   
  14.     void SetURL(CString strURL);   
  15.     CString GetURL() const;   
  16.   
  17.     void SetColours(COLORREF crLinkColour, COLORREF crVisitedColour,    
  18.                     COLORREF crHoverColour = -1);   
  19.     COLORREF GetLinkColour() const;   
  20.     COLORREF GetVisitedColour() const;   
  21.     COLORREF GetHoverColour() const;   
  22.   
  23.     void SetVisited(BOOL bVisited = TRUE);   
  24.     BOOL GetVisited() const;   
  25.   
  26.     void SetLinkCursor(HCURSOR hCursor);   
  27.     HCURSOR GetLinkCursor() const;   
  28.   
  29.     void SetUnderline(int nUnderline = ulHover);   
  30.     int  GetUnderline() const;   
  31.   
  32.     void SetAutoSize(BOOL bAutoSize = TRUE);   
  33.     BOOL GetAutoSize() const;   
  34.   
  35. // Overrides   
  36.     // ClassWizard generated virtual function overrides   
  37.     //{{AFX_VIRTUAL(CHyperLink)   
  38.     public:   
  39.     virtual BOOL PreTranslateMessage(MSG* pMsg);   
  40.     virtual BOOL DestroyWindow();   
  41.     protected:   
  42.     virtual void PreSubclassWindow();   
  43.     //}}AFX_VIRTUAL   
  44.   
  45. // Implementation   
  46. protected:   
  47.     HINSTANCE GotoURL(LPCTSTR url, int showcmd);   
  48.     void ReportError(int nError);   
  49.     LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata);   
  50.     void PositionWindow();   
  51.     void SetDefaultCursor();   
  52.   
  53. // Protected attributes   
  54. protected:   
  55.     COLORREF m_crLinkColour, m_crVisitedColour;     // Hyperlink colours   
  56.     COLORREF m_crHoverColour;                       // Hover colour   
  57.     BOOL     m_bOverControl;                        // cursor over control?   
  58.     BOOL     m_bVisited;                            // Has it been visited?   
  59.     int      m_nUnderline;                          // underline hyperlink?   
  60.     BOOL     m_bAdjustToFit;                        // Adjust window size to fit text?   
  61.     CString  m_strURL;                              // hyperlink URL   
  62.     CFont    m_UnderlineFont;                       // Font for underline display   
  63.     CFont    m_StdFont;                             // Standard font   
  64.     HCURSOR  m_hLinkCursor;                         // Cursor for hyperlink   
  65.     CToolTipCtrl m_ToolTip;                         // The tooltip   
  66.     UINT     m_nTimerID;   
  67.   
  68.     // Generated message map functions   
  69. protected:   
  70.     //{{AFX_MSG(CHyperLink)   
  71.     afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);   
  72.     afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);   
  73.     afx_msg void OnMouseMove(UINT nFlags, CPoint point);   
  74.     afx_msg void OnTimer(UINT nIDEvent);   
  75.     afx_msg BOOL OnEraseBkgnd(CDC* pDC);   
  76.     //}}AFX_MSG   
  77.     afx_msg void OnClicked();   
  78.     DECLARE_MESSAGE_MAP()   
  79. };  

CFontEdit类,用来设置文本框中字体的样式:

折叠C/C++ Code复制下面的内容
  1. /*www.vclover.com VC 爱好者vc lover_com*/  
  2. class CFontEdit : public CEdit   
  3. {   
  4.   
  5. // Construction   
  6. public:   
  7.     CFontEdit();   
  8.   
  9. // Attributes   
  10. public:   
  11.   
  12.     bool m_bBold;   
  13.     bool m_bItalic;   
  14.     bool m_bUnderlined;   
  15.     bool m_bStrikethrough;   
  16.     bool m_bAntialias;   
  17.     bool m_bBgColor;   
  18.   
  19.     bool m_bCenter;   
  20.     bool m_bLeft;   
  21.     bool m_bRight;   
  22.   
  23.     CString m_szFont;   
  24.     DWORD m_dwColor;   
  25.     DWORD m_dwBgColor;   
  26.     int m_nSize;   
  27.   
  28.     //new   
  29.     CBrush m_brBkgnd;   
  30.     DWORD  m_rBgColor; //readonly   
  31.     DWORD  m_oBgColor;   
  32.     UINT   unFormat;//对齐格式   
  33.     CFont fFont;   
  34.   
  35. // Operations   
  36. public:   
  37.   
  38. // Overrides   
  39.     // ClassWizard generated virtual function overrides   
  40.     //{{AFX_VIRTUAL(CFontEdit)   
  41.     protected:   
  42.     virtual void PreSubclassWindow();   
  43.     //}}AFX_VIRTUAL   
  44.   
  45. // Implementation   
  46. public:   
  47.     void SetFontStyle(DWORD dwStyle);   
  48.     void SetBackground(DWORD dwBgColor);   
  49.     void SetFontEdit(CString szFont, int nSize, DWORD dwColor=RGB(0,0,0), DWORD dwStyle=FS_NORMAL);   
  50.     BOOL SetReadOnly(BOOL flag);   
  51.     virtual ~CFontEdit();   
  52.   
  53.     // Generated message map functions   
  54. protected:   
  55.     //{{AFX_MSG(CFontEdit)   
  56.     afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor); // This Function Gets Called Every Time Your Window Gets Redrawn.   
  57.     //}}AFX_MSG   
  58.   
  59.     DECLARE_MESSAGE_MAP()   
  60. };  

CFontStatic类是用来设置Static控件的字体属性。 具体的源码可以下载参考!!

上一篇:没有了   下一篇:没有了
相关文章
查看全部评论相关评论
评论内容:
昵称: 验证码:验证码
What's New?
What's Hot?
Google Adsense!