Jump to content

building component


Mauri

Recommended Posts

I am starting to use the UniGUI framework and I'm creating a new child component inherited from TUniDBLookupComboBox. In this component I need some different behaviors and one of them is an additional research. I have this same component running on the VCL and it creates a query component in the component creation event, making it easier for the programmer does not need to add a TQuery component for each Lookup! I wonder if I can do this using UniGUI as reading the forum I realized that the data connection components need to be in specific places (MainDataModulo or Form)! I'm asking this because my component is giving a memory error and do not know if this is related to ownership of the built in component TQuery

 

Best Regards

 

Mauri

 

Sample:

======

  TDBLookup = class(TUniDBLookupComboBox)
  private
    fQuery: TSQLQuery;
	function SearchRecord: boolean;
	...
  protected
	...
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
	...
  end;

procedure Register;

implementation

constructor TDBLookup.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  fQuery:= TSQLQuery.Create(Self);
  ...
end;

destructor TDBLookup.Destroy;
begin
  try
    if Assigned(fQuery) then
      FreeAndNil(fQuery);
  finally
	...
  end;
  inherited Destroy;
end;

function TDBLookup.SearchRecord: boolean;
begin
  try	
	fQuery.sql.text:= 'Select field from table where ...';
	fQuery.open;
	...
  finally
  end;  
end;

procedure Register;
begin
  RegisterComponents ('COMPS',[TDBLookup]);
end;

initialization
finalization

end.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...