Solved

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

Posted on 2004-04-07
17
1,013 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
ID: 10804003
This window should be visible? you can simply hide it(ShowWindow with SW_HIDE command).
0
 
LVL 5

Author Comment

by:jjacksn
ID: 10806579
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
ID: 10812574
>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
ID: 10826041
I think you can use this.Hide() on Deactivate event of main form. This possibly will help
0
 
LVL 5

Author Comment

by:jjacksn
ID: 10829203
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
ID: 10830626
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
ID: 10969233
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
ID: 11043507
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 5

Author Comment

by:jjacksn
ID: 11044372
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
ID: 11057735
It becomes active when you press alt-tab because it next window to your DVD player.
0
 
LVL 5

Author Comment

by:jjacksn
ID: 11059409
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
ID: 11062894
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
ID: 11372288
??

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
ID: 11372975
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
ID: 11373056
I can still alt tab to it.  
0
 
LVL 8

Expert Comment

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

Author Comment

by:jjacksn
ID: 11525008
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Data Saving 5 56
Why Does This Page Not Show Up? 4 21
Excel file not created as expected 7 46
Where can I ask about my ASP.NET MVC project? 6 12
Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

947 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

23 Experts available now in Live!

Get 1:1 Help Now