Forum > General
"$if declared()" directive
MarkMLl:
Somewhere around v2.0 Lazarus started adding an assignment to its .lpr file which breaks compatibility with older versions. How does one conditionalise it, since the example below doesn't work:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- RequireDerivedFormResource:=True;{$if declared(Application.Scaled) } Application.Scaled:=True;{$endif } Application.Initialize;
MarkMLl
wp:
I think it came in v1.8. So, you can add LCLVersion to the uses clause of the project file and then put the Application.Scaled into an {$IF LCL_FullVersion >=1080000} directive:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---begin RequireDerivedFormResource:=True; {$IF LCL_FullVersion >= 1080000} Application.Scaled:=True; {$IFEND} Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run;end. But be warned: Sometimes the project file is rewritten by the IDE, and then the Application.Scaled := True will be re-added.
MarkMLl:
Thanks very much for that, I'll investigate: I admit I didn't know about that define.
I routinely insert e.g. handlers for --help and --version into the .lpr just before that point, and /so/ /far/ haven't had the IDE interfere with it. In the current case the .lpr hadn't been rewritten, it was something I'd coded on a PC with a v2.0 IDE and then moved to a newly-rebuilt Raspberry Pi where the compiler and IDE were a bit older.
Slightly later for the record: that needs an explicit import of LCLVersion.
MarkMLl
marcov:
Maybe worth to try TApplication.scaled?
MarkMLl:
--- Quote from: marcov on November 28, 2021, 06:32:15 pm ---Maybe worth to try TApplication.scaled?
--- End quote ---
Regrettably not, I get
gui_test.lpr(51,5) Error: Evaluating a conditional compiling expression
Without meaning to criticise either project, I don't know which is worse: that Lazarus has added something without conditionalising it or that FPC complains about an undefined field without supporting the obvious way of excluding it.
MarkMLl
Navigation
[0] Message Index
[#] Next page