Re: is there a handler for when a button is pressed and held down?
- From: "jimi_hendricks" <jimihendricks@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 10 May 2005 08:14:02 -0700
Hi Jonathan,
Thanks once again for you help.
in the interests of keeping my code 'lite' i had sort of hoped the 'sleep'
function previously mentioned might work. however the macro keeps stalling
when called.
my declaration is as follows:
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
and i call it with:
Sleep 500 'for example
but no luck. I'm using Word 2003, perhaps this syntax i've picked up was for
an older version?
Failing that i'll try to incorporate the CStopWatch class you kindly
suggested.
Regards,
jimi
"Jonathan West" wrote:
> Hi Jimi
>
> You can use the CStopwatch class from Karl Peterson's web site. Take a look
> here
>
> http://vb.mvps.org/samples/project.asp?id=StopWatch
>
> The class gives you a timer with millisecond precision. Although it was
> written in VB rather than VBA, the class module can be dropped directly into
> a Word VBA project unmodified.
>
> --
> Regards
> Jonathan West - Word MVP
> www.intelligentdocuments.co.uk
> Please reply to the newsgroup
> Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
>
> "jimi_hendricks" <jimihendricks@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:58CEA9AB-4562-47A5-8B10-6652D04AD01E@xxxxxxxxxxxxxxxx
> > Dear Jonathan and Helmut,
> >
> > Thanks for your help.
> >
> > I have implemented a solution using a flag switched on at the start of
> > MouseDown(), then a while loop repeats, calling the 'Wait()' function
> > suggested by Helmut, so long as the flag is true, and the mouseUp()
> > function
> > resets the flag.
> >
> > Could I ask for a little more help?
> >
> > Ideally, the action should repeat more rapidly than once a second, but it
> > seems the 'timer' property only deals in units of a second, is that
> > correct?
> >
> > Is there an alternative way of coding the 'Wait()' function that allows it
> > to tick maybe 10 times a second?
> >
> > Thanks again!
> >
> > "Helmut Weber" wrote:
> >
> >> Hi,
> >> you could combine the mousedown-event with the mouseup-event.
> >> A click on the userform sets a public boolean to true.
> >> The mousedown event runs until the boolean is false.
> >> The boolean is set to false by the mouseup-event:
> >>
> >> Dim weiter As Boolean
> >>
> >> Private Sub CommandButton1_MouseDown(ByVal Button As Integer, ByVal
> >> Shift As Integer, ByVal X As Single, ByVal Y As Single)
> >> While weiter = True
> >> Selection.TypeText Text:="j"
> >> Wait 1
> >> Wend
> >> End Sub
> >>
> >> Private Sub CommandButton1_MouseUp(ByVal Button As Integer, ByVal
> >> Shift As Integer, ByVal X As Single, ByVal Y As Single)
> >> weiter = False
> >> End Sub
> >>
> >> Private Sub UserForm_Click()
> >> weiter = True
> >> End Sub
> >>
> >> Public Sub Wait(ByVal aNum As Integer)
> >> Dim aTim As Single
> >> aTim = Timer
> >> While Timer < aTim + aNum
> >> DoEvents
> >> Wend
> >> End Sub
> >>
> >> To start it all again, one would have to click in the userform before.
> >>
> >> You may try api-sleep instead of wait.
> >>
> >> Greetings from Bavaria, Germany
> >>
> >> Helmut Weber, MVP
> >> "red.sys" & chr(64) & "t-online.de"
> >> Word XP, Win 98
> >> http://word.mvps.org/
> >>
>
>
.
- Follow-Ups:
- Re: is there a handler for when a button is pressed and held down?
- From: Helmut Weber
- Re: is there a handler for when a button is pressed and held down?
- From: Jonathan West
- Re: is there a handler for when a button is pressed and held down?
- References:
- is there a handler for when a button is pressed and held down?
- From: jimi_hendricks
- Re: is there a handler for when a button is pressed and held down?
- From: Helmut Weber
- Re: is there a handler for when a button is pressed and held down?
- From: jimi_hendricks
- Re: is there a handler for when a button is pressed and held down?
- From: Jonathan West
- is there a handler for when a button is pressed and held down?
- Prev by Date: Re: is there a handler for when a button is pressed and held down?
- Next by Date: Re: is there a handler for when a button is pressed and held down?
- Previous by thread: Re: is there a handler for when a button is pressed and held down?
- Next by thread: Re: is there a handler for when a button is pressed and held down?
- Index(es):
Relevant Pages
|