?? masked_edit3.shtml.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">
<h3 align="center"><font color="#aoao99">masked edit control (3) </font></h3>
<hr>
<!-- author and contact details -->
<p>this article was contributed by <a href="mailto:jeff@scriptpro.com">jeff knight</a>. <!-- sample image - gif or jpg --> </p>
<p><img src="masked_edit3_1.jpg"
tppabs="http://www.codeguru.com/editctrl/masked_edit3_1.jpg" width="225" height="150"> </p>
<p><img src="masked_edit3_2.jpg"
tppabs="http://www.codeguru.com/editctrl/masked_edit3_2.jpg" width="225" height="150"> <!-- text / source code --> </p>
<p><!-- the 'p' starts a paragraph of normal text --> we had been using the msmask.ocx control in our mfc application for almost a year.
recently a 200k memory leak was traced to the settext method (200k each time it was
called), so we downloaded another masked edit class from the web, but it flickered
intensely and the code was kind of icky. anyway, i decided to write my own. turns out it
works better than i could have hoped. it's easy to use and the source code very simple
allowing anyone to extend it as necessary. </p>
<p><b>in ::oninitdialog()</b> <!-- start a block of source code --> </p>
<pre><tt><font color="#990000">
m_maskedit.subclassdlgitem(idc_edit_mask, this);
// initialize the control to "state: ks, zip: 66202-1234"
m_maskedit.setmask("state: ??, zip: #####-####");
m_maskedit.settext("ks662021234");
<!-- end the block of source code -->
</font></tt></pre>
<b>
<p>in ::onok()</b> </p>
<p><!-- start a block of source code --> </p>
<pre><tt><font color="#990000">
// gettext returns "ks66202123"
cstring strtemp = m_maskedit.gettext();
// getwindowtext yields "state: ks, zip: 66202-1234"
m_maskedit.getwindowtext(strtemp);
<!-- end the block of source code -->
</font></tt></pre>
<!-- create more blocks of article text as needed -->
<!-- create more blocks of source code as needed -->
<!-- demo project -->
<p><a href="masked_edit3_demo.zip"
tppabs="http://www.codeguru.com/editctrl/masked_edit3_demo.zip">download demo project -
[17] kb</a> <!-- zipped source --> </p>
<p><a href="masked_edit3_src.zip"
tppabs="http://www.codeguru.com/editctrl/masked_edit3_src.zip">download source - [2] kb</a>
<!--comments--></p>
</body>
</html>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -