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 know if the user is pressing on a CButton for more than 250msec? (MFC CButton)

How can I know if the user is pressing on a CButton for more than 250msec? (MFC CButton)

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++comtools
2 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.
  • R Offline
    R Offline
    rbid
    wrote on last edited by
    #1

    Hello, This question is for an MFC application. How can I know if the user is pressing on a button for more than 250msec? As far I know, I get the BN_CLICKED only once, and only when the user releases the button :( Any hint?:confused: -- **Ricky Marek** (_AKA: rbid_) -- "Things are only impossible until they are not" --- Jean-Luc Picard My articles

    G 1 Reply Last reply
    0
    • R rbid

      Hello, This question is for an MFC application. How can I know if the user is pressing on a button for more than 250msec? As far I know, I get the BN_CLICKED only once, and only when the user releases the button :( Any hint?:confused: -- **Ricky Marek** (_AKA: rbid_) -- "Things are only impossible until they are not" --- Jean-Luc Picard My articles

      G Offline
      G Offline
      Gary R Wheeler
      wrote on last edited by
      #2

      Create your own button class CMyButton, which subclasses the existing CButton. Add a handler for the WM_LBUTTONDOWN message to CMyButton. In the handler, post a notification to the parent dialog like this:

      WPARAM wParam = MAKEWPARAM(GetDlgCtrlID(),BN\_PRESSED);
      LPARAM lParam = (LPARAM)m\_hWnd;
      
      GetParent()->PostMessage(WM\_COMMAND,wParam,lParam);
      

      where BN_PRESSED is a notification code you've defined. In your dialog, add a handler for the BN_PRESSED notification. In the handler, start a timer (try using QueryPerformanceCounter). In your BN_CLICKED handler, get the value of the timer and compare the difference.


      Software Zen: delete this;

      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