Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Feature Request - "Snap To" default button

20 views
Skip to first unread message

MJMatthew

unread,
Feb 28, 2007, 6:14:49 AM2/28/07
to
I'm not sure where else to post this, so here goes...

Delphi applications do not utilise the "Snap To" feature built into Windows,
where the mouse cursor jumps to the default button.

This is located in: Start / Control Panel / Mouse / Pointer Options / Snap
To.

I really like this feature, but it's annoying when some applications do not
implement this.

Can you please consider this for a future versions.

Many thanks.

Matthew


Ralf Kaiser

unread,
Feb 28, 2007, 6:22:34 AM2/28/07
to
"MJMatthew" <REMOVE_THIS_T...@btinternet.com> schrieb im
Newsbeitrag news:45e56423$1...@newsgroups.borland.com...

> Delphi applications do not utilise the "Snap To" feature built into
> Windows, where the mouse cursor jumps to the default button.

Did you try to define one button in you dialog as default? If i understand
it correctly that button is the one this function is searching for.

Dave Nottage [TeamB]

unread,
Feb 28, 2007, 6:44:35 AM2/28/07
to
MJMatthew wrote:

> Delphi applications do not utilise the "Snap To" feature built into
> Windows, where the mouse cursor jumps to the default button.

You could use SetCursorPos in the forms OnShow event. Personally, I
find the behaviour very, very annoying.

--
Dave Nottage [TeamB]

MJMatthew

unread,
Feb 28, 2007, 6:45:12 AM2/28/07
to
Yep, did that. Doesn't seem to make any difference though.

This problem applies to Delphi itself, plus any written applications.

Matthew

"Ralf Kaiser" <r...@lingosmart.de> wrote in message
news:45e5...@newsgroups.borland.com...

Dave Nottage [TeamB]

unread,
Feb 28, 2007, 7:05:36 AM2/28/07
to
MJMatthew wrote:

> This problem applies to Delphi itself, plus any written applications.

It's because of the class name of buttons in Delphi are not "Button".

Expanding on my other post, you could call this function in the OnShow
event of the form:

procedure MouseSnapTo(AForm: TForm);
var
i: integer;
Button: TButton;
Pt: TPoint;
Snap: integer;
begin
SystemParametersInfo(SPI_GETSNAPTODEFBUTTON, 0, @Snap, 0);
if Snap > 0 then
for i := 0 to AForm.ComponentCount - 1 do
if AForm.Components[i] is TButton then
begin
Button := AForm.Components[i] as TButton;
if Button.Default then
begin
Pt.X := Button.Left + (Button.Width div 2);
Pt.Y := Button.Top + (Button.Height div 2);
Pt := AForm.ClientToScreen(Pt);
SetCursorPos(Pt.X, Pt.Y);
end;
end;
end;

eg:

procedure TForm1.FormShow(Sender: TObject);
begin
MouseSnapTo(Self);
end;

--
Dave Nottage [TeamB]

Ivan Rakyta

unread,
Feb 28, 2007, 8:31:04 AM2/28/07
to
> For people like myself who suffer from RSI if I do too much mouse moving
> this feature is very useful.

This is not Delphi related, but did you try this?
www.powerballs.com
I had similar problem and doing excercises with power ball helped me a lot
;)


Pete Fraser

unread,
Feb 28, 2007, 8:17:41 AM2/28/07
to
Thanks for this Dave,
I've been wondering for some time why this didn't work.

For people like myself who suffer from RSI if I do too much
mouse moving this feature is very useful. However, it can be
annoying if some other application puts up a dialog box and
you click it during other activities

Cheers, Pete

"Dave Nottage [TeamB]" <rot13....@enqfbsg.pbz.nh> wrote
in message news:xn0f30ak4...@forums.borland.com...


> MJMatthew wrote:
>
>> This problem applies to Delphi itself, plus any written
>> applications.
>
> It's because of the class name of buttons in Delphi are
> not "Button".
>
> Expanding on my other post, you could call this function
> in the OnShow
> event of the form:

<snipped code>


Lee Grissom

unread,
Feb 28, 2007, 1:38:35 PM2/28/07
to
I'd suggest entering an official enhancement request in CodeGear's Quality
Central system.
http://qc.codegear.com/wc/qcmain.aspx

Be sure to add Dave's code as an example, and maybe the VCL team will come
up with something that works for you. I'm guessing since there's a
work-around, it won't be a high priority item, but enter it anyway.
--
Lee


Brad White

unread,
Feb 28, 2007, 3:13:50 PM2/28/07
to
"Dave Nottage [TeamB]" <rot13....@enqfbsg.pbz.nh> wrote in message
news:xn0f30ak4...@forums.borland.com...
> MJMatthew wrote:
>
>> This problem applies to Delphi itself, plus any written applications.
>
> It's because of the class name of buttons in Delphi are not "Button".
>
> Expanding on my other post, you could call this function in the OnShow
> event of the form:
>
> procedure MouseSnapTo(AForm: TForm);

