数字小键盘练习软件的设计与实现
本文适合中级读者阅读 作者:guoguo 来源:vclover.com 日期: 2008/02/19 浏览:
简捷有效的小键盘指法练习软件,现提供软件和源码下载。
小键盘数字键练习工具,程序小巧实用。每次随机产生10~25个数字,只能接受小键盘的数字键输入。输入完成后按回车即产生新的一组数字。程序带有计时,计速度的功能,可以作为你练习小键盘数字键的辅助工具。
打开程序后,直接敲击回车就可以开始计时了,请使用小键盘来输入数字!软件只能接受小键盘的数字按键和回车键,其他按键不响应。
欢迎使用郭郭的小作品。本软件是VC爱好者原创作品,转载请注明出处!
关于源代码:
本程序的源代码很简洁。在VC++6.0环境下开发,使用了三个类来制作文字的颜色效果和超链接效果。
CHyperLink类,用来设置超链接:
折叠C/C++ Code复制下面的内容
- /*www.vclover.com VC-爱好者vc_Lover_Com*/
- class CHyperLink : public CStatic
- {
- // Construction/destruction
- public:
- CHyperLink();
- virtual ~CHyperLink();
- public:
- enum UnderLineOptions { ulHover = -1, ulNone = 0, ulAlways = 1};
- // Attributes
- public:
- void SetURL(CString strURL);
- CString GetURL() const;
- void SetColours(COLORREF crLinkColour, COLORREF crVisitedColour,
- COLORREF crHoverColour = -1);
- COLORREF GetLinkColour() const;
- COLORREF GetVisitedColour() const;
- COLORREF GetHoverColour() const;
- void SetVisited(BOOL bVisited = TRUE);
- BOOL GetVisited() const;
- void SetLinkCursor(HCURSOR hCursor);
- HCURSOR GetLinkCursor() const;
- void SetUnderline(int nUnderline = ulHover);
- int GetUnderline() const;
- void SetAutoSize(BOOL bAutoSize = TRUE);
- BOOL GetAutoSize() const;
- // Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CHyperLink)
- public:
- virtual BOOL PreTranslateMessage(MSG* pMsg);
- virtual BOOL DestroyWindow();
- protected:
- virtual void PreSubclassWindow();
- //}}AFX_VIRTUAL
- // Implementation
- protected:
- HINSTANCE GotoURL(LPCTSTR url, int showcmd);
- void ReportError(int nError);
- LONG GetRegKey(HKEY key, LPCTSTR subkey, LPTSTR retdata);
- void PositionWindow();
- void SetDefaultCursor();
- // Protected attributes
- protected:
- COLORREF m_crLinkColour, m_crVisitedColour; // Hyperlink colours
- COLORREF m_crHoverColour; // Hover colour
- BOOL m_bOverControl; // cursor over control?
- BOOL m_bVisited; // Has it been visited?
- int m_nUnderline; // underline hyperlink?
- BOOL m_bAdjustToFit; // Adjust window size to fit text?
- CString m_strURL; // hyperlink URL
- CFont m_UnderlineFont; // Font for underline display
- CFont m_StdFont; // Standard font
- HCURSOR m_hLinkCursor; // Cursor for hyperlink
- CToolTipCtrl m_ToolTip; // The tooltip
- UINT m_nTimerID;
- // Generated message map functions
- protected:
- //{{AFX_MSG(CHyperLink)
- afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
- afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
- afx_msg void OnTimer(UINT nIDEvent);
- afx_msg BOOL OnEraseBkgnd(CDC* pDC);
- //}}AFX_MSG
- afx_msg void OnClicked();
- DECLARE_MESSAGE_MAP()
- };
CFontEdit类,用来设置文本框中字体的样式:
折叠C/C++ Code复制下面的内容
- /*www.vclover.com VC 爱好者vc lover_com*/
- class CFontEdit : public CEdit
- {
- // Construction
- public:
- CFontEdit();
- // Attributes
- public:
- bool m_bBold;
- bool m_bItalic;
- bool m_bUnderlined;
- bool m_bStrikethrough;
- bool m_bAntialias;
- bool m_bBgColor;
- bool m_bCenter;
- bool m_bLeft;
- bool m_bRight;
- CString m_szFont;
- DWORD m_dwColor;
- DWORD m_dwBgColor;
- int m_nSize;
- //new
- CBrush m_brBkgnd;
- DWORD m_rBgColor; //readonly
- DWORD m_oBgColor;
- UINT unFormat;//对齐格式
- CFont fFont;
- // Operations
- public:
- // Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CFontEdit)
- protected:
- virtual void PreSubclassWindow();
- //}}AFX_VIRTUAL
- // Implementation
- public:
- void SetFontStyle(DWORD dwStyle);
- void SetBackground(DWORD dwBgColor);
- void SetFontEdit(CString szFont, int nSize, DWORD dwColor=RGB(0,0,0), DWORD dwStyle=FS_NORMAL);
- BOOL SetReadOnly(BOOL flag);
- virtual ~CFontEdit();
- // Generated message map functions
- protected:
- //{{AFX_MSG(CFontEdit)
- afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor); // This Function Gets Called Every Time Your Window Gets Redrawn.
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
CFontStatic类是用来设置Static控件的字体属性。 具体的源码可以下载参考!!

上一篇:没有了 下一篇:没有了
相关文章
查看全部评论相关评论
What's New?
What's Hot?
Google Adsense!