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. Owner draw buttton:Unable to handle enter key event

Owner draw buttton:Unable to handle enter key event

Scheduled Pinned Locked Moved C / C++ / MFC
c++wpftutorialquestion
10 Posts 2 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.
  • M Offline
    M Offline
    Manish_Home
    wrote on last edited by
    #1

    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

    H 1 Reply Last reply
    0
    • M Manish_Home

      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

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      You have three buttons on your dialog when you press one key you dont get any action,right?


      WhiteSky


      M 1 Reply Last reply
      0
      • H Hamid Taebi

        You have three buttons on your dialog when you press one key you dont get any action,right?


        WhiteSky


        M Offline
        M Offline
        Manish_Home
        wrote on last edited by
        #3

        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

        H 1 Reply Last reply
        0
        • M Manish_Home

          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

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          Do you set Default Button to true (On property window) for B2?


          WhiteSky


          M 1 Reply Last reply
          0
          • H Hamid Taebi

            Do you set Default Button to true (On property window) for B2?


            WhiteSky


            M Offline
            M Offline
            Manish_Home
            wrote on last edited by
            #5

            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

            H 1 Reply Last reply
            0
            • M Manish_Home

              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

              H Offline
              H Offline
              Hamid Taebi
              wrote on last edited by
              #6

              Not visible I said Default button on proeprty window of each button


              WhiteSky


              M 1 Reply Last reply
              0
              • H Hamid Taebi

                Not visible I said Default button on proeprty window of each button


                WhiteSky


                M Offline
                M Offline
                Manish_Home
                wrote on last edited by
                #7

                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

                H 1 Reply Last reply
                0
                • M Manish_Home

                  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

                  H Offline
                  H Offline
                  Hamid Taebi
                  wrote on last edited by
                  #8

                  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


                  M 1 Reply Last reply
                  0
                  • H Hamid Taebi

                    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


                    M Offline
                    M Offline
                    Manish_Home
                    wrote on last edited by
                    #9

                    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

                    H 1 Reply Last reply
                    0
                    • M Manish_Home

                      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

                      H Offline
                      H Offline
                      Hamid Taebi
                      wrote on last edited by
                      #10

                      I glad you find it :-D


                      WhiteSky


                      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