Owner draw buttton:Unable to handle enter key event
-
Hi, I have created dialog box in SDK(c++) and there is one button "B1" with style owner draw and other "B2" with default style. When I press enter key then "B2" gets pressed but when "B1" is highlighted it doesn't respond. I tried many styles of button and also tried subclassing but I am unbale to handle enter key event. Is any one knows how to solve it?
Manish
-
Hi, I have created dialog box in SDK(c++) and there is one button "B1" with style owner draw and other "B2" with default style. When I press enter key then "B2" gets pressed but when "B1" is highlighted it doesn't respond. I tried many styles of button and also tried subclassing but I am unbale to handle enter key event. Is any one knows how to solve it?
Manish
You have three buttons on your dialog when you press one key you dont get any action,right?
WhiteSky
-
You have three buttons on your dialog when you press one key you dont get any action,right?
WhiteSky
No I have two buttons: Button "B1" with owner draw style and button "B2" with default style. On mouse click both get action. On space bar when highlighted both get actions. But when I press enter key when highlighted "B2" gets action but "B1" when highlighted doesn't respond to it. Any sugestions?
Manish
-
No I have two buttons: Button "B1" with owner draw style and button "B2" with default style. On mouse click both get action. On space bar when highlighted both get actions. But when I press enter key when highlighted "B2" gets action but "B1" when highlighted doesn't respond to it. Any sugestions?
Manish
Do you set Default Button to true (On property window) for B2?
WhiteSky
-
Do you set Default Button to true (On property window) for B2?
WhiteSky
In property page: B2 having style: visible B1 having style : visible and owner draw. Please suggest any solution so that when B1 is highlighted,on pressing enter ket it should get action.
Manish
-
In property page: B2 having style: visible B1 having style : visible and owner draw. Please suggest any solution so that when B1 is highlighted,on pressing enter ket it should get action.
Manish
Not visible I said Default button on proeprty window of each button
WhiteSky
-
Not visible I said Default button on proeprty window of each button
WhiteSky
I haven't set any default button on my dialog. All other styles are set to false and only those wnich are mentioned are set. With these styles I want to handle enter key event for "B1". How will it be done?
Manish
-
I haven't set any default button on my dialog. All other styles are set to false and only those wnich are mentioned are set. With these styles I want to handle enter key event for "B1". How will it be done?
Manish
if you run this code what happens?
#define IDC_TEST 1000 BEGIN_MESSAGE_MAP(CAnswerDlg, CDialog) ON_BN_CLICKED(IDC_TEST, OnBnClickedTest) END_MESSAGE_MAP() void CAnswerDlg::DoDataExchange(CDataExchange* pDX) { DDX_Control(pDX, IDC_TEST, m_Test); } BOOL CAnswerDlg::OnInitDialog() { m_Test.Create("AS",WS_TABSTOP|WS_CHILD|WS_VISIBLE|BS_NOTIFY,CRect(0,0,100,23),this,IDC_TEST); } void CAnswerDlg::OnBnClickedTest() { MessageBox("A"); } //////////In header file/////// afx_msg void OnBnClickedTest(); CButton m_Test;
I run this code and it works for me does this code solve your problem?
WhiteSky
-
if you run this code what happens?
#define IDC_TEST 1000 BEGIN_MESSAGE_MAP(CAnswerDlg, CDialog) ON_BN_CLICKED(IDC_TEST, OnBnClickedTest) END_MESSAGE_MAP() void CAnswerDlg::DoDataExchange(CDataExchange* pDX) { DDX_Control(pDX, IDC_TEST, m_Test); } BOOL CAnswerDlg::OnInitDialog() { m_Test.Create("AS",WS_TABSTOP|WS_CHILD|WS_VISIBLE|BS_NOTIFY,CRect(0,0,100,23),this,IDC_TEST); } void CAnswerDlg::OnBnClickedTest() { MessageBox("A"); } //////////In header file/////// afx_msg void OnBnClickedTest(); CButton m_Test;
I run this code and it works for me does this code solve your problem?
WhiteSky
Hi, Regret for late reply... I am using Win32 SDk application,no MFC is there. I have implemented subclaasing of child controls(buttons in this case) to adrees this issue.Now I am able to handle enter key events as well.:)
Manish
-
Hi, Regret for late reply... I am using Win32 SDk application,no MFC is there. I have implemented subclaasing of child controls(buttons in this case) to adrees this issue.Now I am able to handle enter key events as well.:)
Manish
I glad you find it :-D
WhiteSky