It looks like the TNxNumberEdit component is firing the OnChange event when it is destroyed. That's my guess anyway.
I was getting a very uninformative exception message when closing an MDIChild form. The CPU display showed that it had occurred in a procedure called LStrClr, which after an hour with Google learned that this function is used to clear ANSIStrings. I'm not using ASNIStrings in my form.
Anyway, by commenting out code I tracked it down to the OnChange event handler, and then to the part that handles the TNxNumberEdit component OnChange event.
I added a (Sender as TNxNumberEdit).Focused requirement to this block of code and the problem went away.
So, I got my program going again, but I thought I'd let you know what I found, or think I found.
More details, including code, at: https://forums.embar...?...35&tstart=0
Access violation involving TNxNumberEdit
Started by m610, Aug 13 2009 10:23 PM
8 replies to this topic
#1
Posted 13 August 2009 - 10:23 PM
#2
Posted 13 August 2009 - 11:25 PM
Hello m610,
Can you please build for me most simple demo project to help me to track a bug? Thank you.
This will help me.
Best regards
Can you please build for me most simple demo project to help me to track a bug? Thank you.
This will help me.
Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#3
Posted 13 August 2009 - 11:56 PM
PS. Does this error happens when you use NxEdit component, or only on NxNumberEdit? Also, do you use NxNumberEdit or NxSpinEdit? Thank you
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#4
Posted 14 August 2009 - 11:29 AM
QUOTE (Boki (Berg) @ Aug 13 2009, 03:25 PM) <{POST_SNAPBACK}>
Hello m610,
Can you please build for me most simple demo project to help me to track a bug? Thank you.
This will help me.
Best regards
Can you please build for me most simple demo project to help me to track a bug? Thank you.
This will help me.
Best regards
Will do. First thing in the morning.
#5
Posted 14 August 2009 - 11:32 AM
QUOTE (Boki (Berg) @ Aug 13 2009, 03:56 PM) <{POST_SNAPBACK}>
PS. Does this error happens when you use NxEdit component, or only on NxNumberEdit? Also, do you use NxNumberEdit or NxSpinEdit? Thank you 
It only happens for the TNxNumberEdit component. I don have a TNeEdit and TNxSPinEdit, ann TNxComboBox, on the form, in the same procedure, and they are fine. Check the link provided in my original post.
#6
Posted 03 September 2009 - 01:03 AM
Hello m610,
Does this error still happen?
Best regards
Does this error still happen?
Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#7
Posted 31 October 2009 - 04:13 PM
Hello Andy,
Can you please send me a sample code or event better a small project where this AV occur. This will help me to track a this bug.
Thank you
Can you please send me a sample code or event better a small project where this AV occur. This will help me to track a this bug.
Thank you
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
#8
Posted 17 November 2009 - 09:22 PM
QUOTE (Boki (Berg) @ Oct 31 2009, 08:13 AM) <{POST_SNAPBACK}>
Hello Andy,
Can you please send me a sample code or event better a small project where this AV occur. This will help me to track a this bug.
Thank you
Can you please send me a sample code or event better a small project where this AV occur. This will help me to track a this bug.
Thank you
I'm finally getting back to this issue and I think I have resolved it by making a few changes to the GetValue and GetValidText routines, shown below.
Here's what was happening:
I'm using a TNxNumberEdit component with textafter set to some text, such as °C.
I get the value using something like X:=AsFloat or X:=Value or X:=AsInteger in an OnChange event handler.
If I delete all of the text so I could start afresh entering a new number, I get a convert error saying the '' is not a valid integer.
So I changed my code to something like if Text<>'' then X:=AsFloat; That solved part of the problem of the error message, but now I was getting a 0 instead of the FMin value. Also, this works only if I deleted the textafter text as well. If I just use the Del key to delete the numbers, I get the error again once I've deleted the last digit.
The IDE indicates that the error occurred in TNxNumberEdit.GetValue. It was actually occurring in GetValidText, which is called by GetValue, when at the end of this routine it was trying to convert the result to a number so the min and max limits could be applied. If the result was '', an error occurred.
To deal with the FMin problem I edited one line in GetValue. Also, there might have been a small error there. In the if NullText part at the beginning the next line said Value:=0. Shouldn't that have been Result:=0, or FValue:=0?
I am curious as to what the NullText property is used for.
Thanks. I hope this makes it into updates, or else I'll have to change it again.
CODE
function TNxCustomNumberEdit.GetValue: Double;
var ValidText: string;
begin
if (Text = NullText) then
begin
Result := FMin;
Exit;
end;
if Text = '' then
Result := FMin
else
begin
ValidText := GetValidText(Text, eoAllowFloat in FOptions, eoAllowSigns in FOptions);
if ValidText = '' then ValidText := FloatToStr(Min);
if TryStrToFloat(ValidText, Result) then
begin
AdjustToRange(Result);
FValue:= Result;
end
else
Result:= FValue;
end;
end;
var ValidText: string;
begin
if (Text = NullText) then
begin
Result := FMin;
Exit;
end;
if Text = '' then
Result := FMin
else
begin
ValidText := GetValidText(Text, eoAllowFloat in FOptions, eoAllowSigns in FOptions);
if ValidText = '' then ValidText := FloatToStr(Min);
if TryStrToFloat(ValidText, Result) then
begin
AdjustToRange(Result);
FValue:= Result;
end
else
Result:= FValue;
end;
end;
CODE
function TNxCustomNumberEdit.GetValidText(UnCheckedText: string; AllowFloat, AllowSigns: Boolean) : string;
var ...
begin
.
.
.
{ set using max and min }
if Result<>'' then
begin
BoundValue := StrToFloat(Result);
AdjustToRange(BoundValue);
end
else
BoundValue:=FMin;
Result := FloatToStr(BoundValue);
end;
var ...
begin
.
.
.
{ set using max and min }
if Result<>'' then
begin
BoundValue := StrToFloat(Result);
AdjustToRange(BoundValue);
end
else
BoundValue:=FMin;
Result := FloatToStr(BoundValue);
end;
#9
Posted 23 November 2009 - 02:32 AM
Hi,
As far I understand, only code:
need to be added. Thank you
I have already include it in my code.
As far I understand, only code:
CODE
if Result <> '' then
begin
BoundValue := StrToFloat(Result);
AdjustToRange(BoundValue);
end else BoundValue := FMin;
begin
BoundValue := StrToFloat(Result);
AdjustToRange(BoundValue);
end else BoundValue := FMin;
need to be added. Thank you
I have already include it in my code.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











