Log On
Embarcadero Home
Watch, Follow, &
Connect with Us
Share This
QualityCentral
Communities
Articles
Blogs
Resources
Downloads
Help
QualityCentral
Delphi-BCB
IDE
Add Component Template
Background compile
Batch file target
Block Completion
Build Tools
Caliber
Class Completion
Class Explorer
Code Browsing
Code Completion
Code Editor
Code Explorer
Code Parameters
Code Templates
Compiler Message Window
Deployment Manager
Dialogs
Direct
Docking
File Browser
File Handling
Form Designer
Help
History View
IDE Insight
Memory Issues
Menu Designer
Menus
Module Manager
Multi-Monitor Support
Object Inspector
Object TreeView
Open Tools API
Packages
Performance
Printing
Project Explorer(old Object Browser)
Project Management
Refactoring
Repository
Save Desktop
Search
Start Page
Starteam
Startup/Shutdown
Structure Pane
System Resources
ToDoList
Tool Palette
Toolbars/Status Line
Translation Tools
Unit Testing
Version Control
VersionInfo
Views
Visual Form Inheritance
Workgroup(PVCS)
You are not logged in.
Help
Print
Public Report
Report From:
Delphi-BCB/IDE/Form Designer
[ Add a report in this area ]
Report #:
41560
Status:
Reported
Snap To default button
Project:
Delphi
Build #:
10.0.2288.42451
Version:
10.0
Submitted By:
Matthew Marsh
Report Type:
New Feature Request
Date Reported:
3/1/2007 2:20:09 AM
Severity:
Commonly encountered problem
Last Updated:
Platform:
All platforms
Internal Tracking #:
Resolution:
None
Resolved in Build:
:
None
Duplicate of:
None
Voting and Rating
Overall Rating:
(2 Total Ratings)
5.00 out of 5
Total Votes:
11
Description
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 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.
Matthew
Steps to Reproduce:
Not applicable.
Workarounds
Provided by TeamB members: Dave Nottage and Remy Lebeau
> 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;
Attachment
None
Comments
Jeremy North at 3/1/2007 3:02:01 AM
-
The workaround should also check to see if the button is visible and enabled
View Your Reports
Search
Server Response from: ETNACODE01
Developer Tools
Blackfish SQL
C++Builder
Delphi
FireMonkey
Prism
InterBase
JBuilder
J Optimizer
HTML5 Builder
3rdRail & TurboRuby
Database Tools
Change Manager
DBArtisan
DB Optimizer
ER/Studio
Performance Center
Rapid SQL
Technical Articles
Tutorials
White Papers
Press Releases
Newsletters
Add Content (GetPublished)
Audio
Audio & Video
Video
Bugs & Suggestions (QualityCentral)
Discussion Forums
Examples (CodeCentral)
Tags
Technology Partners
Downloads
Free Trials
Registered User Downloads
Beta Programs
Add Content (GetPublished)
Articles
Blogs
Bugs & Suggestions (QualityCentral)
Discussion Forums
Examples (CodeCentral)
Member Services
About
Connect with Us