Update of /cvsroot/gexperts/gexperts/unstable/Src/Utils
In directory sc8-pr-cvs2.sourceforge.net:/tmp/cvs-serv14850/Utils
Modified Files:
GX_OtaUtils.pas
Log Message:
Never try to get a native object for a VCL.NET component
Index: GX_OtaUtils.pas
===================================================================
RCS file: /cvsroot/gexperts/gexperts/unstable/Src/Utils/GX_OtaUtils.pas,v
retrieving revision 1.199
retrieving revision 1.200
diff -u -d -r1.199 -r1.200
--- GX_OtaUtils.pas 17 Mar 2007 07:26:30 -0000 1.199
+++ GX_OtaUtils.pas 23 Mar 2007 09:33:44 -0000 1.200
@@ -2528,10 +2528,10 @@
tkWString: Result := Buffer.WString;
tkSet:
begin
- if PreferStrings then
+ if PreferStrings and GxOtaActiveDesignerIsVCL then
begin
NativeObject := GxOtaGetNativeObject(AComponent);
- Assert(Assigned(NativeObject));
+ Assert(Assigned(NativeObject), 'No native object for property ' + PropertyName);
Result := SetToString(FindTypeInfo(NativeObject, PropertyName), Buffer.Int);
end
else
@@ -2539,7 +2539,7 @@
end;
tkEnumeration:
begin
- if PreferStrings then
+ if PreferStrings and GxOtaActiveDesignerIsVCL then
begin
NativeObject := GxOtaGetNativeObject(AComponent);
Assert(Assigned(NativeObject));
@@ -2599,6 +2599,7 @@
VFloat : Extended;
VChar : Char;
VWChar : WChar;
+ VBoolean : Boolean;
function PropertyDescription: string;
begin
@@ -2664,8 +2665,23 @@
// Note: Booleans are of type tkEnumeration
tkEnumeration: begin
- VInteger := GetEnumValueFromStr(NativeObject, PropertyName, Value);
- Result := AComponent.SetPropByName(PropertyName, VInteger);
+ if Assigned(NativeObject) then begin
+ VInteger := GetEnumValueFromStr(NativeObject, PropertyName, Value);
+ Result := AComponent.SetPropByName(PropertyName, VInteger);
+ end
+ else begin // VCL.NET error in BDS 2006: "Invalid property typeinfo type": http://qc.borland.com/wc/qcmain.aspx?d=42751
+ if SameText(Value, 'TRUE') or SameText(Value, 'FALSE') then begin
+ VBoolean := SameText(Value, 'TRUE');
+ Result := AComponent.SetPropByName(PropertyName, VBoolean);
+ end
+ else begin
+ VInteger := StrToIntDef(Value, -99998);
+ if VInteger <> -99998 then
+ Result := AComponent.SetPropByName(PropertyName, VInteger)
+ else
+ raise Exception.CreateFmt('Unsupported property value for %s: %s (try using the integer representing the enum value)', [PropertyDescription, Value]);
+ end;
+ end;
end;
// Support for sets is partial, because we don't support normalizing the values
@@ -2675,7 +2691,7 @@
SetOrdProp(NativeObject, PropertyName, VInteger);
end
else
- raise Exception.CreateFmt('No native object available for to set component property %s', [PropertyDescription]);
+ raise Exception.CreateFmt('No native object available to set component property %s', [PropertyDescription]);
end;
else // Unsupported: tkUnknown, tkMethod, tkInterface, tkDynArray, tkClass, tkArray, tkRecord
@@ -2688,7 +2704,7 @@
CompHandle: TOTAHandle;
begin
Result := nil;
- if AComponent = nil then
+ if (AComponent = nil) or (not GxOtaActiveDesignerIsVCL) then
Exit;
CompHandle := AComponent.GetComponentHandle;
if Assigned(CompHandle) then
|