PeterPanettone 157 Posted March 9, 2020 I want to either expand the functionality of the Get Component Names GExpert to somehow include the CLASSNAME of the selected component(s) or to create a similar GExpert which gets the CLASSNAME instead of the component name. (The former solution could include an additional keyboard-shortcut configuration for the classname, inside the same GExpert). So I looked at the GxOtaGetComponentName function: function GxOtaGetComponentName(const AComponent: IOTAComponent): WideString; var Component: TComponent; begin Assert(Assigned(AComponent)); Result := GxOtaGetComponentPropertyAsString(AComponent, NamePropertyName); if IsEmpty(Result) then begin Component := GxOtaGetNativeComponent(AComponent); if Assigned(Component) then Result := Component.Name; end; end; The parameter NamePropertyName is defined as a constant with the value 'Name'. Since there is no constant NamePropertyClassName, I assume that the class name of a component can be in any case simply retrieved by Component.ClassName and has not necessarily be retrieved by GxOtaGetComponentPropertyAsString. So I would naively propose this function to get the class name: function GxOtaGetComponentClassName(const AComponent: IOTAComponent): WideString; var Component: TComponent; begin Result := ''; Assert(Assigned(AComponent)); Component := GxOtaGetNativeComponent(AComponent); if Assigned(Component) then Result := Component.ClassName; end; What do you think? Share this post Link to post
PeterPanettone 157 Posted March 9, 2020 Now I have tried it out by replacing the old function GxOtaGetComponentName with the new function GxOtaGetComponentClassName in the unit GX_CopyComponentNames: CurrentComponent := FormEditor.GetSelComponent(i); //ComponentName := GxOtaGetComponentName(CurrentComponent); ComponentName := GxOtaGetComponentClassName(CurrentComponent); It works perfectly. Now it's time to decide how the new functionality Get Component ClassNames should be implemented: 1. Combine the component name and class name in one string, e.g.: ComponentName (ComponentClassname) 2. Provide a second keyboard-shortcut box for the class name inside the existing GExpert, e.g. F5 for the component name and CTRL+F5 for the component class name 3. Create a separate GExpert for the component's class name. Plus: Provide a small configuration dialog where one of the above choices could be configured. Please select your favorite choice. Share this post Link to post