From: Peter on
I've got a windows app that was developed using the MFC framework. As my
app is started the user is presented with a form with some dialog boxes for
input. One of the input boxes is for a user to enter certain values such as
1,2,3,4-7,A,B

That works as expected, but my problem is if I want to enter a range of
letters such as A-d I'm able to enter the first char "A" but the only key
that responses after that is a comma. The hyphen doesn't work, so I have
to entered them in a comma separated for A,B,C,D. The strange part is
that for numbers I can do a range 1-10,11,12

Some how that control has a filter or mask setup. If I look the RC file the
name associated with that control is
#define IDC_MOD 1115

EDITTEXT IDC_MOD,7,49,348,21,ES_MULTILINE

Then ...

DDX_Control(pDX, IDC_MOD, m_ModStatusCtrl);

DDX_Text(pDX, IDC_MOD, m_MOD);

DDV_MaxChars(pDX, m_MOD, 156);

ON_EN_CHANGE(IDC_MOD, OnEnChangeMod)



Any ideas what I should be looking for? I not able to see anything that
explicitly won't allow a hyphen after a Char








From: JCO on
When you say dialog boxes, are you talking about an Editbox from the
Toolbox? If so, it is possible that the Editbox (type CEdit) has a
Subclass. In other words, there must be another Class (ie. MyEdit) that was
derived from the CEdit. Look for that class (ie. MyEdit). In that
subclass, the person must of only allowed certain inputs from the user.

This is just a guess...my MFC is rusty.


"Peter" <noMorespam(a)MSUK.com> wrote in message
news:OqVf2dI7KHA.4508(a)TK2MSFTNGP06.phx.gbl...
> I've got a windows app that was developed using the MFC framework. As my
> app is started the user is presented with a form with some dialog boxes
> for input. One of the input boxes is for a user to enter certain values
> such as 1,2,3,4-7,A,B
>
> That works as expected, but my problem is if I want to enter a range of
> letters such as A-d I'm able to enter the first char "A" but the only key
> that responses after that is a comma. The hyphen doesn't work, so I have
> to entered them in a comma separated for A,B,C,D. The strange part is
> that for numbers I can do a range 1-10,11,12
>
> Some how that control has a filter or mask setup. If I look the RC file
> the name associated with that control is
> #define IDC_MOD 1115
>
> EDITTEXT IDC_MOD,7,49,348,21,ES_MULTILINE
>
> Then ...
>
> DDX_Control(pDX, IDC_MOD, m_ModStatusCtrl);
>
> DDX_Text(pDX, IDC_MOD, m_MOD);
>
> DDV_MaxChars(pDX, m_MOD, 156);
>
> ON_EN_CHANGE(IDC_MOD, OnEnChangeMod)
>
>
>
> Any ideas what I should be looking for? I not able to see anything that
> explicitly won't allow a hyphen after a Char
>
>
>
>
>
>
>
>
From: David Lowndes on
>Some how that control has a filter or mask setup. If I look the RC file the
>name associated with that control is
>#define IDC_MOD 1115
>
>EDITTEXT IDC_MOD,7,49,348,21,ES_MULTILINE
>
>Then ...
>
>DDX_Control(pDX, IDC_MOD, m_ModStatusCtrl);
>
>DDX_Text(pDX, IDC_MOD, m_MOD);
>
>DDV_MaxChars(pDX, m_MOD, 156);
>
>ON_EN_CHANGE(IDC_MOD, OnEnChangeMod)
>
>Any ideas what I should be looking for? I not able to see anything that
>explicitly won't allow a hyphen after a Char

Whatever code is invoked in your OnEnChangeMod method!

Dave
From: David Ching on
"Peter" <noMorespam(a)MSUK.com> wrote in message
news:OqVf2dI7KHA.4508(a)TK2MSFTNGP06.phx.gbl...
> Some how that control has a filter or mask setup. ...
> DDX_Control(pDX, IDC_MOD, m_ModStatusCtrl);
>
> DDX_Text(pDX, IDC_MOD, m_MOD);
>
> DDV_MaxChars(pDX, m_MOD, 156);
>
> ON_EN_CHANGE(IDC_MOD, OnEnChangeMod)
>

