11 April, 2018

Prevent Leaving An Icon In System Tray On Program Exit

The Windows 7 taskbar shows a preview of the w...
The Windows 7 taskbar shows a preview of the window. (Photo credit: Wikipedia)
11-April-2018


Prevent Leaving An Icon In System Tray On Program Exit. I had a problem with one of my applications about this. I was able to minimize it to System Tray. The App Icon was removed from the Taskbar, alright. But when the application was restored and closed, the icon remains in the System Tray. What's worse, I didn't notice it!

This was complicated by the fact that I did a routine cycle of closing and opening the program using scripts and some free apps downloadable from the internet, so that for a period of time, System Tray was filled up with icons of the same program, all N-1 of which are invalid handles!

I got a good scolding from my boss about this. Why? When I researched this problem, I found out that it is a prevalent issue. There are a number of forums that discusses the same exact problem, as obviously, I am not the only one having it. No, I am not the first one, and I will not be the last.

What did I find? That it was, and it remains, an issue by MS. Yep. The software giant company MS. They have it as a bug, and it still isn't fixed. The full details, I cannot tell here. But if you are interested, and if it happens to you in the future, you will know and understand what I mean.

Of course, there were suggestions presented in the forums to remedy the situation, and some of them I actually followed. Unfortunately, they didn't work perfectly for me. That is why so many icons still get left behind. And worse, this was implemented in one of our customers. Customer complain, that is what I got. That is how I got a good scolding. What's the point? I followed and applied in my code something that is 'wrong'. Yeah, I kinda missed that.

Anyway, how was that problem remedied?

This is the surprising this. It really is very simple, and it isn't something hidden.

In the FormClosed event, put (or add) these lines:

myNotifyIcon.Icon = null;
myNotifyIcon.Dispose();
Application.DoEvents();
if (Application.MessageLoop) {
    // WinForms app
    Application.DoEvents();
    Application.Exit();
}
else {
    // Console app
    Environment.Exit(0);
}

Surprising, isn't it? You gotta try it to know it! And with that, You should be all set. Prevent Leaving An Icon In System Tray On Program Exit.

Till then!

[Late posting; drafted on 18-October-2017]


28 March, 2018

Make App Disappear From Taskbar On Minimize

Screenshot showing Windows 8's ability to pin ...
Screenshot showing Windows 8's ability to pin apps and show different wallpapers on different monitors, as well as displaying the new Explorer file browser interface, Task Manager, and multi-monitor taskbar (in "Duplicated on all taskbars" mode). (Photo credit: Wikipedia)
28-March-2018

I wanted to completely hide an application after it is minimized. Hide() is not enough. [ShowInTaskbar = false] did the trick.

Well, I could say that I struggled a bit finding out what would really make the application disappear from the taskbar.

I used Hide(). Didn't work. I also tried Visible = false. Also did not work. I combined both, but still, it did not work. I combined both Hide() and Visible = false, and even then, I still did not see the job done. App icon still shows in the taskbar when it was minimized.

I should mention that I already have the application creating an icon in the System Tray as I have previously created a NotifyIcon to handle that. And what I am adding now is to minimize the window via code, which also requires the app icon to be not shown in the Taskbar.

I couldn't find many articles that provided help. What came up usually just mentioned Hide() or Visible, and some of the old stuff about adding a NotifyIcon function. I found one that did mention about making use of the property ShowInTaskbar. So I grabbed that one-liner code, tried it, and it worked!

So now my program is complete! Now I can hide an application after it is minimized. Thanks to ShowInTaskbar, I could declare it a holiday!

Till then!

[Late posting; drafted on 04-October-2017]


22 November, 2017

How to Speed up Windows 7, 8, 8.1, 10

Windows 7 build 7600
Windows 7 build 7600 (Photo credit: Wikipedia)
22-Nov-2017


In Windows 7, 8, 8.1, 10, slow performance is one big hurdle to tackle.

Aside from simply increasing the RAM to max, if that is possible, and switching to SSD, if that is at all possible (financially, of course), there is the usual list:


  • uninstall unneeded software
  • clean up computer clutter
  • disable services not in use
  • delay start up for some services
  • and many, many others


What I am writing about now is not these usual stuffs, but one that is normally overlooked, or not done: Windows File Indexing.

A bit on File Indexing. It is to aid searches. Google it to know more, but this is taxing Windows far beyond belief. Right after Windows install, there already is a ton of files in your C: drive. And this feature is turned on by default. So if you have several discs (desktop, in particular), or partitions, then all of these partitions have the file indexing flag turned on.

And every time you add or remove a file in any of these drives, file indexing kicks in, for what? Again, to aid file searches. Even more, to check what is inside the file, so when you do your searches, file name and file content is checked.

Let your imagination now run wild. How much system resource will that consume? Sorry, but I can't compute!

So let's get it done with.

Simply, to check on it, right-click on a drive, like C:, or D:, or whatever you have, except of course CD drive and the likes excluded, and at the bottom is Properties. Click on it.

Then, again, at the bottom part, you will see 2 checkboxes. First is 'Compress...', and next is 'Allow files on this drive to have contents indexed in addition to file properties.'

So was wrong. Not only file name and contents are indexed, but file properties is also indexed. Wham!

Well, to turn that off means all of those indexing activities will immediately cease. And all you have to do is uncheck that box, Yes, that is all. Right away. Immediately.

Sudden, instant, immediate effect. And do it for all disc drives that you have. I'm sure you will right away feel the difference.

I mean, why would Windows have that feature turned on by default, and without a hint, it is taking a lot of system resources?

Now this is the kind of 'improvement' that I would recommend to anybody and everybody, without having to fork out a single cent.

Of course, if you need to do searches, then leave it on, and forever be plagued by a slow Windows PC.

Wait, you mean there is no help? If I want to turn off File Indexing and I do searches, then I'm done for good? Actually, there is. You are not the first to ask that question. And for sure, you will not be the last.

There is a free tool, Search Everything, that you can use to help you in doing file searches, and it is customizable, too. So go ahead and turn off File Indexing to get that added speed (or conversely, remove that Windows slowness), and since Windows will not be able to help you anymore with searches, use Search Everything, a free tool from voidtools.com.

So now you have a way to make your PC a bit faster without forking out a single cent, and you also have a new tool to use for file searches.

Who says you can't have the best of both worlds?

Now you can.

Till then!