⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 masked_edit.shtml.htm

📁 一套比较全的编辑框控制教程。。。附源代码。
💻 HTM
字号:
<html>

<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<meta name="author" content="zafir anjum">
<title>edit controls - table of contents</title>
<meta name="description" content="source code for various windows controls">
<meta name="keywords" content="mfc source code edit controls">
</head>

<body background="../di2001.jpg"
tppabs="http://www.codeguru.com/fancyhome/back.gif" bgcolor="#ffffff">
<!-- article title -->

<h3 align="center"><font color="#aoao99">masked edit control </font></h3>

<hr align="center">
<!-- author and contact details -->

<p>this article was contributed by <a href="mailto:sam.claret@dial.pipex.com">sam claret</a>.
<!-- sample image and source code/demo project --></p>

<p><a href="masked_edit.zip" tppabs="http://www.codeguru.com/editctrl/masked_edit.zip">download
source code</a> </p>

<p><br>
<!-- the article... --></p>

<p>i got this masked edit control code from someone (i can't remember whom it was). if
anyone wishes to lay claim to the original they are more than welcome. i have found this
quite useful. so i can't lay claim to doing all or even most of this. however i have
enhanced the code to deal with times as well as dates. </p>

<p>i have also added validation of the keystrokes so that invalid times i.e. &gt; 23:59
are not allowed. (i have limited the time validation to minutes. it would be no great
effort to add in the seconds. validation for dates is a little more difficult. validation
is limited to months &lt; 13 and days &lt; 32. </p>

<p>i.e you can put in 31/02/1998 for example. </p>

<p>ok how to make it work. there are three classes 

<ul>
  <li>cmaskedit </li>
  <li>cdateedit </li>
  <li>ctimeedit </li>
</ul>

<p>include the two files masked.cpp and masked.h in your project. also include
&lt;afxdao.h&gt; for the coledatetime features if you already haven't. modify the include
line that says #include &quot;myproj&quot; to point to your project. create a cedit
control and declare a control variable in your dialog then modify the cedit declaration in
the class header to say either cdateedit or ctimeedit </p>

<h4>cdateedit:</h4>

<p>pass your time to cdateedit with <font color="#990000"><tt></p>

<pre>	cdateedit myeditctrl;
	myeditctrl.setdate(coledatetime var);
</tt></pre>
</font>

<p>and get the edited result back with <font color="#990000"><tt></p>

<pre>	coledatetime var = myeditctrl.getdate();
</tt></pre>
</font>

<h4>ctimeedit:</h4>

<p>pass your time to ctimeedit with <font color="#990000"><tt></p>

<pre>	ctimeedit myeditctrl;
	myeditctrl.settime(coledatetime var);
</tt></pre>
</font>

<p>and get the edited result back with <font color="#990000"><tt></p>

<pre>	coledatetime var = myeditctrl.gettime();
</tt></pre>
</font>

<p>and there you have it. </p>

<p>please feel free to modify any modifications i have made. these are stated with //added
this <!-- remember to update this --> </p>

<p>last updated: 15 may 1998 <!--comments--> </p>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -