Keyboard dialog
-
I am designing a dialog that resembles a keyboard that will allow the user to enter passwords, keys, etc... Is it possible to create a single message handler for all of the buttons (letters, numbers, spacebar, -, and .), and if so how do you differetiate between which button was actually pressed. Or, do I have to have a single message handler for each individual keyboard button? Roger Printy Software Engineer TeraNex Orlando, FL
-
I am designing a dialog that resembles a keyboard that will allow the user to enter passwords, keys, etc... Is it possible to create a single message handler for all of the buttons (letters, numbers, spacebar, -, and .), and if so how do you differetiate between which button was actually pressed. Or, do I have to have a single message handler for each individual keyboard button? Roger Printy Software Engineer TeraNex Orlando, FL
-
Supply your own WndProc (window procedure) and look for the messages in that. Stephen Kellett
Any help on doing that, this is new to me. Also, how would you suggest to create an array of button objects that in a constructor is initialized to have each element in the array be a pointer to a button. I am doing this, am I correct because it seems to not be working completely: CButton *m_pLetterBtn[19]; m_pLetterBtn[1] = (CButton *)GetDlgItem(IDC_KEY_1); m_pLetterBtn[1] = (CButton *)GetDlgItem(IDC_KEY_2); m_pLetterBtn[1] = (CButton *)GetDlgItem(IDC_KEY_3); . . . Roger Printy Software Engineer TeraNex Orlando, FL
-
I am designing a dialog that resembles a keyboard that will allow the user to enter passwords, keys, etc... Is it possible to create a single message handler for all of the buttons (letters, numbers, spacebar, -, and .), and if so how do you differetiate between which button was actually pressed. Or, do I have to have a single message handler for each individual keyboard button? Roger Printy Software Engineer TeraNex Orlando, FL
Well, actually, you can use the ON_COMMAND_RANGE message handler. You must make sure all the buttons resource ID's are sequential though. Having said that, your design is probably not the best. It would be much easier if you simply drew the keyboard layout on the dialog in it's OnPaint handler, then create regions for each button and then handle the OnMouseUp event and check to see which region the button press occured in.
-
I am designing a dialog that resembles a keyboard that will allow the user to enter passwords, keys, etc... Is it possible to create a single message handler for all of the buttons (letters, numbers, spacebar, -, and .), and if so how do you differetiate between which button was actually pressed. Or, do I have to have a single message handler for each individual keyboard button? Roger Printy Software Engineer TeraNex Orlando, FL
You can create a message map entry as below ON_CONTROL_RANGE(BN_CLICKED, IDC_BUTTON1, IDC_BUTTON10, OnButtonClicked) instead of the ON_BN_CLICKED message map entry. Here IDC_BUTTONis is the first button in a set of button having consequtive IDS. and IDC_BUTTON10 is last among them. The corresponding hadler will look like void CMyDialog::OnButtonClicked( UINT nID ) { int nButton = nID - IDC_BUTTON1; ASSERT( nButton >= 0 && nButton < 10 ); // ... } If you dont have the button ids as consequtive integers You can try one more method. Let me explain that. Map All the button to one Command Handler. You can do this using the class wizard itself. For all the buttons give the function name the same. Say (OnButtonClicked) Later inside OnButtonClicked you can code as below; void CMyDialog::OnButtonClicked() { const MSG *x = GetCurrentMessage(); CString ToDisp; int nID=(int)x->wParam;//WParam gives the command id of the button. ToDisp.Format("The Id of the button is %d...",nID); MessageBox(ToDisp); } HTH Sundaravalli Shriram Tektronix Engineering Development India Ltd, Bangalore - 560001, India.