Solved

How to have a "repeat button"?

Posted on 1997-06-06
2
248 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
2 Comments
 
LVL 2

Accepted Solution

by:
The Master earned 100 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to monitor remote shell execution on linux 9 104
has77  challenge 9 88
Problem to event 3 102
Bartender label printing - switch on and off graphics 3 54
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

808 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