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. maintain focus in edit box

maintain focus in edit box

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
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.
  • A Offline
    A Offline
    aarontan
    wrote on last edited by
    #1

    How do i maintain the focus in a edit box? For example i was typing half-way in the edit box, however an event occur and the focus got changed. How do i set the focus to remain in the edit box. This is wat i tried to do when the event occurs if(m_alarmOn==false) { m_alarmOn= true; CWnd* prev = this->SetFocus(); prev->SetFocus(); CreateThread(0,NULL,CSecurityDlg::playSound,this,0,0); } The above code reside in a OnBtnClick function. So when alarm is on, the button will be auto click....and the alarm sound goes off.... But in the process of these, i might be typing in a editbox. So i will lose the focus...How do i get it to stay? :(( Aaron

    E 1 Reply Last reply
    0
    • A aarontan

      How do i maintain the focus in a edit box? For example i was typing half-way in the edit box, however an event occur and the focus got changed. How do i set the focus to remain in the edit box. This is wat i tried to do when the event occurs if(m_alarmOn==false) { m_alarmOn= true; CWnd* prev = this->SetFocus(); prev->SetFocus(); CreateThread(0,NULL,CSecurityDlg::playSound,this,0,0); } The above code reside in a OnBtnClick function. So when alarm is on, the button will be auto click....and the alarm sound goes off.... But in the process of these, i might be typing in a editbox. So i will lose the focus...How do i get it to stay? :(( Aaron

      E Offline
      E Offline
      Eytukan
      wrote on last edited by
      #2

      void APPDlg::OnKillfocusTextBox() { //set condtion here to see if the user has finshed typing.. //else do this, m_TextBox.SetFocus(); } u can never get out of ur textbox if u dont handle it correctly :~ V

      A 1 Reply Last reply
      0
      • E Eytukan

        void APPDlg::OnKillfocusTextBox() { //set condtion here to see if the user has finshed typing.. //else do this, m_TextBox.SetFocus(); } u can never get out of ur textbox if u dont handle it correctly :~ V

        A Offline
        A Offline
        aarontan
        wrote on last edited by
        #3

        Tks. I resolved it using pic control and defining a WM_action message instead. Thought this would be neater. :-O

        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