MSDN > フォーラム ホーム > Visual C++ Language > Validations for a dialog based application
質問する質問する
 

回答済みValidations for a dialog based application

  • 2009年11月4日 12:25KEERV ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
    Hi

    How do i add validations to an edit box  in a dialog based application where i type the name like the first letter shud be a capital letter,no numerals or special characters  and the word limit etc...

回答

  • 2009年11月4日 16:31Scott McPhillipsMVPユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     回答済み
    • 回答としてマークKEERV 2009年11月6日 3:53
    • 回答としてマークされていないKEERV 2009年11月5日 6:54
    • 回答としてマークKEERV 2009年11月5日 3:41
    •  
  • 2009年11月5日 14:49Scott McPhillipsMVPユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     回答済み
    Are you using MFC?  If so you would benefit greatly from studying an MFC book. 

    To take your last question first, you right-click on the edit control and do 'Add Variable'.  This gives your dialog class a member variable CEdit m_someeditname.  Use that variable to call CEdit member functions.

    m_someeditname.SetLimitText(n);

    sets the text limit.  A big part of MFC is to give you such functions so you do not have to send messages.

    To validate input to the edit control you start by deriving a class from CEdit.  And you add a message handler in that class for WM_CHAR.  The flounder.com tutorial shows such a function as CFloatingEdit::OnChar.  To make your CEdit-derived class work with m_someeditname you simply change CEdit to CFloatingEdit in the dialog header file.
    • 回答としてマークKEERV 2009年11月6日 3:52
    •  

すべての返信

  • 2009年11月4日 16:31Scott McPhillipsMVPユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     回答済み
    • 回答としてマークKEERV 2009年11月6日 3:53
    • 回答としてマークされていないKEERV 2009年11月5日 6:54
    • 回答としてマークKEERV 2009年11月5日 3:41
    •  
  • 2009年11月5日 3:41KEERV ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
    Thanks Scott.. but i dint understand much... :(
    I googled and searched for some sample code but unable to get one clear solution.

    If i want to use EM_LIMITTEXT i need to send it using SendDlgItemMessage. How do i do that? any sample code? please help..

  • 2009年11月5日 14:49Scott McPhillipsMVPユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     回答済み
    Are you using MFC?  If so you would benefit greatly from studying an MFC book. 

    To take your last question first, you right-click on the edit control and do 'Add Variable'.  This gives your dialog class a member variable CEdit m_someeditname.  Use that variable to call CEdit member functions.

    m_someeditname.SetLimitText(n);

    sets the text limit.  A big part of MFC is to give you such functions so you do not have to send messages.

    To validate input to the edit control you start by deriving a class from CEdit.  And you add a message handler in that class for WM_CHAR.  The flounder.com tutorial shows such a function as CFloatingEdit::OnChar.  To make your CEdit-derived class work with m_someeditname you simply change CEdit to CFloatingEdit in the dialog header file.
    • 回答としてマークKEERV 2009年11月6日 3:52
    •  
  • 2009年11月6日 3:52KEERV ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
    Thanks again Scott.. Will try that..and yes am using MFC.
  • 2009年11月6日 7:30Nancy ShaoMSFT, モデレータユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
    Hi KEERV,

    Scott has given you a great sample and a detailed description. And I also found a good example in Codeproject for your reference:

    Validating Edit Controls

    Best Regards,
    Nancy
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
  • 2009年11月6日 12:10KEERV ユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダルユーザーのメダル
     
    Yes Nancy thank you. I did google and had found this link and had gone through it. I found it a little difficult to understand.
    After a little more of searching in the msdn forums and reading an mfc book like Scott suggested I have now found a simpler way of validating edit controls. :)
    ("simpler way" according to me.)