| | |
MFC - OnKeyDown event.
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Dec 2005
Posts: 43
Reputation:
Solved Threads: 0
In CApplView I create a Login Form.
How do I add code to set the focus on pPasswd when TAB or RETN is entered in pUserid?
Something like...
I cannot figure out how to incorporate the event in the MESSAGE MAP.
C++ Syntax (Toggle Plain Text)
void CApplView::Login_Entry(CDC *pDC) { .. if (pUserid == NULL) { pUserid = new CEdit; pUserid->Create(WS_CHILD|WS_VISIBLE|WS_BORDER, CRect(x,y1,w,h), this, IDC_USER); pPasswd = new CEdit; pPasswd->Create(WS_CHILD|WS_VISIBLE|WS_BORDER, CRect(x,y2,w,h), this, IDC_PASS); pbLogin = new CButton(); pbLogin->Create("Login",WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON, CRect(x,y3,w,h), this, IDB_LOGIN); } }
Something like...
C++ Syntax (Toggle Plain Text)
OnKeyDown (in pUserid) if ((char == VK_RETURN) || (char == VK_TAB)) { pPasswd->SetFocus(); }
•
•
Join Date: Dec 2005
Posts: 43
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by WolfPack
You want to add a "Event Handler" for the event of pressing a Tab key or Return key?
I can include, in my MESSAGE MAP,
ON_WM_KEYDOWN()
and write a handler function..
void CApplView::OnKeyDown (UINT nChar, UINT nRepCnt, UINT nFlags) {...}
That will work to capture a key stroke when the main window has focus. I want it to capture the key stroke when pUserid has the focus. I know I can do this by creating a new class derived from CEdit, but I thought there must be a simpler way.
•
•
•
•
Originally Posted by WolfPack
What Compiler of VC are you using?
![]() |
Similar Threads
- !!! Help ME !!!!! (Pascal and Delphi)
- Number Checking string input in Delphi? (Pascal and Delphi)
- Enter to tab (Pascal and Delphi)
- I need to be able to hit Enter as well as clicking button. (VB.NET)
- MFC Countdown Timer (C)
- Subclassed Editbox Control: Do I need to create 2 subclasses for two edit controls? (C++)
Other Threads in the C++ Forum
- Previous Thread: File Processing C++
- Next Thread: Constructor Error
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






