Board index » delphi » Any Comments Appreciated

Any Comments Appreciated


2004-01-26 08:34:05 AM
delphi7
Hello all,
For over 20 years I have been writing code to control computers. For a large
part of that time with Borland product and with Windows since the start. OK,
that establishs my experience (or lack of it).
During that time all my applications were aimed at expert users, i.e. folk
who knew what they were doing and considered training a major part of the
product brief.
Recently we started developing a POS for the automotive industry. Its brief
was anyone should be able to use it with no training. OK, we have managed to
achieve the greater part of that.
Notwithstanding, here is the issue.
Who would ever have considered that a user would DOUBLE-CLICK a command
button. Never before has this been a problem. "Click the command button" you
say and click it they do. Not now, I am sure if you stood still long enough
they'd double-click you.
Without completely railroading the control and rewriting the event handlers,
how to we all stop iterations from double-clicks of a command button.
I have never had to worry about this before and have started on the task of
solving it.
It is easy to say "tell them not to do it" but one can't deploy anything
with known time-bombs in it.
I would be interested in anyone's ideas or practical suggestions as to how
to stop a double-clicking of a command button impacting on the code. Of
course there is no double-click per se, it is two clicks one after the other
iterating two calls to the same event handler. I am sure everyone can start
to consider what this is going to do when you are loading forms, destroying
forms, saving records etc.
In the words of Toranage to Anjin San "Interesting Neh?"
I suppose we can put a timer on the thing, we could put a flag into the
process that circumvents future iterations until the primary one completes,
there are many ways of doing it although I admit I am having trouble with
the timing at this time. Even the time it takes to jump to a process to set
a flag is too long to stop the next iteration.
What do you reckon guys, am I Robinson Crusoe or do we all have this one
ready to bite us?
Regards
Tony Benci
www.smithholden.com.au
XXXX@XXXXX.COM
 
 

Re:Any Comments Appreciated

Hi Tony,
Can't you just assign the OnClick event to the OnDblClick event handler?
Mike
"Tony Benci" <XXXX@XXXXX.COM>writes
Quote
Hello all,
<snip>

Without completely railroading the control and rewriting the event
handlers,
how to we all stop iterations from double-clicks of a command button.

<snip>
 

Re:Any Comments Appreciated

Hi mike,
There isn't one for the TBUTTON
Regards
Tony
"Mike" <XXXX@XXXXX.COM>writes
Quote
Hi Tony,

Can't you just assign the OnClick event to the OnDblClick event handler?

Mike

"Tony Benci" <XXXX@XXXXX.COM>writes
news:XXXX@XXXXX.COM...
>Hello all,


<snip>
>

>Without completely railroading the control and rewriting the event
handlers,
>how to we all stop iterations from double-clicks of a command button.
>
<snip>


 

Re:Any Comments Appreciated

Quote
I would be interested in anyone's ideas or practical suggestions as to how
to stop a double-clicking of a command button impacting on the code. Of
course there is no double-click per se, it is two clicks one after the
other
iterating two calls to the same event handler.
How about this:
procedure EmptyMouseQueue;
var Msg: TMsg;
begin
while PeekMessage( Msg, 0, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE or
PM_NOYIELD)do;
end;
procedure DisableButton(TheButton: TObject);
begin
TButton(TheButton).Enabled:=False;
end;
procedure EnableButton(TheButton: TObject);
begin
EmptyMouseQueue;
TButton(TheButton).Enabled:=True;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
DisableButton(Sender);
try
// do something... for example:
sleep(2000);
finally
EnableButton(Sender);
end;
end;
 

Re:Any Comments Appreciated

Quote
Without completely railroading the control and rewriting the event handlers,
how to we all stop iterations from double-clicks of a command button.
subclass the button; add wm_lbuttondown; in the first call inherited and
disable the button; overrider the doclick method; call inherited and enable the
button.
--
Hannes Danzl [NexusDB Developer]
Newsgroup archive at www.tamaracka.com/search.htm
 

Re:Any Comments Appreciated

Quote
subclass the button; add wm_lbuttondown; in the first call inherited and
disable the button; overrider the doclick method; call inherited and
enable the
button.
Just disabling the button is not enough. Even if you have the button
disabled the extra mouse clicks are stored in the queue; so you need to
empty the queue before you reenable the button.
 

Re:Any Comments Appreciated

Quote
Hello all,
Greetings.
Quote
During that time all my applications were aimed at expert users, i.e. folk
who knew what they were doing and considered training a major part of the
product brief.
You've been a lucky man!
Quote
Recently we started developing a POS for the automotive industry. Its brief
was anyone should be able to use it with no training.
Luck ran out!
Quote
Who would ever have considered that a user would DOUBLE-CLICK a command
button.
I've seen worse. it is hard not to laugh sometimes.
Quote
Without completely railroading the control and rewriting the event handlers,
how to we all stop iterations from double-clicks of a command button.
Replace the buttons with this...
======================================================================
unit rdDebouncedButton;
interface
uses
Windows, StdCtrls;
type
TrdDebouncedButton = class( TButton )
private
fLastClick: DWORD;
public
procedure Click; override;
end;
implementation
{ TrdDebouncedButton }
procedure TrdDebouncedButton.Click;
var
ThisClick: DWORD;
begin
ThisClick := GetMessageTime;
try
if ThisClick-fLastClick>GetDoubleClickTime then
inherited;
finally
fLastClick := ThisClick;
end;
end;
end.
======================================================================
I believe GExperts can assist with the global search and replace.
Good luck, Brian
 

