Re: CEdit ampersand character handling
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Mon, 30 Jun 2008 16:57:42 -0400
Yes, this is a standard trick. But as you observed, you need to DrawText with the right
flags. When the cell loses focus, the edit control is destroyed (or at least hidden) and
a simple static drawing is used; this eliminates the need to have thousands of windows
around to handle every single cell.
joe
On Mon, 30 Jun 2008 12:44:15 -0700, gi-m <gim@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
The class doing the DrawText is not derived from the CEdit. It is the classJoseph M. Newcomer [MVP]
that creates the CEdit control and uses it to fill in a list of text items
(like you guessed in a 2 dimensional grid). So the DrawText call is used when
re-drawing the list after the user changed one of the text items. I just made
the mistaken assumption that the CEdit control is the one doing the drawing
of the text, even after the cell being edited lost focus.
I see I came to the right place to ask my question. Thank you very much for
your help and comments.
Regards, gi-m
"Joseph M. Newcomer" wrote:
It's very suspect that a class that derives from CEdit is using DrawText. This is likely
to produce many more different manifestations of bugs. Generally, any attempt to
circumvent what CEdit does is dangerous. Unless this is some kind of grid control that
actually only has one active window at a time.
joe
On Sun, 29 Jun 2008 06:28:00 -0700, gi-m <gim@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
Thank you for your response. You answered my question. It also explains whyJoseph M. Newcomer [MVP]
no one else complained about this.
I am debugging someone elses application and saw the behavior I described in
my question when editing text using a CEdit control. I assumed it was the
CEdit control (or more accurately the CWnd base class) that was doing the
drawing of the text when the control lost focus (after the user entered or
edited some text). After you clarified that the CEdit control doesn't do
anything special with the &, I realized that it must be the application that
is doing the drawing of the text after the CEdit control is done with it. So
it only took a few minutes to find the DrawText call in the class that
creates and uses the CEdit control,and sure enough it did not have the
DT_NOPREFIX flag set. I changed it and now the text is displayed correctly,
without any special processing of the &.
Thank you for your help.
gi-m
PS: I am using Visual Studio C++ 6.0.
"Joseph M. Newcomer" wrote:
Edit controls should do nothing special with &. Can you say more about the app? Which
version of VS, which version of WIndows. etc.
joe
On Sat, 28 Jun 2008 19:18:01 -0700, gi-m <gim@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I need to modify a CEdit control to handle the ampersand character like anyJoseph M. Newcomer [MVP]
other character (no special handling). Something equivalent to SS_NOPREFIX on
static controls (or DT_NOPREFIX in a DrawText call). It seems that when the
edit control has focus, the displayed text shows the ampersand as is. When
the control loses focus, the & is interpreted as an accelerator prefix and
shows as an underline of the next character, so changing single ampersand to
double ampersand will show ok when the control does not have focus but is
changed to double ampersand when the edit control gets focus. I would rather
not have to tell the user that he has to type in a double ampersand to get
one (from his point of view there is not reason why he should have to do
that). I did a lot of searching around and was suprised that no one else
seems to have needed to do this ? Any ideas on how to disable the special
processing of the ampersand in a CEdit control ?
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- References:
- Re: CEdit ampersand character handling
- From: Joseph M . Newcomer
- Re: CEdit ampersand character handling
- From: gi-m
- Re: CEdit ampersand character handling
- From: Joseph M . Newcomer
- Re: CEdit ampersand character handling
- From: gi-m
- Re: CEdit ampersand character handling
- Prev by Date: Re: how to store list of varying types
- Next by Date: Re: how to store list of varying types
- Previous by thread: Re: CEdit ampersand character handling
- Next by thread: CAsyncSocket - Connected or not?
- Index(es):
Relevant Pages
|