Solved

Hidding the window for a tray app (overriding so alt-tab doesn't work properly)

Posted on 2004-04-07
17
1,010 Views
Last Modified: 2007-12-19
I have a tray app that has a window and I do not want it to be alt-tabbable.  

It doesn't show up in the alt-tab window right now unless the user is using a full screen program

1.  why does it show up doing a full screen program?
2.  What is the best thing to override to not allow alt-tab to work properly (just capture WM_MAXIMIZE in WndProc?) and leave the window minimized.  

0
Comment
Question by:jjacksn
  • 9
  • 8
17 Comments
 
LVL 8

Expert Comment

by:RomanPetrenko
Comment Utility
This window should be visible? you can simply hide it(ShowWindow with SW_HIDE command).
0
 
LVL 5

Author Comment

by:jjacksn
Comment Utility
This window is never visible.  Another window shows as a popup, but not the main window.  I use the SW_HIDE command, and that works fine when a window is not if full screen mode.  By fine I mean it isn't in the alt-tab window.  

However, when a window is full screen, you can alt-tab to it.  
0
 
LVL 8

Expert Comment

by:RomanPetrenko
Comment Utility
>This window is never visible.
...
>However, when a window is full screen, you can alt-tab to it
You mean above the window of another application is full screen? When you say "Full screen" you mean maximized or like screensavers(no taskbar, toolbars and may be grafic mode changed).
0
 
LVL 8

Expert Comment

by:RomanPetrenko
Comment Utility
I think you can use this.Hide() on Deactivate event of main form. This possibly will help
0
 
LVL 5

Author Comment

by:jjacksn
Comment Utility
I mean like when you are playing a dvd or something like that, so it goes into complete full screen mode.  then you can see my app in the alt-tab window.  others, it works fine.
0
 
LVL 8

Expert Comment

by:RomanPetrenko
Comment Utility
So your main window is hidden and it's popup is in fullscreen mode, did I understand you right?
How do you create full-screen popup window? can you provide here simple sample. I'd like to see such behavior you describe.
0
 
LVL 5

Author Comment

by:jjacksn
Comment Utility
Roman, create an app that has no taskbar and call this.Hide().  You will not be able to see in alt-tab.  Then play a DVD in full screen mode.  when you alt-tab, you can see it.
0
 
LVL 8

Expert Comment

by:RomanPetrenko
Comment Utility
This happened because the window active(focused) now. When you hiding it you also should move focus to another window(May be to desktop or next window in alt-tab list). Also you may try WS_TRANSPARENT|WS_TOPMOST style, then your window will not grab focus and also will be visible over all other windows.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 5

Author Comment

by:jjacksn
Comment Utility
Roman, it is never active to begin with though... so I don't quite understand what you are saying?
0
 
LVL 8

Expert Comment

by:RomanPetrenko
Comment Utility
It becomes active when you press alt-tab because it next window to your DVD player.
0
 
LVL 5

Author Comment

by:jjacksn
Comment Utility
It doesn't become active, it simply is shown in the alt-tab window and one COULD select it.  However, if a window is not in full-screen mode, then you can't see my application icon in the alt-tab window.
0
 
LVL 8

Accepted Solution

by:
RomanPetrenko earned 500 total points
Comment Utility
Look,
I have Windows XP SP2 RC1
the following code hides the main window when you minimize it and shows notifyIcon and the window not visible in neither in TaskBar nor AltTab list, in notifyIcon's context menu you can choose "show" to show it.
as  dvd player I've tried BSPlayer and Nero Media player in FullScreen and windowed mode:
---Sample---
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.NotifyIcon notifyIcon1;
private System.Windows.Forms.ContextMenu contextMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.ComponentModel.IContainer components;

public Form1()
{
      //
      // Required for Windows Form Designer support
      //
      InitializeComponent();

      //
      // TODO: Add any constructor code after InitializeComponent call
      //
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
      if( disposing )
      {
            if (components != null)
            {
                  components.Dispose();
            }
      }
      base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
      this.components = new System.ComponentModel.Container();
      System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
      this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components);
      this.contextMenu1 = new System.Windows.Forms.ContextMenu();
      this.menuItem1 = new System.Windows.Forms.MenuItem();
      //
      // notifyIcon1
      //
      this.notifyIcon1.ContextMenu = this.contextMenu1;
      this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
      this.notifyIcon1.Text = "notifyIcon1";
      //
      // contextMenu1
      //
      this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                                                                                                              this.menuItem1});
      //
      // menuItem1
      //
      this.menuItem1.Index = 0;
      this.menuItem1.Text = "Show";
      this.menuItem1.Click += new System.EventHandler(this.menuItem1_Click);
      //
      // Form1
      //
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(292, 273);
      this.Name = "Form1";
      this.Text = "Form1";
      this.SizeChanged += new System.EventHandler(this.Form1_SizeChanged);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
      Application.Run(new Form1());
}

private void Form1_SizeChanged(object sender, System.EventArgs e)
{
      if (this.WindowState == FormWindowState.Minimized)
      {
            Hide();
            notifyIcon1.Visible = true;
      }
}

private void menuItem1_Click(object sender, System.EventArgs e)
{
      notifyIcon1.Visible = false;
      Show();
}
}
---end of Sample---
Is this smaple works the same way for you?
0
 
LVL 5

Author Comment

by:jjacksn
Comment Utility
??

This code doesn't hide the main app, I can get through it via alt-tab, and I can't see an icon get loaded into the tray.  Is this the right code?
0
 
LVL 8

Expert Comment

by:RomanPetrenko
Comment Utility
yes. It was compiled with VS.net 2003 and works fine.
When you minimize window it hides and shows icon in tray, click on show menu item in task bar you'll get it back.
0
 
LVL 5

Author Comment

by:jjacksn
Comment Utility
I can still alt tab to it.  
0
 
LVL 8

Expert Comment

by:RomanPetrenko
Comment Utility
Did you find the problem? now the code I posted before works? You found better solution?
0
 
LVL 5

Author Comment

by:jjacksn
Comment Utility
Roamin, as I said, I can still alt-tab to the screen in your code (which I don't want to be able to do)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now