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. how can I get Push button setfocus event

how can I get Push button setfocus event

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
3 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.
  • H Offline
    H Offline
    hemlat
    wrote on last edited by
    #1

    Hi, I have created MFC application.I am having 2 Dialog boxes.If I click "Add" button(push button) on first Dialog second dialog will open.After canceling of second dialog once again focus is coming on Add Button.At that time I need to refresh my list box,which is on first dialog. I need to get focus of Add button.So I have created small program like this

    BEGIN_MESSAGE_MAP(CMyThreadDlg, CDialog)
    ON_BN_SETFOCUS(IDC_BUTTON2, &CMyThreadDlg::OnBnSetfocusButton2)
    END_MESSAGE_MAP()

    void CMyThreadDlg::OnBnSetfocusButton2()
    {
    // TODO: Add your control notification handler code here
    MessageBox(_T("Focus"));
    }

    If I click on that button focus is coming but function is not calling.Can anyone help me.

    C 1 Reply Last reply
    0
    • H hemlat

      Hi, I have created MFC application.I am having 2 Dialog boxes.If I click "Add" button(push button) on first Dialog second dialog will open.After canceling of second dialog once again focus is coming on Add Button.At that time I need to refresh my list box,which is on first dialog. I need to get focus of Add button.So I have created small program like this

      BEGIN_MESSAGE_MAP(CMyThreadDlg, CDialog)
      ON_BN_SETFOCUS(IDC_BUTTON2, &CMyThreadDlg::OnBnSetfocusButton2)
      END_MESSAGE_MAP()

      void CMyThreadDlg::OnBnSetfocusButton2()
      {
      // TODO: Add your control notification handler code here
      MessageBox(_T("Focus"));
      }

      If I click on that button focus is coming but function is not calling.Can anyone help me.

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      Why do you need to refresh your listbox when your add button gets focus? I am just guessing but i believe what you want is to refresh your list when your second dialog is closed. If it is a modal dialog then all you need to do is refresh your list after your second dialog's DoModal returns.

      void CMyThreadDlg::OnPressedAddButton()
      {
      CMySecondDialog Dlg(this);
      Dlg.DoModal();
      RefreshMyListNow();
      }

      If you insist on the focus change maybe try using ON_BN_SETFOCUS(IDC_BUTTON2, OnBnSetfocusButton2) instead of ON_BN_SETFOCUS(IDC_BUTTON2, &CMyThreadDlg::OnBnSetfocusButton2), does that help?

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

      H 1 Reply Last reply
      0
      • C Code o mat

        Why do you need to refresh your listbox when your add button gets focus? I am just guessing but i believe what you want is to refresh your list when your second dialog is closed. If it is a modal dialog then all you need to do is refresh your list after your second dialog's DoModal returns.

        void CMyThreadDlg::OnPressedAddButton()
        {
        CMySecondDialog Dlg(this);
        Dlg.DoModal();
        RefreshMyListNow();
        }

        If you insist on the focus change maybe try using ON_BN_SETFOCUS(IDC_BUTTON2, OnBnSetfocusButton2) instead of ON_BN_SETFOCUS(IDC_BUTTON2, &CMyThreadDlg::OnBnSetfocusButton2), does that help?

        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <

        H Offline
        H Offline
        hemlat
        wrote on last edited by
        #3

        Hi, Thanks for your reply.I am calling refresh function after second dialog returns. My code is working fine.

        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