本文整理汇总了C#中APPBARDATA类的典型用法代码示例。如果您正苦于以下问题:C# APPBARDATA类的具体用法?C# APPBARDATA怎么用?C# APPBARDATA使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
APPBARDATA类属于命名空间,在下文中一共展示了APPBARDATA类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTaskbarState
/// <summary>
/// Gets the current Taskbar state
/// </summary>
/// <returns>current Taskbar state</returns>
public AppBarStates GetTaskbarState()
{
APPBARDATA msgData = new APPBARDATA();
msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
msgData.hWnd = FindWindow("System_TrayWnd", null);
return (AppBarStates)SHAppBarMessage((UInt32)AppBarMessages.GetState, ref msgData);
}
示例2: Taskbar
public Taskbar(bool secondary)
{
Handle = User32.FindWindow(!secondary ? ClassName : SecondaryClassName, null);
if (Handle == IntPtr.Zero)
return;
var data = new APPBARDATA { cbSize = (uint)Marshal.SizeOf(typeof(APPBARDATA)), hWnd = Handle };
IntPtr result = Shell32.SHAppBarMessage(ABM.GetTaskbarPos, ref data);
if (result == IntPtr.Zero)
throw new InvalidOperationException();
Position = (TaskbarPosition)data.uEdge;
Bounds = Rectangle.FromLTRB(data.rc.left, data.rc.top, data.rc.right, data.rc.bottom);
data.cbSize = (uint)Marshal.SizeOf(typeof(APPBARDATA));
result = Shell32.SHAppBarMessage(ABM.GetState, ref data);
int state = result.ToInt32();
AlwaysOnTop = (state & ABS.AlwaysOnTop) == ABS.AlwaysOnTop;
AutoHide = (state & ABS.Autohide) == ABS.Autohide;
var lpRect = new RECT();
User32.GetWindowRect(Handle, ref lpRect);
VisibleBounds = Rectangle.FromLTRB(lpRect.left, lpRect.top, lpRect.right, lpRect.bottom);
/*Debug.WriteLine(this.Bounds);
Debug.WriteLine(lpRect.top + "-------------------");*/
}
示例3: SetAppBar
public static void SetAppBar(Window appbarWindow, ABEdge edge)
{
RegisterInfo info = GetRegisterInfo(appbarWindow);
info.Edge = edge;
APPBARDATA abd = new APPBARDATA();
abd.cbSize = Marshal.SizeOf(abd);
abd.hWnd = new WindowInteropHelper(appbarWindow).Handle;
if (edge == ABEdge.None) {
if (info.IsRegistered) {
SHAppBarMessage((int)ABMsg.ABM_REMOVE, ref abd);
info.IsRegistered = false;
}
RestoreWindow(appbarWindow);
return;
}
if (!info.IsRegistered) {
info.IsRegistered = true;
info.CallbackId = RegisterWindowMessage("AppBarMessage");
abd.uCallbackMessage = info.CallbackId;
uint ret = SHAppBarMessage((int)ABMsg.ABM_NEW, ref abd);
HwndSource source = HwndSource.FromHwnd(abd.hWnd);
source.AddHook(new HwndSourceHook(info.WndProc));
}
appbarWindow.WindowStyle = WindowStyle.None;
appbarWindow.ResizeMode = ResizeMode.NoResize;
appbarWindow.Topmost = true;
ABSetPos(info.Edge, appbarWindow);
}
示例4: GetTaskbar
/// <summary>
/// Returns information for the Windows taskbar (type, location, size)
/// </summary>
public static Rectangle GetTaskbar(out AppBarLocation location)
{
var data = new APPBARDATA();
var res = SHAppBarMessage(ABM_GETTASKBARPOS, ref data);
location = data.uEdge;
return Rectangle.FromLTRB(data.rc.left, data.rc.top, data.rc.right, data.rc.bottom);
}
示例5: SetTaskbarState
/// <summary>
/// Set the Taskbar State option
/// </summary>
/// <param name="option">AppBarState to activate</param>
public void SetTaskbarState(AppBarStates option)
{
APPBARDATA msgData = new APPBARDATA();
msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
msgData.hWnd = FindWindow("System_TrayWnd", null);
msgData.lParam = (Int32)(option);
SHAppBarMessage((UInt32)AppBarMessages.SetState, ref msgData);
}
示例6: GetTaskBarInfo
public static void GetTaskBarInfo(out AppBarEdge taskBarEdge, out Rectangle region)
{
APPBARDATA appData = new APPBARDATA();
uint ret = SHAppBarMessage(AppBarMessage.GetTaskBarPos, ref appData);
taskBarEdge = appData.uEdge;
region = appData.rc.ToRectangle();
}
示例7: GetScreenHeight
public static int GetScreenHeight(Window appbarWindow)
{
APPBARDATA barData = new APPBARDATA();
barData.cbSize = Marshal.SizeOf(barData);
barData.hWnd = new WindowInteropHelper(appbarWindow).Handle;
SHAppBarMessage((int)ABMsg.ABM_GETTASKBARPOS, ref barData);
return barData.rc.top;
}
示例8: ABSetPos
public static void ABSetPos(Window appbarWindow, ABEdge edge)
{
APPBARDATA barData = new APPBARDATA();
barData.cbSize = Marshal.SizeOf(barData);
barData.hWnd = new WindowInteropHelper(appbarWindow).Handle;
barData.uEdge = (int)edge;
int leftOffset = 0;
int topOffset = 0;
int actualScreenWidth = (int)SystemParameters.PrimaryScreenWidth;
int actualScreenHeight = (int)SystemParameters.PrimaryScreenHeight;
GetActualScreenData(edge, appbarWindow, ref leftOffset, ref topOffset, ref actualScreenWidth, ref actualScreenHeight);
if (barData.uEdge == (int)ABEdge.Left || barData.uEdge == (int)ABEdge.Right)
{
barData.rc.top = topOffset;
barData.rc.bottom = actualScreenHeight;
if (barData.uEdge == (int)ABEdge.Left)
{
barData.rc.left = leftOffset;
barData.rc.right = (int)Math.Round(appbarWindow.ActualWidth) + leftOffset;
}
else
{
barData.rc.right = actualScreenWidth + leftOffset;
barData.rc.left = barData.rc.right - (int)Math.Round(appbarWindow.ActualWidth);
}
}
else
{
barData.rc.left = leftOffset;
barData.rc.right = actualScreenWidth + leftOffset;
if (barData.uEdge == (int)ABEdge.Top)
{
barData.rc.top = topOffset;
barData.rc.bottom = (int)Math.Round(appbarWindow.ActualHeight) + topOffset;
}
else
{
barData.rc.bottom = actualScreenHeight + topOffset;
barData.rc.top = barData.rc.bottom - (int)Math.Round(appbarWindow.ActualHeight);
}
}
SHAppBarMessage((int)ABMsg.ABM_QUERYPOS, ref barData);
SHAppBarMessage((int)ABMsg.ABM_SETPOS, ref barData);
Rect rect = new Rect((double)barData.rc.left, (double)barData.rc.top,
(double)(barData.rc.right - barData.rc.left), (double)(barData.rc.bottom - barData.rc.top));
//This is done async, because WPF will send a resize after a new appbar is added.
//if we size right away, WPFs resize comes last and overrides us.
appbarWindow.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle,
new ResizeDelegate(DoResize), appbarWindow, rect);
}
示例9: show
static void show()
{
// タスクバーを常に表示
APPBARDATA abd = new APPBARDATA();
abd.cbSize = Marshal.SizeOf(abd);
abd.lParam = ABS_ALWAYSONTOP;
SHAppBarMessage(ABM_SETSTATE, ref abd);
// タスクバーを表示
ShowWindow(FindWindow("Shell_TrayWnd", IntPtr.Zero), SW_NORMAL);
}
示例10: GetTaskbarPosition
private static TaskbarPosition GetTaskbarPosition(out Rectangle bounds)
{
var taskbarHandle = FindWindow("Shell_TrayWnd", null);
var data = new APPBARDATA { cbSize = (uint)Marshal.SizeOf(typeof(APPBARDATA)), hWnd = taskbarHandle };
var result = SHAppBarMessage(ABM.GetTaskbarPos, ref data);
if (result == IntPtr.Zero)
throw new InvalidOperationException();
bounds = Rectangle.FromLTRB(data.rc.left, data.rc.top, data.rc.right, data.rc.bottom);
return (TaskbarPosition)data.uEdge;
}
示例11: hide
static void hide()
{
// 「タスクバーを自動的に隠す」
APPBARDATA abd = new APPBARDATA();
abd.cbSize = Marshal.SizeOf(abd);
abd.lParam = ABS_AUTOHIDE;
SHAppBarMessage(ABM_SETSTATE, ref abd);
System.Threading.Thread.Sleep(100);
// タスクバーを非表示
ShowWindow(FindWindow("Shell_TrayWnd", IntPtr.Zero), SW_HIDE);
}
示例12: GetPosition
public void GetPosition(string strClassName, string strWindowName)
{
this.m_data = new APPBARDATA();
this.m_data.cbSize = (uint) Marshal.SizeOf(this.m_data.GetType());
if (!(FindWindow(strClassName, strWindowName) != IntPtr.Zero))
{
throw new Exception("Failed to find an AppBar that matched the given criteria");
}
if (SHAppBarMessage(5, ref this.m_data) != 1)
{
throw new Exception("Failed to communicate with the given AppBar");
}
}
示例13: button1_Click
private void button1_Click(object sender, EventArgs e)
{
// タスクバーを常に表示
APPBARDATA abd = new APPBARDATA();
abd.cbSize = Marshal.SizeOf(abd);
abd.lParam = ABS_ALWAYSONTOP;
SHAppBarMessage(ABM_SETSTATE, ref abd);
// タスクバーを表示
ShowWindow(FindWindow("Shell_TrayWnd", IntPtr.Zero), SW_NORMAL);
// フォームを閉じる
//this.Close();
}
示例14: button2_Click
private void button2_Click(object sender, EventArgs e)
{
//タスクバーを自動的に隠す
APPBARDATA abd = new APPBARDATA();
abd.cbSize = Marshal.SizeOf(abd);
abd.lParam = ABS_AUTOHIDE;
SHAppBarMessage(ABM_SETSTATE, ref abd);
// タスクバーを非表示
ShowWindow(FindWindow("Shell_TrayWnd", IntPtr.Zero), SW_HIDE);
// フォームを閉じる
//this.Close();
}
示例15: SetAppBarAutoDisplay
///
/// 设置系统任务栏是否自动隐藏
///
/// True 设置为自动隐藏,False 取消自动隐藏
public static void SetAppBarAutoDisplay(bool IsAuto)
{
APPBARDATA abd = new APPBARDATA();
abd.hwnd = FindWindow("Shell_TrayWnd", "");
//abd.lParam = ABS_ALWAYSONTOP Or ABS_AUTOHIDE '自动隐藏,且位于窗口前
//abd.lParam = ABS_ALWAYSONTOP '不自动隐藏,且位于窗口前
//abd.lParam = ABS_AUTOHIDE '自动隐藏,且不位于窗口前
if (IsAuto)
{
abd.lParam = ABS_AUTOHIDE;
SHAppBarMessage(ABM_SETSTATE, ref abd);
}
else
{
abd.lParam = ABS_ALWAYSONTOP;
SHAppBarMessage(ABM_SETSTATE, ref abd);
}
}