Forum > Options

[SOLVED] {$APPTYPE CONSOLE} {$APPTYPE GUI} please where to set?

(1/4) > >>

KodeZwerg:
Hello community,

I do code on/for Windows Operating System using Lazarus/FPC/WidgetSet for Windows.

Where can I enable that Lazarus does apply {$APPTYPE CONSOLE} or {$APPTYPE GUI} to the .lpr file please?
Whenever I do say "Create a new project" I would want to have that in my .lpr file added.
Are there templates I can edit?
Please help a beginner.

KodeZwerg:
Sorry, forgot to say: Lazarus 2.2.2 (rev lazarus_2_2_2-0-g537f43754c) FPC 3.2.2 x86_64-win64-win32/win64

Thaddy:
You should do that in the lpr file - on the top - or in the Lazarus IDE indeed.
When you encounter a console application example by me and others that often reads like this:
--- 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";}};} ---{$ifdef mswindows}{$define apptype console}{$endif}This is only necessary for the Windows platform.
What happens is that it links in support to read and write to/from the console, so error 103 will not be triggered.
OTOH you can also define {$apptype gui} which means that the console support code is skipped.
On many supported OS's this is not an issue, but for windows it is.

KodeZwerg:
Thanks for your reply.
My question still is, where can I enable an option that Lazarus add this automatic for me without need to check/edit the .lpr afterwards.
Or where does Lazarus take the clean/empty template from so I add those line within to never need to think about it anymore please.


--- Quote from: Thaddy on November 24, 2022, 04:17:51 pm ---When you encounter a console application example by me and others that often reads like this:
--- 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";}};} ---{$ifdef mswindows}{$define apptype console}{$endif}
--- End quote ---
it should be like this to 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";}};} ---{$ifdef mswindows}{$apptype console}{$endif}

Thaddy:
file | new | simple program
but there are at least two more options I am aware of. (but note I do not use Lazarus very much, since my code is centered around networks and do not need a GUI, except for control)

Navigation

[0] Message Index

[#] Next page

Go to full version