Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Edit Box Problem!!

Edit Box Problem!!

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sunny
    wrote on last edited by
    #1
    1. I recently try to create a password protection program!!! But the problem was when I press "ENTER" in the edit box it will exit the program!!!! Anyone know how to fix this problem!!!(I want the Password check box checked in the property of edit box)!! 2) Are there a WM_KEYDOWN event for the edit box control???? What I want to do is when the user press "enter" key in the edit box it will checks to see if the password entered is it correct or not!!!! Any Help with these 2 problems???? THANKS FOR THE HELPER!~!!!!
    E O H 3 Replies Last reply
    0
    • S sunny
      1. I recently try to create a password protection program!!! But the problem was when I press "ENTER" in the edit box it will exit the program!!!! Anyone know how to fix this problem!!!(I want the Password check box checked in the property of edit box)!! 2) Are there a WM_KEYDOWN event for the edit box control???? What I want to do is when the user press "enter" key in the edit box it will checks to see if the password entered is it correct or not!!!! Any Help with these 2 problems???? THANKS FOR THE HELPER!~!!!!
      E Offline
      E Offline
      Erik Funkenbusch
      wrote on last edited by
      #2

      You need to override PreTranslateMessage for your dialog, then when you recieve a WM_KEYDOWN message that is VK_RETURN, check to see if the window handle of the message is equal to the window handle of the edit box, if so handle the message, otherwise pass it on to the base class.

      1 Reply Last reply
      0
      • S sunny
        1. I recently try to create a password protection program!!! But the problem was when I press "ENTER" in the edit box it will exit the program!!!! Anyone know how to fix this problem!!!(I want the Password check box checked in the property of edit box)!! 2) Are there a WM_KEYDOWN event for the edit box control???? What I want to do is when the user press "enter" key in the edit box it will checks to see if the password entered is it correct or not!!!! Any Help with these 2 problems???? THANKS FOR THE HELPER!~!!!!
        O Offline
        O Offline
        Oleg Zhuk
        wrote on last edited by
        #3

        You can use this metod: dlg.h file add: virtual void OnOK(); dlg.cpp file add: void CDlg::OnOK() { // TODO: Add extra validation here ////CDialog::OnOK(); nothing do if Enter press } OlegO

        1 Reply Last reply
        0
        • S sunny
          1. I recently try to create a password protection program!!! But the problem was when I press "ENTER" in the edit box it will exit the program!!!! Anyone know how to fix this problem!!!(I want the Password check box checked in the property of edit box)!! 2) Are there a WM_KEYDOWN event for the edit box control???? What I want to do is when the user press "enter" key in the edit box it will checks to see if the password entered is it correct or not!!!! Any Help with these 2 problems???? THANKS FOR THE HELPER!~!!!!
          H Offline
          H Offline
          HP
          wrote on last edited by
          #4

          Hi, I think the solution for both problems is to override the "OnOK" handler of the dialog:

          void MyDialog::OnOK()
          {
          // suppose m_sPassword is bound with DDX to the editbox
          UpdateData( TRUE );

          if( m\_sPassword != "PASSWORD" )
          {
          	AfxMessageBox( "Wrong Password" );
          	return;
          }
          
          CDialog::OnOK();
          

          }

          Best regards Holger

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups