Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-04-07
17
Medium Priority
?
1,036 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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
 
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 1500 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

604 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