Re: Feature Request - "Snap To" default button
- From: "Dave Nottage [TeamB]" <rot13.qnivqa@xxxxxxxxxxxxxx>
- Date: 28 Feb 2007 04:05:36 -0800
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]
.
- Follow-Ups:
- Re: Feature Request - "Snap To" default button
- From: Brad White
- Re: Feature Request - "Snap To" default button
- From: Pete Fraser
- Re: Feature Request - "Snap To" default button
- References:
- Feature Request - "Snap To" default button
- From: MJMatthew
- Re: Feature Request - "Snap To" default button
- From: Ralf Kaiser
- Re: Feature Request - "Snap To" default button
- From: MJMatthew
- Feature Request - "Snap To" default button
- Prev by Date: Re: Feature Request - "Snap To" default button
- Next by Date: Re: Yet another reason for openTools API attention
- Previous by thread: Re: Feature Request - "Snap To" default button
- Next by thread: Re: Feature Request - "Snap To" default button
- Index(es):