Hidding a window and preventing Alt-Tabbing to it

D

Danielb

I'm trying to hide the main form of my application, as I want all of the
user interaction with my application to come from interacting with a notify
icon with a context menu in the system tray (which I have working). I've
figured out how to hide the form easy enough, set the WindowState to
Minimized and ShowInTaskbar to False.

What I can't figure out is how to prevent the user Alt-Tabbing to the
window, as its still visible in the Alt-Tab menu. I can set the windows
FormBorderStyle to FixedToolWindow or SizeableToolWindow and it will no
longer show up in the Alt-Tab menu but now it will now minimize to the
bottom left of the desktop just showing the windows title bar instead of
being completely hidden!

Does anyone know of any way to completely hide a window visibly(so no part
of the window is visible anywhere), with no icon on the task bar or on the
Alt-Tab menu? All I really want is to be able to run a notify icon in the
system tray and a context menu for the icon but I'm don't know of any other
way to do it other than to run it in a enclosing form.

I've been wondering if making my application a service make things easier
but I've no experience with programming services and it seems a bit of
overkill for what I'm wanting to do!

Any advice would be most appreciated!

Cheers,

Danielb
 
D

DanielB

I've tried calling that before and after the form's
InitializeComponent call but it does not seem to make a difference if
the border style is set to FixedToolWindow or SizeableToolWindow. You
still end up with a minimized window instead of a hidden one :-(

I guess I will need to find a new way of preventing the window showing
up in the Alt-Tab menu, as this method is proving to ackward as it
does not look like I can hide the window properally.

Daniel
 
J

John M Deal

You should be able to accomplish this by setting the form's visibility
to false at the same time that you set the form's ShowInTaskbar property
to false. Do that in your form load event handler and it should do the
trick. At least it does in VS.Net 2003 on a Win2K3 box. If this isn't
working in your current application, you may want to try creation a test
project with just that code in it and see what happens. If it works in
the test project but still doesn't in your real project then there is
likely some code somewhere that is resetting one of these values. Hope
this helps.

Have A Better One!

John M Deal, MCP
Necessity Software
 
D

Danielb

Hi John,

I've just had the applicationContext class pointed out to me so I
think I might be able to use one of these instead of a main form. As I
really don't need the main form at all, i just need something to
contain my notify icon and its context menu!

Thanks for the advice though!

Cheers,

DanielB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top