ShowinTaskBar -- Backwards Question

G

Guest

I program in both C# WinForms and C++ Windows SDK. In C# WinForms there is a
property for the Form called ShowInTaskBar which removes the window from the
taskbar if False. This is a nice feature, however I would love to do this in
C++/Windows SDK. The question is how is this accomplished in Windows SDK?
Is it a flag when I do a CreateWindow?

I know this isn't a WinForm question, however I was hoping there was an old
hand at Windows GUI programming hanging around that could enlighten me.

-Wayne
 
B

bj7lewis

I believe you need to remove the WS_EX_TOOLWINDOW style from the window.
Google for 'WS_EX_TOOLWINDOW' to see examples.
That change the window's non-client window part to a tool window style but
yes removes the app from taskbar...

Try removing WS_EX_APPWINDOW from extended styles instead if you need the
normal non-client window style...
 
L

Linda Liu[MSFT]

Hi Wayne,

Based on my understanding, you'd like to hide a form from the taskbar
through Windows API functions. If I'm off base, please feel free to let me
know.

To get what you want, the first step is to remove the WS_EX_APPWINDOW flag
from the extended window style of the form firstly. We can do this by
calling the Win32 function SetWindowLong. The second step is to set the
owner of this form to an invisible form.

The following is a sample in C#:

using System.Runtime.InteropServices;
public partial class Form1 : Form
{
public Form1()
{
int style = GetWindowLong(this.Handle, GWL_EXSTYLE);
style &= ~WS_EX_APPWINDOW;
SetWindowLong(this.Handle, GWL_EXSTYLE, style);
this.Owner = new Form();
}

public static int WS_EX_APPWINDOW = 0x40000;
public static int GWL_EXSTYLE = -20;

DllImport("user32.dll")]
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int
dwNewLong);
[DllImport("user32.dll")]
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);

}

The following is sample in C++:
'How to dynamically show/hide the Taskbar application button'
http://www.codeguru.com/cpp/frameworks/advancedui/article.php/c3227/

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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