[Lazarus] ide.lpk 's project.pp and freepascal project.pp, same filename problem
Mattias Gaertner
nc-gaertnma at netcologne.de
Mon Sep 23 12:46:32 CEST 2013
On Mon, 23 Sep 2013 13:17:15 +0300
FreeMan <freeman35 at delphiturkiye.com> wrote:
> All voits goes to Mattias
> Thank you so much Mattias, I'm so happy today. I added my codes
>
> var LazProject: TLazProject;
> LazFile: TLazProjectFile;
> aDesigner : TComponentEditorDesigner;
> .......
> LV.Items.Clear;
> LazProject:=LazarusIDE.ActiveProject;
> if LazProject<>nil then begin
> Self.Caption := Format('Project detail form [%s]',
> [LazProject.GetTitleOrName]);
> for i:=0 to LazProject.FileCount-1 do begin
> LazFile:=LazProject.Files[i];
> if LazFile.IsPartOfProject then begin
> if FilenameIsPascalUnit(LazFile.Filename)then begin
> L:=LV.Items.Add;
> L.Caption := ExtractFileName(LazFile.Filename);
> //I was work for this two lines :)
> aDesigner:=TComponentEditorDesigner(LazarusIDE.GetDesignerWithProjectFile(LazFile,
> True));
The GetDesignerWithProjectFile will load the form and open the
designer if not yet done.
> L.Data := aDesigner.PropertyEditorHook.LookupRoot;
aDesigner.PropertyEditorHook is GlobalDesignHook.
aDesigner.PropertyEditorHook.LookupRoot is the currently selected
form/datamodule/whatever, which might not be the aDesigner component.
Use aDesigner.Form instead.
> S := ConcatPaths([
> ExtractFileDir(LazFile.Filename),ExtractFileNameOnly(LazFile.Filename)]);
Maybe you are searching for ChangeFileExt?
Keep in mind that LazFile.Filename might be 'unit1.pas' when the file
was newly created and not yet saved.
> if FileExists(S+'.lfm')then
> L.SubItems.Add(ExtractFileName(S+'.lfm'))
> else if FileExists(S+'.dfm')then
> L.SubItems.Add(ExtractFileName(S+'.dfm'))
> else L.SubItems.Add('');
> L.SubItems.Add(ExtractFileDir(LazFile.Filename));
> L.Checked := Pos(LazFile.Filename, OpenedFiles)>0;
> end;
> end;
> end;
> end else begin
> L.Caption := 'Project name';
> L.SubItems.Add('');
> L.SubItems.Add('');
> end;
Mattias
More information about the Lazarus
mailing list