SHAppbarMessage in C#

G

Guest

Hi,

I have a problem with hide and show the Windows Taskbar,
when using the SHAppBarMessage API function in C# for
setting the state of the taskbar to AlwaysOnTop or
AutoHide.

Everything works fine, when running the app on XP SP1.
On W2K SP3 the taskbar *does not react* and I cannot
figure out, if this is a .NET issue though I have the
feeling that it relates to differences in shell32.dll

Below is the code snippet, that reproduces this behaviour.



[DllImport("shell32.dll")]
public static extern UInt32 SHAppBarMessage(
UInt32 dwMessage,

ref APPBARDATA pData);


public enum AppBarMessages
{
New =
0x00000000,
Remove =
0x00000001,
QueryPos =
0x00000002,
SetPos =
0x00000003,
GetState =
0x00000004,
GetTaskBarPos =
0x00000005,
Activate =
0x00000006,
GetAutoHideBar =
0x00000007,
SetAutoHideBar =
0x00000008,
WindowPosChanged =
0x00000009,
SetState =
0x0000000a
}

[StructLayout(LayoutKind.Sequential)]
public struct APPBARDATA
{
public UInt32 cbSize;
public IntPtr hWnd;
public UInt32 uCallbackMessage;
public UInt32 uEdge;
public RECT rc;
public Int32 lParam;
}


public enum AppBarStates
{
AutoHide =
0x00000001,
AlwaysOnTop =
0x00000002
}


public void SetTaskbar_AutoHide()
{
APPBARDATA msgData = new APPBARDATA
();
msgData.cbSize = (UInt32)
Marshal.SizeOf(msgData);
msgData.hWnd = FindWindow
("System_TrayWnd",null);
msgData.lParam = (Int32)
(AppBarStates.AutoHide);

SHAppBarMessage((UInt32)
AppBarMessages.SetState, ref msgData);
}
 

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

Similar Threads

Moving windows takbar? 2

Top