Duplicated icon in the Windows Taskbar lazarus / 21-General ---------------------------------------------------------------------- w click · 2026-02-13 16:47 I had a program that sat in the Windows 10 taskbar, click it and it runs.  The icon is still there.  You can click the icon to minimise and restore it, exactly as you'd want and expect. I wrote another version of the same program, but now when it runs, there are two icons in the taskbar, one on top of the other.  When I hover over them, I get two versions of the program appear as floating options – the right brings the program up, the left does nothing.  I did change form1's borderstyle to bsnone, but that's not it, as it doesn't fix it when I change it back.  I mention it because that's the sort of thing I've been adjusting in this version.  I've messed something up. Anyone any idea how to get rid of this duplication? ---------------------------------------------------------------------- w click · 2026-02-15 11:39 Anyone? ---------------------------------------------------------------------- jamie · 2026-02-15 12:15 Do you have that app setup in Autorun when the OS starts? If so, remove the old one. also, you may want to have windows rebuild its icon cache, you can find info on that online. Sounds more like a windows problem to me. jamie ---------------------------------------------------------------------- CM630 · 2026-02-15 12:24 I your app creates five windows, you will have 5 items in the task bar. If you use the systray - if you run and stop a program ten times,you will have ten icons, but they disapper when clicked or focused. You wrote Windows 10, but maybe it is worth mentioning, that the taskbar of Windows 11 is not ready for usage yet, I have mo idea if they intend to fix it. ---------------------------------------------------------------------- w click · 2026-02-15 13:57 Jamie: I do have the app set to run on startup.  I don't think it's an icon cache issue and rebuilding it looks scary.  And, yes, it is a Windows problem, I'm sure, but why does one program work and the other doesn't? CM630: The App creates one window.  It creates two versions observable in Task Manager, even when I remove the shortcut from the Systray.  I copied-and-pasted from a program that doesn't behave like this to create the new one.  I run and stop ten times, and one doesn't have duplicates, the other always has two.  And I'm avoiding Windows 11 and considering Linux Mint. Hmm, I changed form1's icon to a Bell, the project options icon to a Circle, then I get two incidents of the program in the Systray, both looking like the old icon!!!  When I hover over it, the two incidents have left, a Circle, and right, a Bell.  Circle does nothing, Bell is the program. The program's form1 does have the bordericons to false and the borderstyle to bsNone. ---------------------------------------------------------------------- w click · 2026-02-15 13:58 I should add that this behaviour is the same when running from the Lazarus IDE or not. ---------------------------------------------------------------------- w click · 2026-02-15 14:51 And rebooting changes the old icon in the SysTray to the Circle, which is as you'd expect. ---------------------------------------------------------------------- jamie · 2026-02-15 15:15 And what does the Task Manager report as number of processes running form that one EXE ? Jamie ---------------------------------------------------------------------- CM630 · 2026-02-15 15:28 Did you try to put exit; on the very first line of the .Create of your main form (also in .OnLoaded if not empty)? If the second icon disappears, that you could move the exit; down and down again, until the second icon shows again. Quote from: w click on February 15, 2026, 02:57:10 pm... CM630: The App creates one window.  It creates two versions observable in Task Manager, ... Usually there is one parent instance in the task manager and one child. Maybe posting some shortcuts will not hurt. Quote from: w click on February 15, 2026, 02:57:10 pm... And I'm avoiding Windows 11 and considering Linux Mint.... I believe Windows 10 is far from dead. I seriously doubt that the transition from Win 10 to Win 11 will be so smooth and easy as from Win 7 to Win 10. Also, Linux does handle properly case sensitivity in *fat and ntfs, there are some steps towards case folding in ext4, not sure if there will be some result. But this is a different issue, I just meant "Don't panic!" ---------------------------------------------------------------------- w click · 2026-02-16 10:36 Quote from: jamie on February 15, 2026, 04:15:59 pmAnd what does the Task Manager report as number of processes running form that one EXE ? Jamie There are two.  They have different icons, the circle and bell. ---------------------------------------------------------------------- w click · 2026-02-16 10:48 Quote from: CM630 on February 15, 2026, 04:28:20 pmDid you try to put exit; on the very first line of the .Create of your main form (also in .OnLoaded if not empty)? If the second icon disappears, that you could move the exit; down and down again, until the second icon shows again. Not a trick I know, but I put 'exit;' as the first line of form1.formcreate;  This makes two processes, both with the circle icon.  I'm guessing one is reset at the end of the create.  I then get all sorts of exceptions and breaks due to string processing. Quote from: CM630 on February 15, 2026, 04:28:20 pmUsually there is one parent instance in the task manager and one child. Maybe posting some shortcuts will not hurt. So, the two processes are normal?  What do you mean by posting shortcuts? Quote from: CM630 on February 15, 2026, 04:28:20 pmI believe Windows 10 is far from dead. I seriously doubt that the transition from Win 10 to Win 11 will be so smooth and easy as from Win 7 to Win 10. Also, Linux does handle properly case sensitivity in *fat and ntfs, there are some steps towards case folding in ext4, not sure if there will be some result. But this is a different issue, I just meant "Don't panic!" I shall be sticking to Windows 10 for a good long while.  Linux doesn't have autohotkey, so I'm going to have issues with my keyboard.  I know where my towel is, so I won't be panicing :–) ---------------------------------------------------------------------- CM630 · 2026-02-16 12:11 Next try: do you happen to have more than one autocreated forms? (Main Menu — Project — Project Options...) ---------------------------------------------------------------------- w click · 2026-02-16 12:39 Quote from: CM630 on February 16, 2026, 01:11:53 pmNext try: do you happen to have more than one autocreated forms? (Main Menu — Project — Project Options...) The above is exactly what I have with a single Form1 in the Auto- create forms list. ---------------------------------------------------------------------- dseligo · 2026-02-16 12:52 Quote from: w click on February 13, 2026, 05:47:49 pmI had a program that sat in the Windows 10 taskbar, click it and it runs.  The icon is still there.  You can click the icon to minimise and restore it, exactly as you'd want and expect. I wrote another version of the same program, but now when it runs, there are two icons in the taskbar, one on top of the other.  When I hover over them, I get two versions of the program appear as floating options – the right brings the program up, the left does nothing.  I did change form1's borderstyle to bsnone, but that's not it, as it doesn't fix it when I change it back.  I mention it because that's the sort of thing I've been adjusting in this version.  I've messed something up. Anyone any idea how to get rid of this duplication? Did you try to right click the icon and click on 'Unpin from taskbar'? ---------------------------------------------------------------------- w click · 2026-02-16 13:57 Quote from: dseligo on February 16, 2026, 01:52:05 pmDid you try to right click the icon and click on 'Unpin from taskbar'? Yes.  The same behaviour whether running from Lazarus or not, pinned or unpinned from the taskbar. ---------------------------------------------------------------------- dseligo · 2026-02-16 14:14 Quote from: w click on February 16, 2026, 02:57:35 pmQuote from: dseligo on February 16, 2026, 01:52:05 pmDid you try to right click the icon and click on 'Unpin from taskbar'? Yes.  The same behaviour whether running from Lazarus or not, pinned or unpinned from the taskbar. So, you don't have any icon and when you run your program Windows shows two icons? Quote there are two icons in the taskbar, one on top of the other. What does this mean ('one on top of the other')? Can you post screenshot? ---------------------------------------------------------------------- w click · 2026-02-16 16:30 Quote from: dseligo on February 16, 2026, 03:14:50 pmSo, you don't have any icon and when you run your program Windows shows two icons? Yes.  Icon on the desktop, double-click, two icons in the taskbar.  Or icon pinned to taskbar, click and two instances again. Quote from: dseligo on February 16, 2026, 03:14:50 pmWhat does this mean ('one on top of the other')? Can you post screenshot? I have to admit what I'm doing now! Attached (I hope) is a photo (can't hover and screen capture!).   See that there are two icons and the two variants appear.  The one with the Star Trek symbol (was a Circle in discussion) and the Bell icon – Bell goes to the program, Star Trek does nothing.  Note that the HAL icon on its right is effectively the same program and is running one instance with one icon.  Somewhere along the line between HAL and LCARS, I set something that fouled this up. ---------------------------------------------------------------------- n7800 · 2026-02-16 19:43 It looks like this is due to the "MainFormOnTaskbar" property. What versions of Lazarus were these applications created in? 1. Open the main program file: Menu > Project > View Project Source 2. Add this line before the "Application.Initialize" line: 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 Application.MainFormOnTaskbar := True; Did this help? ---------------------------------------------------------------------- w click · 2026-02-16 20:15 Quote from: n7800 on February 16, 2026, 08:43:26 pmIt looks like this is due to the "MainFormOnTaskbar" property. What versions of Lazarus were these applications created in? 1. Open the main program file: Menu > Project > View Project Source 2. Add this line before the "Application.Initialize" line: 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 Application.MainFormOnTaskbar := True; Did this help? Bingo!  Thank you (and everyone) so much. I do get 'Warning: Symbol "MainFormOnTaskbar" is not portable'.  Only one icon though, so great. But why is this needed for this program, Version 2, and not for Version 1? ---------------------------------------------------------------------- n7800 · 2026-02-16 20:31 Quote from: w click on February 16, 2026, 09:15:59 pmI do get 'Warning: Symbol "MainFormOnTaskbar" is not portable'. Just ignore, this property is only needed for Windows, so it's declared platform-dependent. For your information, this property was introduced so that main window caption and taskbar icon can have different text. But this is usually unnecessary, and it causes some strange bugs. Therefore, in the new version of Lazarus (4.0, IIRC), this line is added automatically in new projects (and has a directive to hide this warning). Quote from: w click on February 16, 2026, 09:15:59 pmBut why is this needed for this program, Version 2, and not for Version 1? Perhaps your two projects were created in different versions of the IDE? Is this line missing in the previous version? ---------------------------------------------------------------------- w click · 2026-02-17 12:51 Quote from: n7800 on February 16, 2026, 09:31:22 pm Quote from: w click on February 16, 2026, 09:15:59 pmBut why is this needed for this program, Version 2, and not for Version 1? Perhaps your two projects were created in different versions of the IDE? Is this line missing in the previous version? I've not updated my IDE for an age and the line is missing from Version 1. ---------------------------------------------------------------------- n7800 · 2026-02-17 17:11 Has the count or settings of forms changed between versions? Pay attention to their "ShowInTaskBar" property. Also, check which ones are generated automatically. You can find this in the Project Options, "Forms" category (or simply open the main program file and look for the "Application.CreateForm" line). ---------------------------------------------------------------------- w click · 2026-02-18 13:43 Quote from: n7800 on February 17, 2026, 06:11:54 pmHas the count or settings of forms changed between versions? Pay attention to their "ShowInTaskBar" property. Also, check which ones are generated automatically. You can find this in the Project Options, "Forms" category (or simply open the main program file and look for the "Application.CreateForm" line). Project Options looked the same (except for Version 1 being two forms and the '  Application.MainFormOnTaskbar := True;' line). Version 1 had ShowInTaskBar set to stDefault, whereas Version 2 had stAlways.  I had a play and setting it to stDefault removed the double icon issue.  However, I still needed to put 'Application.MainFormOnTaskbar := True;' back in to make it minimise and maximise properly.