Discussion:
Fast Click
(too old to reply)
Ivar
2012-02-07 23:58:49 UTC
Permalink
Hi All.

I asked this question a fair few years ago and got a really good answer, but
now totally forgotten it. So here it is again.
VB6
Got a PictureBox, The only even is the Click event.
There is some way that the click event of the picturebox can be set so that
it responds to each click event no matter how short the interval between
events is.
If I remember right it's get something to do with clsID
Can anyone help?

Thanks

Ivar
Farnsworth
2012-02-08 00:07:41 UTC
Permalink
Post by Ivar
Hi All.
I asked this question a fair few years ago and got a really good answer,
but now totally forgotten it. So here it is again.
VB6
Got a PictureBox, The only even is the Click event.
There is some way that the click event of the picturebox can be set so
that it responds to each click event no matter how short the interval
between events is.
If I remember right it's get something to do with clsID
Can anyone help?
You need to remove the double click style so Windows doesn't wait for the
double-click time. Search the newsgroups for "vb SetClassLong CS_DBLCLKS".
Auric__
2012-02-08 02:25:36 UTC
Permalink
Post by Farnsworth
Post by Ivar
Hi All.
I asked this question a fair few years ago and got a really good answer,
but now totally forgotten it. So here it is again.
VB6
Got a PictureBox, The only even is the Click event.
There is some way that the click event of the picturebox can be set so
that it responds to each click event no matter how short the interval
between events is.
If I remember right it's get something to do with clsID
Can anyone help?
You need to remove the double click style so Windows doesn't wait for the
double-click time. Search the newsgroups for "vb SetClassLong CS_DBLCLKS".
The one place I had to worry about this, I simply added a DblClick event that
called the Click event twice. Overly-simplistic perhaps, but it worked... I
think.
--
They are way too perky to be here.
Ivar
2012-02-08 08:23:02 UTC
Permalink
Thank You

All Sorted Now, Found The Answer here:

http://www.xtremevbtalk.com/archive/index.php/t-43911.html
Mike Williams
2012-02-08 09:33:57 UTC
Permalink
Post by Ivar
Got a PictureBox, The only even is the Click event.
There is some way that the click event of the picturebox
can be set so that it responds to each click event no matter
how short the interval between events is. If I remember
right it's get something to do with clsID
Can anyone help?
As Farnsworth has already said, you can use SetClassLong with the
CS_DBLCLICKS flag. Here is an example (declarations omitted):

Dim oldStyle As Long
oldStyle = GetClassLong(Picture1.hWnd, GCL_STYLE)
SetClassLong Picture1.hWnd, GCL_STYLE, _
oldStyle And Not CS_DBLCLKS

You need to bear in mind that doing so will remove the double clicks not
only from Picture1 but also from all PictureBoxes in all Forms in your
project. If this is not what you want then you will need to return the
double click action back to normal when the user is interacting with other
PictureBoxes in your project. You can do this using code similar to the
above but using 'oldStyle Or CS_DBLCLKS' rather than 'oldStyle And Not
CS_DBLCLKS'. You also need to ensure that you use similar code turn the
effect off in your main Form's Unload event, otherwise when testing programs
in the VB IDE you will find that the effect carries over from one run to the
next, which may be a little confusing.

A much simpler alternative of course would be to forget all about the above
code and simply use the PictureBox's MouseUp event instead of its Click
event, which will probably suit your needs.

Mike
Ivar
2012-02-08 11:58:19 UTC
Permalink
Hi Mike.

I did a test, you are right, it affects all picture boxes. Not that any
other picbox uses the double click event but knowing that now will avoid
confusion in the future.

Use the mouse Down and up events. How simple is that!
I think I need to get out for a while :-)
Thanks for the waffle mike, keep it up

Ivar


"Mike Williams" wrote in message news:jgtfhd$5cq$***@dont-email.me...
As Farnsworth has already said, you can use SetClassLong with the
CS_DBLCLICKS flag. Here is an example (declarations omitted):

Dim oldStyle As Long
oldStyle = GetClassLong(Picture1.hWnd, GCL_STYLE)
SetClassLong Picture1.hWnd, GCL_STYLE, _
oldStyle And Not CS_DBLCLKS

You need to bear in mind that doing so will remove the double clicks not
only from Picture1 but also from all PictureBoxes in all Forms in your
project. If this is not what you want then you will need to return the
double click action back to normal when the user is interacting with other
PictureBoxes in your project. You can do this using code similar to the
above but using 'oldStyle Or CS_DBLCLKS' rather than 'oldStyle And Not
CS_DBLCLKS'. You also need to ensure that you use similar code turn the
effect off in your main Form's Unload event, otherwise when testing programs
in the VB IDE you will find that the effect carries over from one run to the
next, which may be a little confusing.

A much simpler alternative of course would be to forget all about the above
code and simply use the PictureBox's MouseUp event instead of its Click
event, which will probably suit your needs.

Mike
Ivar
2012-02-08 17:28:14 UTC
Permalink
Further to last posting

Went out for a while, came back and tested the mouse down up events. They
now respond in the same way as the click event with the same delay in
responding to events when rapid clicking.
VB must have been reset after I shut it down.
Back to the first way I suppose.

Ivar
Mike Williams
2012-02-08 18:29:35 UTC
Permalink
Further to last posting Went out for a while, came back and tested the
mouse down
up events. They now respond in the same way as the click
event with the same delay in responding to events when rapid
clicking. VB must have been reset after I shut it down.
Back to the first way I suppose.
I never suggested MouseDown, Ivar . . . I suggested MouseUp. If you click
the mouse a dozen times in the PictureBox then you will get a dozen MouseUp
events regardless of how fast you click.

Mike
Ivar
2012-02-08 17:28:14 UTC
Permalink
Further to last posting

Went out for a while, came back and tested the mouse down up events. They
now respond in the same way as the click event with the same delay in
responding to events when rapid clicking.
VB must have been reset after I shut it down.
Back to the first way I suppose.

Ivar

Loading...