Can a Windows GUI program written in Lazarus create a console and write it at run time?

When writing a Lazarus program, you have the option to use $APPTYPE consoleor deselect Win32 GUI Application( -WG) in the project settings.

I noticed that without these options DebugLn, and WriteLnthere are exceptions. Is there a way to create a console, even if the program is not compiled above the above options and then displays it with DebugLnand WriteLn?

+1
source share
2 answers

Delphi. Delphi , , AllocConsole. Lazarus/FreePascal, :

uses
  Windows;
begin
  AllocConsole;      // in Windows unit
  IsConsole := True; // in System unit
  SysInitStdIO;      // in System unit
  // Now you can do Writeln, DebugLn, ...
end.

, . iirc linux , . . , .

+4

, , GUI-, , . .

, , , ,   Application.ShowMainForm:=False;

Application.CreateForm(TForm1, Form1);

.lpr.

, showmessage ().

+2

Source: https://habr.com/ru/post/1538024/


All Articles