?
Solved

How to have a "repeat button"?

Posted on 1997-06-06
2
Medium Priority
?
261 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month7 days, 19 hours left to enroll

765 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