Can't hide main window lazarus / 67-Windows ---------------------------------------------------------------------- TyneBridges · 2021-01-09 15:20 I'm trying to create a project in Windows where the main window is hidden. It's converted from Delphi where the usual advice worked. However, trying to replicate this in Lazarus gives me a visible window that looks like a console window except that it has my application icon, as shown. The obvious cause would be writing to the console but I've searched through my code for references to Write and Writeln followed immediately by (' and there are none. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i My project source file ends as follows: begin     Application.Initialize;     Application.ShowMainForm:= False;     Application.Title:= 'My Title';     Application.CreateForm(THSForm, HSForm);     Application.Run;end.    There is a lot of code in FormCreate that I tried commenting out completely (leaving just the header and Begin and End) but, after recompiling, the form still showed. I have no OnShow or OnActivate event. Has anybody any idea why the application would be visible despite this? My application is a Windows GUI one and does not use the Console. ---------------------------------------------------------------------- dseligo · 2021-01-09 15:39 I just tried this to put this line "Application.ShowMainForm:=False;" in some test project and form isn't shown - Lazarus 2.0.10 on Windows. So I guess generally Lazarus is working fine. Try to create new project, put "Application.ShowMainForm:=False;" in it and see if it works. If it works, then make some other form main in your project - see if it is related to the main form. You don't create anything else (forms, data modules) in your project source? Code you've shown between "begin" and "end." is all? ---------------------------------------------------------------------- TyneBridges · 2021-01-09 16:01 Thanks dseligo. Yes, the code I quoted is everything apart from the preamble below. I'll try your suggestion with a blank project. (DiscFrm referenced below is a disclaimer that I do show after the main form is initialised and, ironically, that isn't displaying correctly either - it shows only as a title bar; but I'll tackle that when I get this issue fixed.) Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program Logr; {$MODE Delphi} uses  Forms, Interfaces,  hsave in 'hsave.pas' {HSForm},  discfrm in 'discfrm.pas' {Disclaimer},  Windows; {$R *.res} ---------------------------------------------------------------------- TyneBridges · 2021-01-09 16:20 The blank project test worked. The application was invisible and could only be seen in Windows' task list, as I would expect. Would my problem be related to having a tray icon? The following was in the code I had commented out but my original application window still showed even when this wasn't invoked.Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i       With TrayIconData do        begin            cbSize:= SizeOf(TrayIconData);            hWnd:= Handle; // Note: different from Delphi which was just Wnd            uID:= 0;            uFlags:= NIF_MESSAGE + NIF_ICON + NIF_TIP;            uCallBackMessage:= WM_ICONTRAY;            hIcon:= Application.Icon.Handle;            StrPCopy(szTip, Application.Title);        end;        Shell_NotifyIconW(NIM_ADD, @TrayIconData); //Note: needed amendment from Delphi        If Debugging then        begin            Writeln(DL, 'Added Tray Icon ' + DateTimeToStr(Now));            Flush(DL);        end;     Maybe that's a red herring: I've just commented out the above again and recompiled, and my application still showed as in my original image.  I don't think I can change my main form without messing up the project badly, since there's a lot of initialisation (opening of files behind the scenes) in the initial form's OnCreate event. Any further ideas/help from anyone would be welcome. Thanks. ---------------------------------------------------------------------- PascalDragon · 2021-01-10 10:30 Quote from: TyneBridges on January 09, 2021, 05:20:32 pmAny further ideas/help from anyone would be welcome. Thanks. Is Project Settings -> Compiler Settings -> Configuration and Targets -> Win32-GUI-Application enabled in your project? Alternatively you could display the value of the System.IsConsole variable in your application to see whether the RTL considered your application to be a console one. ---------------------------------------------------------------------- TyneBridges · 2021-01-10 12:50 Quote from: PascalDragon on January 10, 2021, 11:30:07 amIs Project Settings -> Compiler Settings -> Configuration and Targets -> Win32-GUI-Application enabled in your project? Alternatively you could display the value of the System.IsConsole variable in your application to see whether the RTL considered your application to be a console one. Thanks PascalDragon! I have ticked this in the Project Settings and it seems to have fixed the problem. I find this a confusing option. I'm using the 64 bit compiler and TargetOS is set to Win64 - will my application still be a true 64 bit one if "Win 32 GUI application" is selected"? I'll be scanning for running processes and need to include 64 bit ones in the list. ---------------------------------------------------------------------- lucamar · 2021-01-10 14:31 Quote from: TyneBridges on January 10, 2021, 01:50:37 pmI find this a confusing option. I'm using the 64 bit compiler and TargetOS is set to Win64 - will my application still be a true 64 bit one if "Win 32 GUI application" is selected"? Yeah, it's a bit confusing and you'll find some other places like this --probably a historical artifact. But don't worry: in this (and those other cases) "Win32" really means generic "Windows". ---------------------------------------------------------------------- PascalDragon · 2021-01-11 13:09 Quote from: TyneBridges on January 10, 2021, 01:50:37 pmI find this a confusing option. I'm using the 64 bit compiler and TargetOS is set to Win64 - will my application still be a true 64 bit one if "Win 32 GUI application" is selected"? I'll be scanning for running processes and need to include 64 bit ones in the list. That option can be worded better (you can open a bug report for that if you want), but what the -WG option does is to change the subsystem type of the generated executable from Console to GUI, it doesn't change anything regarding the targeted OS. The same can be achieved by using {$apptype gui} in the main project file (see here). Console type applications always have a console associated with them so Windows starts one if it isn't started from a console while GUI applications (usually) have none, so they don't get a console. Delphi by default assumes that the application is a GUI application while for FPC the default is Console. ---------------------------------------------------------------------- Ed78z · 2023-09-28 17:38 Quote from: dseligo on January 09, 2021, 04:39:34 pmI just tried this to put this line "Application.ShowMainForm:=False;" in some test project and form isn't shown - Lazarus 2.0.10 on Windows. So I guess generally Lazarus is working fine. Try to create new project, put "Application.ShowMainForm:=False;" in it and see if it works. If it works, then make some other form main in your project - see if it is related to the main form. You don't create anything else (forms, data modules) in your project source? Code you've shown between "begin" and "end." is all? I tried this but didn't work for me. Application.Initialize; Application.ShowMainForm:=False; Application.CreateForm(TForm1, Form1); Any idea why this is not working? (Lazarus 2.2.6 on Win10 x64) ---------------------------------------------------------------------- zeljko · 2023-09-28 18:03 Works ok here, Linux Mint 20.1 64bit, Qt4, Qt5 ,Qt6, gtk2. Does not work with gtk3 (shows main form), but probably such stuff isn't implemented in gtk3 yet. All tested with trunk lazarus. ---------------------------------------------------------------------- Ed78z · 2023-09-28 19:07 Quote from: zeljko on September 28, 2023, 08:03:00 pmWorks ok here, Linux Mint 20.1 64bit, Qt4, Qt5 ,Qt6, gtk2. Does not work with gtk3 (shows main form), but probably such stuff isn't implemented in gtk3 yet. All tested with trunk lazarus. I just solved the issue: 1)   Application.CreateForm(TForm1, Form1);   Application.ShowMainForm:=False;   <-- IN THIS LOCATION   Application.Run; 2)   procedure TForm1.FormCreate(Sender: TObject);   begin      Form1.Visible:=False;   <-- ADD THIS With both 1&2 applied to the program, the program starts in hidden status! ---------------------------------------------------------------------- zeljko · 2023-09-29 06:16 It's bug in win32 ws and should be reported.