This is good, but it needs to respect the SnapToSetting.

--
Thanks,
Brad.


Dave Nottage [TeamB]

unread,
Feb 28, 2007, 3:38:24 PM2/28/07
to
Brad White wrote:

> > procedure MouseSnapTo(AForm: TForm);
>
> This is good, but it needs to respect the SnapToSetting.

You mean this part?:

SystemParametersInfo(SPI_GETSNAPTODEFBUTTON, 0, @Snap, 0);
if Snap > 0 then

--
Dave Nottage [TeamB]

Chris Morgan

unread,
Feb 28, 2007, 7:56:43 PM2/28/07
to
> Delphi applications do not utilise the "Snap To" feature built into
> Windows, where the mouse cursor jumps to the default button.
>
> This is located in: Start / Control Panel / Mouse / Pointer Options /
> Snap To.
>
> I really like this feature, but it's annoying when some applications do
> not implement this.

Does it work when the form type is set to Dialog?
I haven't tried it but it may only work with dialogs, as opposed
to normal Delphi forms with minimise and maximise buttons.

Cheers,

Chris


Marco Caspers

unread,
Mar 1, 2007, 3:08:38 AM3/1/07
to
Ivan Rakyta wrote:

<snip>


> This is not Delphi related, but did you try this?
> www.powerballs.com
> I had similar problem and doing excercises with power ball helped me
> a lot ;)

This is what i don't get, RSI stands for Repetitive Strain Injury.
So by repeating movement too much, you injure yourself.
So if you do repeated exercizes with that powerball, again, repeating
movement much, you don't injure yourself, and on top of it, you have
less problems with the injuries that you already have..
I don't get that at all. My take on it is that RSI is all between the
ears.

--

Remy Lebeau (TeamB)

unread,
Mar 1, 2007, 3:42:45 AM3/1/07
to

"Dave Nottage [TeamB]" <rot13....@enqfbsg.pbz.nh> wrote in message
news:xn0f30ak4...@forums.borland.com...

> Expanding on my other post, you could call this function in the


OnShow
> event of the form:

That code does not check for buttons that have a different Parent than
the Form itself. You would need a recursive search for that, ie:

function FindDefaultButton(AParent: TWinControl): TButton;
var
I: Integer;
Ctrl: TControl;
begin
Result := nil;
for I := 0 to AParent.ControlCount-1 do
begin
Ctrl := AParent.Controls[I];
if (Ctrl is TButton) and TButton(Ctrl).Default then
begin
Result := TButton(Ctrl);
Exit;
end;
if Ctrl is TWinControl then
begin
Result := FindDefaultButton(TWinControl(Ctrl));
if Result <> nil then Exit;
end;
end;
end;

procedure MouseSnapTo(AForm: TForm);
var
Snap: Integer;
Button: TButton;
Pt: TPoint;


begin
SystemParametersInfo(SPI_GETSNAPTODEFBUTTON, 0, @Snap, 0);
if Snap > 0 then

begin
Button := FindDefaultButton(AForm);
if Button <> nil then
begin
Pt := Button.ClientOrigin;
Inc(Pt.X, Button.ClientWidth div 2);
Inc(Pt.Y, Button.ClientHeight div 2);
Windows.SetCursorPos(Pt.X, Pt.Y);
end;
end;
end;


Gambit


Jolyon Smith

unread,
Mar 1, 2007, 3:47:30 AM3/1/07
to
In article <45e68a06$1...@newsgroups.borland.com>, Hexor...@vaxor.com says...

> This is what i don't get, RSI stands for Repetitive Strain Injury.
> So by repeating movement too much, you injure yourself.

By repeating _specific_ movements that when repeated too often or too
frequently have the potential to cause damage.


> So if you do repeated exercizes with that powerball, again, repeating
> movement much, you don't injure yourself, and on top of it, you have
> less problems with the injuries that you already have.

Different types of movement, different affect on the moving parts.

Sometimes when I drink too much I fall down.
Sometimes when I drink too much I just need the bathroom more.
Sometimes when I drink too much I need the bathroom more and fall down on the
way.

:D

It all depends on _what_ I drink, not the fact that I have been drinking.

;)

MJMatthew

unread,
Mar 1, 2007, 4:34:00 AM3/1/07
to
The dialog components seem to work correctly. save, print etc.

But how do you set the form type to Dialog. I only see BorderStyle with
bsDialog option.

Thanks
Matthew

"Chris Morgan" <chris.nospam at lynxinfo dot co dot uk> wrote in message

MJMatthew

