lazarus编写程序特别是需要交叉编译时,不清楚当前project交叉编译的目标CPU及OS,为方便使用,可以按以下方法(红字部分)修改:
打开lazarus\ide\main.pp,找到procedure TMainIDE.UpdateCaption;
procedure TMainIDE.UpdateCaption; function AddToCaption(const CurrentCaption, CaptAddition: string): String; begin if EnvironmentGuiOpts.Desktop.IDETitleStartsWithProject then Result := CaptAddition + ' - ' + CurrentCaption else Result := CurrentCaption + ' - ' + CaptAddition; end; var rev, NewCaption, NewTitle, ProjectName, DirName,TargetOSCPU: String; begin if MainIDEBar = nil then Exit; if ToolStatus = itExiting then Exit; rev := GetLazarusRevision; if IsNumber(rev) then NewCaption := Format(lisLazarusEditorV + ' r%s', [GetLazarusVersionString, rev]) else NewCaption := Format(lisLazarusEditorV, [GetLazarusVersionString]); NewTitle := NewCaption; if MainBarSubTitle <> '' then NewCaption := AddToCaption(NewCaption, MainBarSubTitle) else begin if Project1 <> nil then begin ProjectName := Project1.GetTitleOrName; if ProjectName <> '' then begin if EnvironmentGuiOpts.Desktop.IDETitleShowsProjectDir then begin DirName := ExtractFileDir(Project1.ProjectInfoFile); TargetOSCPU:=' '+Project1.ActiveBuildMode.CompilerOptions.TargetOS+'-'+Project1.ActiveBuildMode.CompilerOptions.TargetCPU; if trim(TargetOSCPU)='-' then TargetOSCPU:=' '+lowercase({$i %FPCTARGETOS%})+'-'+lowercase({$i %FPCTARGETCPU%}); if DirName <> '' then ProjectName := ProjectName + ' ('+DirName+TargetOSCPU+')'; end; end else ProjectName := lisnewProject; NewTitle := AddToCaption(NewCaption, ProjectName); if EnvironmentGuiOpts.Desktop.IDETitleShowsBuildMode and (Project1.BuildModes.Count > 1) then ProjectName:= ProjectName + ' - ' +Project1.ActiveBuildMode.GetCaption; NewCaption := AddToCaption(NewCaption, ProjectName); end; end; case ToolStatus of itBuilder: NewCaption := Format(liscompiling, [NewCaption]); itDebugger: begin if DebugBoss.Commands - [dcRun, dcStop, dcEnvironment] <> [] then NewCaption := Format(lisDebugging, [NewCaption]) else NewCaption := Format(lisRunning, [NewCaption]); end; else end; MainIDEBar.Caption := NewCaption; Application.Title := NewTitle; end;
修改后重新编译lazarus就可以在标题栏显示目标OS/CPU:
标签:begin,end,ProjectName,标题栏,else,project,NewCaption,lazarus,Project1 From: https://www.cnblogs.com/qiufeng2014/p/18377352