《用C语言写的鼠标驱动程序》由会员分享,可在线阅读,更多相关《用C语言写的鼠标驱动程序(2页珍藏版)》请在金锄头文库上搜索。
1、文章来源:文章来源:程序运行效果截图:运行环境:VC7, VC6, XP, W2K, Win9X, Win95, NT4, MFC简介我想要这样一个控件,既包括标准 date picker 控件的功能,又能让用户任何时候都能自己输入日期。标准的 date picker 控件有其自己的实现自编辑日期的方法,但是这并没有达到我想要的。文档此控件基于微软的 CDateTimeCtrl 类,我使用了一些小技巧用我自己的编辑控件和按钮替换了标准的控件,但是处理类仍继承于 CDateTimeCtrl。为了实现这个功能,我销毁了已存在的窗口,并且创建了一个与类相关联的我自己的窗口。工作原理参看 CDateT
2、imeEditCtrl:OnRecreate。基于我的实现方法,这个控件的使用与标准的 CDateTimeCtrl 完全一样。在你的对话框资源中加入一个标准的 Date picker 控件,然后为其创建 CDateTimeEditCtrl 类型的成员变量。这个控件支持通常的 Date picker 风格,下面几个风格不支持:DTS_UPDOWN, DTS_SHOWNONE, DTS_APPCANPARSE, DTS_LONGDATEFORMAT, and DTS_TIMEFORMAT。消息传递与标准控件一样,但是不支持 DTM_GETRANGE, DTM_SETRANGE 和 DTM_SETF
3、ORMAT消息。控件中事件的通知与标准控件一样,发送给父窗口。一些额外的公有函数也被加入以提供更强的功能扩展,这些公有函数列表如下:BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);与 CDateTimeCtrl 功能类似.CEdit* GetEditControl() const;返回一个指向编辑控件的指针,通过这个指针可以直接处理它的属性。void EnableButton(BOOL bEnable = TRUE);允许或禁止用来下拉 calendar control 的按钮void Resto
4、reFocus(BOOL bRestore = TRUE);Determines the behaviour when clicking on the button. If TRUE then the control re-sets the focus back to the window whitch had the focus on clicking the button, else the focus is set to the edit control. If the control is not editable focus is always set back to the pre
5、viously focused window. The default is for the focus to be set to the edit control.void SetNonEditable(BOOL bNonEditable = TRUE);Used to make the edit portion of the control non-editable. The default is editable.BOOL GetNonEditable();Returns whether the edit control is currently editable.virtual BOO
6、L IsValidDate(LPCTSTR lpszDate = NULL);Returns whether the date string passed is valid. If lpszDate is NULL then it returns whether the text in the edit control is a valid date string.void SetValidCharsOnly(BOOL bValidCharsOnly = TRUE);Sets whether the user can only enter characters that are validBO
7、OL GetValidCharsOnly();Returns whether the user can only enter valid characters into the edit controlvoid SetValidChars(LPCTSTR lpszValidChars = NULL);Sets the characters that are valid for the user to type into the edit control. If NULL is specified, then the default characters are used (0-9 and th
8、e current users locales date separator). If the user changes the locale settings then the control will detect this and use the new separator.CString GetValidChars();Returns the characters that have been set as being valid for the user to type into the edit control文章来源:文章来源:void SetAllowUpDownKeys(BOOL bAllow = TRUE);Sets whether the up/down arrow keys will increment/decrement the part of the date string that contains the cursor.BOOL GetAllowUpDownKeys();Returns whether the up/down keys will increment/decrement parts of the date string.