Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to have a "repeat button"?

Posted on 1997-06-06
2
Medium Priority
?
269 Views
Last Modified: 2013-11-20
My application needs a "repeat button" : a button that sends a  messages every m milisecondes when the user maintains it pressed. Could tell what is the best way to implement this?
(Is it in a new class repeat  button, at he level of the toolbar that have the button or in the View that use the handle the command?
Thanks, Nicolas
0
Comment
Question by:Nicolas060297
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
The Master earned 300 total points
ID: 1301998
As far as I know, the only time you get a button-click notification is when the button is acutally pressed, and then released.  You need to start your handling when the button is pressed, so you need to create your own class.

You could do this pretty easily by deriving a class from CButton, and handling the following messages:

OnLButtonDown()
OnLButtonUp()
OnTimer()

In OnLButtonDown, just call SetTimer() with the appropriate delay, and in OnLButtonUp, call KillTimer().  In your OnTimer() handler, send your message.

I'm pretty sure the timer resolution in Windows is around 55 ms, so if you want faster messages than that, you could alternatively start a peekmessage loop in your OnLButtonDown handler, and call timeGetTime() every loop to know when to send out the message.  You would obviously break out of the loop when you received a WM_MOUSEUP message.

Good Luck!
0
 

Author Comment

by:Nicolas060297
ID: 1301999
This answer suits me quite well. But I would have liked a little bit more details about how the button generates an application message.
(How does it knows the message it have to send)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question