Re:Any Comments Appreciated

Quote
>Who would ever have considered that a user would DOUBLE-CLICK a command
>button.

I've seen worse. it is hard not to laugh sometimes.
That's a bit unfair. People get trained to double-click on Icons, but not
on other things, and get very confused, as the difference between a button
and an icon is not necessarily obvious. If a user can not use your
application, then you are frustrating them, and laughing at them will hardly
help.
Oliver Townshend
 

Re:Any Comments Appreciated

Quote
>>Who would ever have considered that a user would DOUBLE-CLICK a command
>>button.
>
>I've seen worse. it is hard not to laugh sometimes.

That's a bit unfair.
You misunderstand. Which is not too difficult given how terse I was...
Quote
People get trained to double-click on Icons, but not
on other things, and get very confused, as the difference between a button
and an icon is not necessarily obvious.
My grandparents and father-in-law are very good examples. Just last
week my grandmother called for "double-click" help. So, I agree with
you. It is very easy for a novice user to confuse the two.
When I said that "it's hard not to laugh sometimes" I was actually
referring to the "I've seen worse" not the "double-click confusion".
Quote
If a user can not use your
application, then you are frustrating them, and laughing at them will hardly
help.
Which is why, to this day, I have NEVER laughed. And I never will.
But, there have certainly been times when it was VERY difficult to
refrain. People do some very strange things with a mouse.
- Brian
 

Re:Any Comments Appreciated

One could also note that there is an "accidental double click prevention"
feature available in the latest Windows and on some mouse drivers,
so people can just have double clicked everything for months and never
have had any issue with it.
Eric
 

Re:Any Comments Appreciated

Oliver,
I think you have misunderstood us all.
No one is laughing at anyone. This is just a case of Murphey's Law.
I would never have considered this a problem prior, it is now.
It's not a case of talking the mickey out of inexpert users. It is more so
making the code professional and able to be used by these folk.
I don't believe I made fun of anyone nor did Brian as I read it
Regards
Tony
 

Re:Any Comments Appreciated

You're right Peter because I did just that.
I have tried customizing the control to no avail. In all instances there is
the problem of the messages on the queue and, even though making my own
object and managing the queue is an option, it is like using a light pole to
pick your teeth.
What I have ended up doing it to take the btClick, move all the code to
another procedure called ProcessClick passing Sender to get the TObject
sorted and changing btClick to look like this
procedure btClick(Sender: TObject);
begin
if bProcessing then begin beep exit end else bProcessing:=True;
ProcessButton(Sender);
bProcessing:=False;
end;
This fixes it and stops any other sperious click from any other button until
the initial iteration has finished. Beauty of this is that it overrides all
buttons, informs the user that they are doing something wrong and doesn't
require the replacement of every button on every form.
Who knows, this may be such a basic approach to this problem that everyone
knows it and I was asleep in Button Click 101.
Thank you all for your comments
Regards
Tony
 

Re:Any Comments Appreciated

"Tony Benci" <XXXX@XXXXX.COM>wrote in
Quote
I would be interested in anyone's ideas or practical suggestions as to
how to stop a double-clicking of a command button impacting on the
code. Of course there is no double-click per se, it is two clicks one
after the other iterating two calls to the same event handler. I'm
sure everyone can start to consider what this is going to do when you
are loading forms, destroying forms, saving records etc.
Procedure TForm1.Button1Click(Sender: TObject);
Begin
Button1.Visible := False;
Try
// stuff
Finally
Button1.Visible := True;
End;
End;
Cheers, Abraham
 

Re:Any Comments Appreciated

abraham <XXXX@XXXXX.COM>wrote in news:40150d35$XXXX@XXXXX.COM:
Quote
Procedure TForm1.Button1Click(Sender: TObject);
Begin
Button1.Visible := False;
Try
// stuff
Finally
Button1.Visible := True;
End;
End;
Or you can do this if you don't like to hide the button.
Procedure TForm1.Button1Click(Sender: TObject);
Begin
While bButtonFlag Do Exit;
bButtonFlag := True;
Try
// stuff
Finally
bButtonFlag := False;
End;
End;
Cheers, Abraham
 

Re:Any Comments Appreciated

On Mon, 26 Jan 2004 12:23:11 +1100, Tony Benci <XXXX@XXXXX.COM>
writes:
Quote
Hi mike,

There isn't one for the TBUTTON
TSpeedButton? It has a double click event. You do loose TabStop however.
Cheers,
Kevin
--
Using M2, Opera's revolutionary e-mail client: www.opera.com/m2/