I am converting an application from RAD 2006 to RAD 2010 The old application would allow hitting the Enter key and the default button would be activated. The new application needs a left mouse click to activate the button. In addition, when clicking on a form that does not have focus, the old application will bring that form into the foreground. In the new application the background form stays in the background. The old application is on a computer running XP and the new application is on a computer w
ith Win 7. Nothing is different in the forms between the two applications. What can be causing this????
Vote for best question.
Score: 0
# Vote: 0
Date Posted: 26-Dec-2014, at 1:31 PM EST
From: Alan Jordan
Re: RAD 2010 Window focus and Button Default not working
> {quote:title=Tom Brunberg wrote:}{quote}
> Alan Jordan wrote:
>
> > > {quote:title=Tom Brunberg wrote:}{quote}
> > > Alan Jordan wrote:
> > >
> > > > I am converting an application from RAD 2006 to RAD 2010 The old application would allow
> > > > hitting the Enter key and the default button would be activated. The new application needs a
> > > > left mouse click to activate the button. In addition, when clicking on a form that does not
> > > > have focus, the old application will bring that form into the foreground. In the new
> > > > application the background form stays in the background. The old application is on a
> > > > computer running XP and the new application is on a computer w ith Win 7. Nothing is
> > > > different in the forms between the two applications. What can be causing this????
> > >
> > > Alan,
> > >
> > > Make sure the 'Default' property of the button to be the default one is set to True.
> >
> > I have tried this on the XP computer and another Win 7 with the same results. Also, I have other
> > buttons on other forms that are working as designed. I set all the properties on the bad button
> > like the good button and still will not accept the Enter key press. In addition, I put in three
> > OnKey events sending them to the button Onclick event. These don't do anything either. I am
> > totally stumpted, compiler problem??? Here is the code from the dfm for that button: object
> > OKButton: TBitBtn Left = 118 Top = 372 Width = 60
> > Height = 25
> > Caption = 'OK'
> > Default = True
> > DoubleBuffered = True
> > Font.Charset = DEFAULT_CHARSET
> > Font.Color = clWindowText
> > Font.Height = -11
> > Font.Name = 'MS Sans Serif'
> > Font.Style = []
> > Glyph.Data = {
> > DE010000424DDE01000000000000760000002800000024000000120000000100
> > 0400000000006801000000000000000000001000000000000000000000000000
> > 80000080000000808000800000008000800080800000C0C0C000808080000000
> > FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333
> > 3333333333333333333333330000333333333333333333333333F33333333333
> > 00003333344333333333333333388F3333333333000033334224333333333333
> > 338338F3333333330000333422224333333333333833338F3333333300003342
> > 222224333333333383333338F3333333000034222A22224333333338F338F333
> > 8F33333300003222A3A2224333333338F3838F338F33333300003A2A333A2224
> > 33333338F83338F338F33333000033A33333A222433333338333338F338F3333
> > 0000333333333A222433333333333338F338F33300003333333333A222433333
> > 333333338F338F33000033333333333A222433333333333338F338F300003333
> > 33333333A222433333333333338F338F00003333333333333A22433333333333
> > 3338F38F000033333333333333A223333333333333338F830000333333333333
> > 333A333333333333333338330000333333333333333333333333333333333333
> > 0000}
> > NumGlyphs = 2
> > ParentDoubleBuffered = False
> > ParentFont = False
> > TabOrder = 1
> > OnClick = OKButtonClick // never get to this.
> > end
> >
> >
> >
> > > See
> > > http://docwiki.embarcadero.com/VCL/2010/en/StdCtrls.TCustomButton.Default
> > > for more info.
> > >
> > > --
> > > Tom Brunberg
> > > firstname.lastname@welho.com
>
> Alan,
> My previous post was a little premature. The OnClick actually works even without my suggested
> modifications, that is, with the same setup as you already have in your .dfm. *Unless* another
> visible button in earlier tab order also is set with Default=True *or* any other button has focus.
> This is documented for the StdCtrls.TCustomButton.Default property.
> {quote}
> If Default is true, the button's OnClick event handler executes when the user presses Enter.
>
> Although an application can have more than one Default button, the form calls the OnClick event
> handler only for the first visible button in the tab order. Moreover, any button that has focus
> becomes the Default button temporarily; hence, if the user selects another button before pressing
> Enter, the selected button's OnClick event handler executes instead.
> {quote}
>
> What kind of control has had focus at the time you have been testing the Default button?
>
> --
> Tom Brunberg
> firstname.lastname@welho.com
Tom,
Thanks, the tab order was wrong. The first on the list was a panel.
I am still not sure why my background form does not come to foreground when clicked on. Anyway, I have one problem solved. Thanks again.
Alan
Vote for best answer.
Score: 0
# Vote: 0
Date Posted: 29-Dec-2014, at 7:34 AM EST
From: Alan Jordan
Re: RAD 2010 Window focus and Button Default not working
Alan Jordan wrote:
> > {quote:title=Tom Brunberg wrote:}{quote}
> > Alan Jordan wrote:
> >
> > > I am converting an application from RAD 2006 to RAD 2010 The old application would allow
> > > hitting the Enter key and the default button would be activated. The new application needs a
> > > left mouse click to activate the button. In addition, when clicking on a form that does not
> > > have focus, the old application will bring that form into the foreground. In the new
> > > application the background form stays in the background. The old application is on a
> > > computer running XP and the new application is on a computer w ith Win 7. Nothing is
> > > different in the forms between the two applications. What can be causing this????
> >
> > Alan,
> >
> > Make sure the 'Default' property of the button to be the default one is set to True.
>
> I have tried this on the XP computer and another Win 7 with the same results. Also, I have other
> buttons on other forms that are working as designed. I set all the properties on the bad button
> like the good button and still will not accept the Enter key press. In addition, I put in three
> OnKey events sending them to the button Onclick event. These don't do anything either. I am
> totally stumpted, compiler problem??? Here is the code from the dfm for that button: object
> OKButton: TBitBtn Left = 118 Top = 372 Width = 60
> Height = 25
> Caption = 'OK'
> Default = True
> DoubleBuffered = True
> Font.Charset = DEFAULT_CHARSET
> Font.Color = clWindowText
> Font.Height = -11
> Font.Name = 'MS Sans Serif'
> Font.Style = []
> Glyph.Data = {
> DE010000424DDE01000000000000760000002800000024000000120000000100
> 0400000000006801000000000000000000001000000000000000000000000000
> 80000080000000808000800000008000800080800000C0C0C000808080000000
> FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333
> 3333333333333333333333330000333333333333333333333333F33333333333
> 00003333344333333333333333388F3333333333000033334224333333333333
> 338338F3333333330000333422224333333333333833338F3333333300003342
> 222224333333333383333338F3333333000034222A22224333333338F338F333
> 8F33333300003222A3A2224333333338F3838F338F33333300003A2A333A2224
> 33333338F83338F338F33333000033A33333A222433333338333338F338F3333
> 0000333333333A222433333333333338F338F33300003333333333A222433333
> 333333338F338F33000033333333333A222433333333333338F338F300003333
> 33333333A222433333333333338F338F00003333333333333A22433333333333
> 3338F38F000033333333333333A223333333333333338F830000333333333333
> 333A333333333333333338330000333333333333333333333333333333333333
> 0000}
> NumGlyphs = 2
> ParentDoubleBuffered = False
> ParentFont = False
> TabOrder = 1
> OnClick = OKButtonClick // never get to this.
> end
>
>
>
> > See
> > http://docwiki.embarcadero.com/VCL/2010/en/StdCtrls.TCustomButton.Default
> > for more info.
> >
> > --
> > Tom Brunberg
> > firstname.lastname@welho.com
Alan,
My previous post was a little premature. The OnClick actually works even without my suggested
modifications, that is, with the same setup as you already have in your .dfm. *Unless* another
visible button in earlier tab order also is set with Default=True *or* any other button has focus.
This is documented for the StdCtrls.TCustomButton.Default property.
{quote}
If Default is true, the button's OnClick event handler executes when the user presses Enter.
Although an application can have more than one Default button, the form calls the OnClick event
handler only for the first visible button in the tab order. Moreover, any button that has focus
becomes the Default button temporarily; hence, if the user selects another button before pressing
Enter, the selected button's OnClick event handler executes instead.
{quote}
What kind of control has had focus at the time you have been testing the Default button?
--
Tom Brunberg
firstname.lastname@welho.com
Vote for best answer.
Score: 0
# Vote: 0
Date Posted: 27-Dec-2014, at 3:45 PM EST
From: Tom Brunberg
Re: RAD 2010 Window focus and Button Default not working
Alan Jordan wrote:
> > {quote:title=Tom Brunberg wrote:}{quote}
> > Alan Jordan wrote:
> >
> > > I am converting an application from RAD 2006 to RAD 2010 The old application would allow
> > > hitting the Enter key and the default button would be activated. The new application needs a
> > > left mouse click to activate the button. In addition, when clicking on a form that does not
> > > have focus, the old application will bring that form into the foreground. In the new
> > > application the background form stays in the background. The old application is on a
> > > computer running XP and the new application is on a computer w ith Win 7. Nothing is
> > > different in the forms between the two applications. What can be causing this????
> >
> > Alan,
> >
> > Make sure the 'Default' property of the button to be the default one is set to True.
>
> I have tried this on the XP computer and another Win 7 with the same results. Also, I have other
> buttons on other forms that are working as designed. I set all the properties on the bad button
> like the good button and still will not accept the Enter key press. In addition, I put in three
> OnKey events sending them to the button Onclick event. These don't do anything either. I am
> totally stumpted, compiler problem??? Here is the code from the dfm for that button: object
> OKButton: TBitBtn Left = 118 Top = 372 Width = 60
> Height = 25
> Caption = 'OK'
> Default = True
> DoubleBuffered = True
> Font.Charset = DEFAULT_CHARSET
> Font.Color = clWindowText
> Font.Height = -11
> Font.Name = 'MS Sans Serif'
> Font.Style = []
> Glyph.Data = {
> DE010000424DDE01000000000000760000002800000024000000120000000100
> 0400000000006801000000000000000000001000000000000000000000000000
> 80000080000000808000800000008000800080800000C0C0C000808080000000
> FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333
> 3333333333333333333333330000333333333333333333333333F33333333333
> 00003333344333333333333333388F3333333333000033334224333333333333
> 338338F3333333330000333422224333333333333833338F3333333300003342
> 222224333333333383333338F3333333000034222A22224333333338F338F333
> 8F33333300003222A3A2224333333338F3838F338F33333300003A2A333A2224
> 33333338F83338F338F33333000033A33333A222433333338333338F338F3333
> 0000333333333A222433333333333338F338F33300003333333333A222433333
> 333333338F338F33000033333333333A222433333333333338F338F300003333
> 33333333A222433333333333338F338F00003333333333333A22433333333333
> 3338F38F000033333333333333A223333333333333338F830000333333333333
> 333A333333333333333338330000333333333333333333333333333333333333
> 0000}
> NumGlyphs = 2
> ParentDoubleBuffered = False
> ParentFont = False
> TabOrder = 1
> OnClick = OKButtonClick // never get to this.
> end
>
>
>
> > See
> > http://docwiki.embarcadero.com/VCL/2010/en/StdCtrls.TCustomButton.Default
> > for more info.
> >
> > --
> > Tom Brunberg
> > firstname.lastname@welho.com
Alan,
It was good that you posted the button part of the .dfm. I see that ModalResult is the default
mrNone (since it is not listed in the .dfm). Set that to *mrOK*.
I believe that you originally have set the buttons 'Kind' property to 'bkOK'. This will
automatically also set other properties (like Glyf, ModalResult et.al.) accordingly. Now, 'Kind'
seems to be 'bkCustom' (again since it is not listed in the .dfm). If above setting of ModalResult
for some reason doesn't help, set Kind to bkOK.
--
Tom Brunberg
firstname.lastname@welho.com
Vote for best answer.
Score: 0
# Vote: 0
Date Posted: 27-Dec-2014, at 3:01 PM EST
From: Tom Brunberg
Re: RAD 2010 Window focus and Button Default not working
> {quote:title=Tom Brunberg wrote:}{quote}
> Alan Jordan wrote:
>
> > I am converting an application from RAD 2006 to RAD 2010 The old application would allow hitting
> > the Enter key and the default button would be activated. The new application needs a left mouse
> > click to activate the button. In addition, when clicking on a form that does not have focus, the
> > old application will bring that form into the foreground. In the new application the background
> > form stays in the background. The old application is on a computer running XP and the new
> > application is on a computer w ith Win 7. Nothing is different in the forms between the two
> > applications. What can be causing this????
>
> Alan,
>
> Make sure the 'Default' property of the button to be the default one is set to True.
I have tried this on the XP computer and another Win 7 with the same results. Also, I have other buttons on other forms that are working as designed. I set all the properties on the bad button like the good button and still will not accept the Enter key press. In addition, I put in three OnKey events sending them to the button Onclick event. These don't do anything either. I am totally stumpted, compiler problem???
Here is the code from the dfm for that button:
object OKButton: TBitBtn
Left = 118
Top = 372
Width = 60
Height = 25
Caption = 'OK'
Default = True
DoubleBuffered = True
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
Glyph.Data = {
DE010000424DDE01000000000000760000002800000024000000120000000100
0400000000006801000000000000000000001000000000000000000000000000
80000080000000808000800000008000800080800000C0C0C000808080000000
FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333333333
3333333333333333333333330000333333333333333333333333F33333333333
00003333344333333333333333388F3333333333000033334224333333333333
338338F3333333330000333422224333333333333833338F3333333300003342
222224333333333383333338F3333333000034222A22224333333338F338F333
8F33333300003222A3A2224333333338F3838F338F33333300003A2A333A2224
33333338F83338F338F33333000033A33333A222433333338333338F338F3333
0000333333333A222433333333333338F338F33300003333333333A222433333
333333338F338F33000033333333333A222433333333333338F338F300003333
33333333A222433333333333338F338F00003333333333333A22433333333333
3338F38F000033333333333333A223333333333333338F830000333333333333
333A333333333333333338330000333333333333333333333333333333333333
0000}
NumGlyphs = 2
ParentDoubleBuffered = False
ParentFont = False
TabOrder = 1
OnClick = OKButtonClick // never get to this.
end
> See
> http://docwiki.embarcadero.com/VCL/2010/en/StdCtrls.TCustomButton.Default
> for more info.
>
> --
> Tom Brunberg
> firstname.lastname@welho.com
Vote for best answer.
Score: 0
# Vote: 0
Date Posted: 27-Dec-2014, at 2:12 PM EST
From: Alan Jordan
Re: RAD 2010 Window focus and Button Default not working
Alan Jordan wrote:
> I am converting an application from RAD 2006 to RAD 2010 The old application would allow hitting
> the Enter key and the default button would be activated. The new application needs a left mouse
> click to activate the button. In addition, when clicking on a form that does not have focus, the
> old application will bring that form into the foreground. In the new application the background
> form stays in the background. The old application is on a computer running XP and the new
> application is on a computer w ith Win 7. Nothing is different in the forms between the two
> applications. What can be causing this????
Alan,
Make sure the 'Default' property of the button to be the default one is set to True.
See
http://docwiki.embarcadero.com/VCL/2010/en/StdCtrls.TCustomButton.Default
for more info.
--
Tom Brunberg
firstname.lastname@welho.com
Vote for best answer.
Score: 0
# Vote: 0
Date Posted: 27-Dec-2014, at 6:08 AM EST
From: Tom Brunberg
Re: RAD 2010 Window focus and Button Default not working
> {quote:title=Alan Jordan wrote:}{quote}
> I am converting an application from RAD 2006 to RAD 2010 The old application would allow hitting the Enter key and the default button would be activated. The new application needs a left mouse click to activate the button. In addition, when clicking on a form that does not have focus, the old application will bring that form into the foreground. In the new application the background form stays in the background. The old application is on a computer running XP and the new application is on a computer
with Win 7. Nothing is different in the forms between the two applications. What can be causing this????
Start by running the 2 app on the other OSs eg 2006 on win7 and 2010 on XP to eliminate the OS / hardware as your problem
--
Linden
"Mango" was Cool but "Wasabi" was Hotter but remember it's all in the "source"