unread,
Mar 1, 2007, 4:58:24 AM3/1/07
to
I appreciate that this is isn't the most important thing in life, but this
type of thing creates confusion. You have forms that don't pick up the
Snap-To setting, whilst dialogs do.

What's the difference ?. I would have thought that any form or dialog with
an OK or Cancel button should implement the Snap-To feature automatically.

It doesn't matter if you like this feature it or not. By default it is
switched off anyway. But for those people that do switch it on, then I
believe it should apply globally.

Just my opinion.

Matthew


"MJMatthew" <REMOVE_THIS_T...@btinternet.com> wrote in message
news:45e56423$1...@newsgroups.borland.com...

MJMatthew

unread,
Mar 1, 2007, 5:01:05 AM3/1/07
to
...and thanks for all the replies and code samples.

Matthew


MJMatthew

unread,
Mar 1, 2007, 5:25:36 AM3/1/07
to

Craig Stuntz [TeamB]

unread,
Mar 1, 2007, 10:35:22 AM3/1/07
to
Marco Caspers wrote:

> I don't get that at all. My take on it is that RSI is all between the
> ears.

Rephrased: "I don't have it and can't personally understand it,
therefore it must not exist?"

Ask a doctor, OK?

--
Craig Stuntz [TeamB] · Vertex Systems Corp. · Columbus, OH
Delphi/InterBase Weblog : http://blogs.teamb.com/craigstuntz
Everything You Need to Know About InterBase Character Sets:
http://blogs.teamb.com/craigstuntz/articles/403.aspx

Pete Fraser

unread,
Mar 1, 2007, 11:21:12 AM3/1/07
to
I've been programming for 25+ years and the only time that
I've suffered from RSI has been when I've been working at
IKEA desks. [Company too trendy to buy proper desks.]
I'm now working at a modified desk (at the right height) and
haven't had RSI for 3 years
So if you do suffer from RSI (and it's not nice) try getting
a desk at the right height for *you* and adjust chairs etc.
It can make a *huge* difference.
Rgds Pete

"Craig Stuntz [TeamB]" <craig_...@nospam.please [a.k.a.
acm.org]> wrote in message
news:45e6f2ba$1...@newsgroups.borland.com...

Ivan Rakyta

unread,
Mar 1, 2007, 12:28:40 PM3/1/07
to
"Pete Fraser" <pete.nospam....@frasersoft.nospam.net> wrote in
message news:45e6...@newsgroups.borland.com...

> I've been programming for 25+ years and the only time that I've suffered
> from RSI has been when I've been working at IKEA desks. [Company too
> trendy to buy proper desks.]
> I'm now working at a modified desk (at the right height) and haven't had
> RSI for 3 years
> So if you do suffer from RSI (and it's not nice) try getting a desk at the
> right height for *you* and adjust chairs etc. It can make a *huge*
> difference.
> Rgds Pete

I have IKEA desk where you can modify height ;)
But you are right, the height is important...
The pain in my hand after 20+ years of programming was so bad, that I have
converted from right handed to left handed and stopped programming for fun
at home...
But now it's not so bad since I use powerball. It realy works, but if I stop
for some months, the pain comes back.


Chris Morgan

unread,
Mar 1, 2007, 3:11:57 PM3/1/07
to
> The dialog components seem to work correctly. save, print etc.
>
> But how do you set the form type to Dialog. I only see BorderStyle with
> bsDialog option.

That's what I meant.

cheers,

Chris


MJMatthew

unread,
Mar 1, 2007, 3:28:05 PM3/1/07
to
It doesn't appear to make any difference, but thanks for suggestion.

Matthew

"Chris Morgan" <chris.nospam at lynxinfo dot co dot uk> wrote in message

news:45e7...@newsgroups.borland.com...

MJMatthew

unread,
Mar 1, 2007, 3:31:49 PM3/1/07
to
Have you tried using wrist splints ?

These worked very well for me and they stopped the pain completely.

Matthew

"Ivan Rakyta" <rakyta_at_stonline.sk> wrote in message

JED

unread,
Mar 1, 2007, 10:10:03 PM3/1/07
to
Remy Lebeau (TeamB) wrote:

> That code does not check for buttons that have a different Parent than
> the Form itself. You would need a recursive search for that, ie:

Code doesn't check if the button is visible and to a lesser extent
enabled as well.

--
TJSDialog - TaskDialog for other operating systems:
http://www.jed-software.com/jsd.htm
Visual Forms IDE Add In: http://www.jed-software.com/vf.htm

Blog: http://jedqc.blogspot.com

Dave Nottage [TeamB]

unread,
Mar 1, 2007, 10:36:39 PM3/1/07
to
JED wrote:

> Code doesn't check if the button is visible and to a lesser extent
> enabled as well.

Whaddya expect in 5 mins? :-P

Hehe.. thanks for the feedback, Jeremy

--
Dave Nottage [TeamB]

0 new messages