ppVariable Subclass and RAP
Hello All:
I subclassed the DBText component and over-rode the GetTheText method to
allow users to set a "Special" display format for zero value database
fields. This allows users to specify N/A for 0 or null values.
I'd like to do the same thing using ppVariables.
However, the ppVariables calculate their value using RAP. I created a
decendent variable, but overriding the GetTheText method did not work ( the
passed value is not the RAP assigned value ).
Is this possible ??? What have I done wrong below ???
Thank you
Neil Huhta
Listed below is my override of the GetTheText
function TppNHVariable.GetTheText: String;
var
lsText: String;
lsFormat: String;
lValue: Variant;
DoTraditionalFormat:Boolean;
begin
// try lValue := username
// else lvalue:=Value
lValue := GetCustomValue;
if (pppcDesigning in DesignState) and not(Printing) then
lsText := lValue
else
begin
DoTraditionalFormat:=True;
if Assigned(OnFormat) then
begin
lsFormat := '';
FOnFormatIsAssigned:=True;
end
Else
begin
lsFormat := DisplayFormat;
FOnFormatIsAssigned:=False;
end;
if ((DataType=dtCurrency) or (DataType=dtDouble) or
(DataType=dtSingle)) and
(Not(FOnFormatIsAssigned)) and
(FDisplayZeroIgnored<>True) Then
begin
if (DisplayZeroFormat <> Null) and ((lValue = NULL) or (lValue=0))
Then //(lValue=0) and
begin
lsText:=DisplayZeroFormat;
DoTraditionalFormat:=False;
end
end;
if DoTraditionalFormat=True Then
begin
lsText := ppFormat(lsFormat, FDataType, lValue);
end;
end;
if Assigned(OnFormat) then
OnFormat(Self, DisplayFormat, FDataType, lValue, lsText);
Result := lsText;
end; {function, GetTheText}
I subclassed the DBText component and over-rode the GetTheText method to
allow users to set a "Special" display format for zero value database
fields. This allows users to specify N/A for 0 or null values.
I'd like to do the same thing using ppVariables.
However, the ppVariables calculate their value using RAP. I created a
decendent variable, but overriding the GetTheText method did not work ( the
passed value is not the RAP assigned value ).
Is this possible ??? What have I done wrong below ???
Thank you
Neil Huhta
Listed below is my override of the GetTheText
function TppNHVariable.GetTheText: String;
var
lsText: String;
lsFormat: String;
lValue: Variant;
DoTraditionalFormat:Boolean;
begin
// try lValue := username
// else lvalue:=Value
lValue := GetCustomValue;
if (pppcDesigning in DesignState) and not(Printing) then
lsText := lValue
else
begin
DoTraditionalFormat:=True;
if Assigned(OnFormat) then
begin
lsFormat := '';
FOnFormatIsAssigned:=True;
end
Else
begin
lsFormat := DisplayFormat;
FOnFormatIsAssigned:=False;
end;
if ((DataType=dtCurrency) or (DataType=dtDouble) or
(DataType=dtSingle)) and
(Not(FOnFormatIsAssigned)) and
(FDisplayZeroIgnored<>True) Then
begin
if (DisplayZeroFormat <> Null) and ((lValue = NULL) or (lValue=0))
Then //(lValue=0) and
begin
lsText:=DisplayZeroFormat;
DoTraditionalFormat:=False;
end
end;
if DoTraditionalFormat=True Then
begin
lsText := ppFormat(lsFormat, FDataType, lValue);
end;
end;
if Assigned(OnFormat) then
OnFormat(Self, DisplayFormat, FDataType, lValue, lsText);
Result := lsText;
end; {function, GetTheText}
This discussion has been closed.
Comments
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
I am assigning it in the Calc tab of the designer. I thought that took
the place of the OnCalc event.
What do I need to do to create a successful subclass ???
I thought that the value of the ppVariable was passed from function
"GetCustomValue" in procedure "GetTheText"
Unfortunately, GetCustomValue is a private function so I cant get access
to it.
Can you help me on this ???
Neil Huhta
engine. We'll have to dig into a test project to find out. Can you send
your descendent as a starting point for us? It may or may not be a simple
fix but we can look at it. Please send it to support@digital-metaphors.com
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com