?? mixededit.shtml.htm
字號(hào):
<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">mixed case edit control </font></h3>
<hr>
<!-- author and contact details -->
<p>this article was contributed by <a href="mailto:jmd@jvf.co.uk">jeremy davis</a>. <!-- sample image - gif or jpg --> <!-- <p><img src="[image filename here]" tppabs="http://www.codeguru.com/editctrl/%5bimage filename here%5d" > --> <!-- environment eg nt 4.0 sp3, vc6.0 sp1 --> <!-- <p><u>environment:</u> ****** --> <!-- text / source code --> </p>
<p><!-- the 'p' starts a paragraph of normal text --> </p>
<p>the vc++ dialog editor allows you to have "any", "lower", and
"upper" case characters typed into a ceditctrl. a user of one of my apps
commented that the displaying of some ceditctrl data looked untidy, they were either lower
or upper case, or even a mixture of the two cases. what was required was an an edit box
that would force the left most character typed into it to upper case. if for example,
e-d-i-t were to be typed, the edit box would interpret and display it as e-d-i-t. this was
very easy to do by sub-classing ceditctrl and monitoring all wm_char messages in
pretranslatemessage. one should not however if the characters were to be typed into the
edit control, and the first character then deleted, the old second character will not
automatically become upper case. i did not require this within the cmyeditctrl class,
however perhaps could be a exercise for someone else.</p>
<p>to use :
<ul>
<li>#include "myeditctrl.h" in the header file of the file that you wish to use it
in.</li>
<li>add myeditctrl.cpp and myeditctrl.h to your project workspace</li>
<li>create an edit box in the dialog editor.</li>
<li>create a cmyeditctrl variable in class wizard for the edit box.</li>
</ul>
<!-- start a block of source code -->
<pre><font color="#990000"><tt>
// myeditctrl.cpp : implementation file
//
#include "stdafx.h"
#include "myeditctrl.h"
#ifdef _debug
#define new debug_new
#undef this_file
static char this_file[] = __file__;
#endif
/////////////////////////////////////////////////////////////////////////////
// cmyeditctrl
cmyeditctrl::cmyeditctrl()
{
}
cmyeditctrl::~cmyeditctrl()
{
}
begin_message_map(cmyeditctrl, cedit)
//{{afx_msg_map(cmyeditctrl)
//}}afx_msg_map
end_message_map()
/////////////////////////////////////////////////////////////////////////////
// cmyeditctrl message handlers
bool cmyeditctrl::pretranslatemessage(msg* pmsg)
{
// todo: add your specialized code here and/or call the base class
if (pmsg->message == wm_char)
{
int start, end;
getsel(start, end);
if (start == 0)
pmsg->wparam = toupper(pmsg->wparam);
}
return cedit::pretranslatemessage(pmsg);
}
</tt></font>
<!-- end the block of source code -->
</pre>
<!-- start a block of source code -->
<pre><tt><font color="#990000">
// myeditctrl.h : header file
//
#if !defined(afx_myeditctrl_h__77b0f921_463a_11d2_be76_0080adb7f1bb__included_)
#define afx_myeditctrl_h__77b0f921_463a_11d2_be76_0080adb7f1bb__included_
#if _msc_ver >= 1000
#pragma once
#endif // _msc_ver >= 1000
/////////////////////////////////////////////////////////////////////////////
// cmyeditctrl window
class cmyeditctrl : public cedit
{
// construction
public:
cmyeditctrl();
// attributes
public:
// operations
public:
// overrides
// classwizard generated virtual function overrides
//{{afx_virtual(cmyeditctrl)
public:
virtual bool pretranslatemessage(msg* pmsg);
//}}afx_virtual
// implementation
public:
virtual ~cmyeditctrl();
// generated message map functions
protected:
//{{afx_msg(cmyeditctrl)
//}}afx_msg
declare_message_map()
};
/////////////////////////////////////////////////////////////////////////////
//{{afx_insert_location}}
// microsoft developer studio will insert additional declarations immediately before
previous line.
#endif // !defined(afx_myeditctrl_h__77b0f921_463a_11d2_be76_0080adb7f1bb__included_)
<!-- end the block of source code -->
</font></tt></pre>
<!-- demo project -->
<!-- <p><a href="../../tppmsgs/msgs0.htm#81" tppabs="http://www.codeguru.com/editctrl/%5bdemo project zip file name here%5d">download demo project - [size in kb] kb</a> -->
<!-- zipped source -->
<!-- <p><a href="../../tppmsgs/msgs0.htm#82" tppabs="http://www.codeguru.com/editctrl/%5bsource code zip file name here%5d">download source - [size in kb] kb</a> -->
<!-- posted / update date month day, year (eg august 11, 1998) - add to the list -->
<p>date posted: december 10, 1998 </p>
</body>
</html>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -