BantuKumar Posted April 8, 2016 Posted April 8, 2016 Hi, I have my custom controls that I have derived from different classes like TComponent, TControls, TWinControl, TCustomPanel etc. Now I want to use them into UniGUI application. I do not want to rewrite the code of my control for UniGUI, what I want is to change/modify the implementation (wherever required) so that I can use the same control over UniGUI application. As of now I tried to change the hierarchy of my controls to corresponding UniGUI classes such as TUniControl, TUniComponent etc. and overridden few methods such as ConfigJSClasses, VCLControlClassName, WebCreate etc. but it is not working as I am expecting. Please suggest is this the right way to go? If Yes then what else is required to make is work? If NO then please suggest a solution for this? Thanks in Advance. Quote
bugra Posted April 8, 2016 Posted April 8, 2016 Hi, Creating a custom uni component is same as delphi.Create a bpl package, add references and write component unit. In delphi that Unit's parent is usually TControl therefore in unigui parent is usually TUniControl. Your Unit uses some Unit like uniGUIBaseClasses, uniGUIClasses. Every uniGUI component need thoose procedures in protected area procedure LoadCompleted; override; procedure ConfigJSClasses(ALoading: Boolean); override; procedure WebCreate; override; this procedures inherited parented class. LoadCompleted usally uses to add JSConfig properties to Component. For example procedure TUniColorPalette.LoadCompleted; begin inherited; JSConfig('someConfig', [FConfigValue]); // FConfigValue defined in unit's private area end; this someConfig came from ExtJS class you use. ConfigJSClasses uses to define which ExtJS class you use. This class is here http://docs.sencha.com/extjs/4.2.3/#!/api If you create new component this procedure is something like that procedure TUniColorPalette.ConfigJSClasses(ALoading: Boolean); begin inherited; JSObjects.DefaultJSClassName:='Ext.somepackage.SomeExtJSClass'; end; If you create a component that parent some other uniComponent inherited is enough. WebCreate procedure uses to value assignment in your component. For Example procedure TUniCustomCheckBox.WebCreate; begin inherited; Width := 97; Height := 17; end; Also you need a Constructure. It also uses to value assignment. It's like constructor TUniBaseButton.Create(AOwner: TComponent); begin inherited; Width:=75; Height:=25; ParentColor := False; end; After all is done, build and install your package. It's add your component wherever you choose. For more information you can examine an uniComponent units. Quote
BantuKumar Posted April 11, 2016 Author Posted April 11, 2016 Hi, Creating a custom uni component is same as delphi.Create a bpl package, add references and write component unit. In delphi that Unit's parent is usually TControl therefore in unigui parent is usually TUniControl. Your Unit uses some Unit like uniGUIBaseClasses, uniGUIClasses. Every uniGUI component need thoose procedures in protected area procedure LoadCompleted; override; procedure ConfigJSClasses(ALoading: Boolean); override; procedure WebCreate; override; this procedures inherited parented class. LoadCompleted usally uses to add JSConfig properties to Component. For example procedure TUniColorPalette.LoadCompleted; begin inherited; JSConfig('someConfig', [FConfigValue]); // FConfigValue defined in unit's private area end; this someConfig came from ExtJS class you use. ConfigJSClasses uses to define which ExtJS class you use. This class is here http://docs.sencha.com/extjs/4.2.3/#!/api If you create new component this procedure is something like that procedure TUniColorPalette.ConfigJSClasses(ALoading: Boolean); begin inherited; JSObjects.DefaultJSClassName:='Ext.somepackage.SomeExtJSClass'; end; If you create a component that parent some other uniComponent inherited is enough. WebCreate procedure uses to value assignment in your component. For Example procedure TUniCustomCheckBox.WebCreate; begin inherited; Width := 97; Height := 17; end; Also you need a Constructure. It also uses to value assignment. It's like constructor TUniBaseButton.Create(AOwner: TComponent); begin inherited; Width:=75; Height:=25; ParentColor := False; end; After all is done, build and install your package. It's add your component wherever you choose. For more information you can examine an uniComponent units. Thank you form sharing this information. It will be helpful. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.