As David L. said, OnEnChangeMod() is called when the contents of the editbox
is changed. Also, what type is m_ModStatusCtrl? If it is anything except
CEditCtrl, look at the class that it is to see if it restricts input.

-- David

From: Joseph M. Newcomer on
See below....
On Wed, 5 May 2010 14:16:26 -0500, "Peter" <noMorespam(a)MSUK.com> wrote:

>
>I've got a windows app that was developed using the MFC framework. As my
>app is started the user is presented with a form with some dialog boxes for
>input. One of the input boxes is for a user to enter certain values such as
>1,2,3,4-7,A,B
>
>That works as expected, but my problem is if I want to enter a range of
>letters such as A-d I'm able to enter the first char "A" but the only key
>that responses after that is a comma. The hyphen doesn't work, so I have
>to entered them in a comma separated for A,B,C,D. The strange part is
>that for numbers I can do a range 1-10,11,12
>
>Some how that control has a filter or mask setup. If I look the RC file the
>name associated with that control is
>#define IDC_MOD 1115
>
>EDITTEXT IDC_MOD,7,49,348,21,ES_MULTILINE
>
>Then ...
>
>DDX_Control(pDX, IDC_MOD, m_ModStatusCtrl);
>
>DDX_Text(pDX, IDC_MOD, m_MOD);
>
>DDV_MaxChars(pDX, m_MOD, 156);
****
First, I would eliminate the DDV completely; I think the entire DDV mechanism is deeply
flawed, beyond any hope of sanity. DDV does data validation whenever an UpdateData is
done to move the values in the controls back to the variables, which is FAR too late to do
any good. I believe strongly in real-time data validation. And the error message that
pops up is an intrusive and obnoxious MessageBox, whose contents are generally
unintelligible.

Next, you failed to show us the declarations of these variables, such as m_ModStatusCtrl
and m_Mod. Without those declarations, the code is impossible to make sense of!
****
>
>ON_EN_CHANGE(IDC_MOD, OnEnChangeMod)
>
>
>
>Any ideas what I should be looking for? I not able to see anything that
>explicitly won't allow a hyphen after a Char
****
The type of the control. If the control has a subclassed handler, the OnChar logic in
that class is going to be your source of difficulty. Most people are, to put it mildly,
totally clueless about how to build a validating control. Simple ones are easy; serious
ones take LOTS of work and very rarely (only when buying third party controls that use
masks) have I seen it done even remotely correctly. I have one example I did, on the
let's-keep-it-really-simple side, called my Validating Edit Control, which you can find on
my MVP Tips site. And even it had seriously interesting issues that needed to be handled.
Sophisticated masked edit controls are even more complex to do, and are rarely done
correctly by beginners. For example, the effects of mouse clicks and arrow keys must be
accounted for, VERY carefully. And I didn't even Want To Go There in my control, so I
made it mindlessly simple. Our experience was that the control which changed its
background color was actually very effective in doing real-time validation. THe OK button
would not be enabled unless every control contained valid input (this means DDV would
never be invoked!) For complex forms, I usually have a static control that says what the
error is, and I've even done a hover-over-the-invalid-value-and-I'll-tooltip-what's-wrong.

So, for example, I would stop accepting characters in an edit control that was not
supposed to hold more than 156 characters when the limit was reached, and probably do a
MessageBeep() to signal that the character was rejected.

But unless you tell us the types of the variables, and if they are NOT CEdit you must show
the relevant code of the controls (usually in the OnKeyDown and OnChar handlers) for us to
figure out what is wrong. Also, the OnEnChangeMod handler is suspect. We'd need to see
it also.
joe
*****
>
>
>
>
>
>
>
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm