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. Button without focus?

Button without focus?

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 Posts 3 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
    Moak
    wrote on last edited by
    #1

    Hi, can I create a button which not get focus if it is clicked? (a focusless button like a button in a toolbar) The focus should stay with the current control and not be "stolen" by button click. Possibly it can be done by overriding WM_LBUTTONDOWN ...? It would be great if I can avoid ownerdraw (to keep XP style button, if code is running on XP). What I found on Google mentions it has to be a onwerdraw button rebuild from scratch. At the moment I simply set the focus back after button is clicked, but that's not that great. Thx for help, Moak

    C X 2 Replies Last reply
    0
    • M Moak

      Hi, can I create a button which not get focus if it is clicked? (a focusless button like a button in a toolbar) The focus should stay with the current control and not be "stolen" by button click. Possibly it can be done by overriding WM_LBUTTONDOWN ...? It would be great if I can avoid ownerdraw (to keep XP style button, if code is running on XP). What I found on Google mentions it has to be a onwerdraw button rebuild from scratch. At the moment I simply set the focus back after button is clicked, but that's not that great. Thx for help, Moak

      C Offline
      C Offline
      chepuri_uk
      wrote on last edited by
      #2

      For example: CButton* bt = (CButton*)GetDlgItem(IDC_BUTTON1); void XDlg::OnButton1() { bt->EnableWindow(FALSE);//For Focusless } void XDlg::OnRbuttonDown() { bt->EnableWindow(TRUE);//For back to Focus; } Is this helpful to you.

      M 1 Reply Last reply
      0
      • M Moak

        Hi, can I create a button which not get focus if it is clicked? (a focusless button like a button in a toolbar) The focus should stay with the current control and not be "stolen" by button click. Possibly it can be done by overriding WM_LBUTTONDOWN ...? It would be great if I can avoid ownerdraw (to keep XP style button, if code is running on XP). What I found on Google mentions it has to be a onwerdraw button rebuild from scratch. At the moment I simply set the focus back after button is clicked, but that's not that great. Thx for help, Moak

        X Offline
        X Offline
        xxhimanshu
        wrote on last edited by
        #3

        i can't undesrtand...what is it you want..in a toolbar too we have focus on the buttons..when we click them..you can just disable it..and use if you want like that.. cheers Himanshu

        M 1 Reply Last reply
        0
        • C chepuri_uk

          For example: CButton* bt = (CButton*)GetDlgItem(IDC_BUTTON1); void XDlg::OnButton1() { bt->EnableWindow(FALSE);//For Focusless } void XDlg::OnRbuttonDown() { bt->EnableWindow(TRUE);//For back to Focus; } Is this helpful to you.

          M Offline
          M Offline
          Moak
          wrote on last edited by
          #4

          yaiii... amazing that this really works. nice trick, chepuri_uk! I changed the code a bit and use something like this now:

          void CButtonFL::OnLButtonDown(UINT nFlags, CPoint point)
          {
          EnableWindow(FALSE);
          CButton::OnLButtonDown(nFlags, point);
          EnableWindow(TRUE);
          }

          Gratefully, Moak PS: I own you a pizza :)

          1 Reply Last reply
          0
          • X xxhimanshu

            i can't undesrtand...what is it you want..in a toolbar too we have focus on the buttons..when we click them..you can just disable it..and use if you want like that.. cheers Himanshu

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

            yeah like a button on a PC... like when you click and all the focus was gone... huuu.... like a button but just like without this focus... like when you click and... it then does not take focus... like in a toolbar we have. It's kind of button. Moak -- "...and it was like, bleep bleep bleep bleep bleep bleep bleep..." Ellen Feiss, Student ;)

            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