Solved

Help parsing an Edit Control

Posted on 2013-06-05
7
254 Views
Last Modified: 2013-06-14
I am simulating a "fingerprint scan" by using an Edit box in my novelty program.

the characters I will use to accept and draw the print are:

/ \ : { } |

Open in new window


here is the key I am using to determine whether or not a fingerprint scan is correct:

{ = day of week is Mon thru thurs
} = say of week is Fri thru sun
/ = month is Jan Thru June
\ = month is July thru Dec
| = time is 12:01am thru 12pm
: = time is 12:01pm thru 12:00am

Can someone show me a Bare bones example on how to check my IDC_PRINT edit box to determine whether they entered a valid"print"?

Thank you.
0
Comment
Question by:edvinson
  • 4
  • 3
7 Comments
 
LVL 33

Expert Comment

by:sarabande
ID: 39222691
can you elaborate what relation a "fingerprint scan" has with a edit box string that contains date/time related characters?

can you make a sample usecase with good and bad input (and explain why they were good or bad)?

Sara
0
 
LVL 1

Author Comment

by:edvinson
ID: 39224670
The user has to enter the correct characters in the edit box to succeed.
So u need to use the key to determine whether their answer is correct.

I think i would loop through each char in edit box, and determine whether that character evaluates to true (based upon the rule assigned to that character)

if each character is True, then they entered a correct "print", and game continues.

Hope that helps. Oh, of course automatically the function will return false, bad, if any other characters are present.

Thank you so much
0
 
LVL 33

Expert Comment

by:sarabande
ID: 39224707
a few questions:

- the user enters any sequence of / \ : { } | and all are valid?

- it depends on the current date/time whether they were valid?

- a valid character can be repeated?

generally, you better would check each single character rather than the input in the edit box. the problem for the latter is that you don't get a reliable event for end-of-input but have to handle ambiguous events like WM_KILLFOCUS, what means that the user has moved from edit field to some other control.

when the user enters a single character you could handle EN_CHANGE or EN_UPDATE notification, or on a lower level, WM_KEYDOWN, WM_CHAR, or WM_KEYUP message.

Sara
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:edvinson
ID: 39232467
I think I confused you, I am sorry.

Quite simply, I want to check the edit box value. It is either going to be correct, or incorrect.

Wrapped in a BOOL function....

 I would loop through each character.

Let's say the first character is { , then my code would check to see if Todays day is MON-THURS. If so, continue with next char. If not, it fails, return false,

Do this for each character. Each character must pass its own test.

The correct answer will contain 3 characters, and depending upon the time and date, it will contain only the characters I listed above.

For instance, using SAT JUN 08 2013 12:02am , a correct answer would be:

}/|

anything else would return false.

I suppose the order of the characters doesn't matter, as long as they are correct
0
 
LVL 1

Author Comment

by:edvinson
ID: 39245421
Question not receiving answers, request deleting please. Maybe i need to re phrase it.
0
 
LVL 33

Accepted Solution

by:
sarabande earned 500 total points
ID: 39246875
you could do like

std::string strValid = "/\\:{}|";
char szInput[100] = { '\0' };
GetWindowText(::GetDlgItem(IDC_PRINT), szInput, 100);
int len = (int)strlen(szInput);
for (int i = 0; i < len; ++i)
{
     if (strValid.find(szInput[i]) == std::string::npos)
     {
            ::MessageBox(NULL, szInput, "Wrong Input", MB_OK);
            return;
     }
     SYSTEMTIME st = { 0 };
     GetSystemTime(&st);
     switch (szInput[i])
     {
     case '/':
           if (st.wMonth > 6)
           {
                ::MessageBox(NULL, "/", "Wrong Month", MB_OK);
                return;
           }   
           break;
    case '\\':
          ...
}

Open in new window


Sara
0
 
LVL 1

Author Closing Comment

by:edvinson
ID: 39247233
This is the perfect code solution to get me going.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
maze travler 6 51
c++ mixing int and strings in multi array 8 71
Visual c++ and text files 7 60
C language IDE – Compilers installation 14 67
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now