您的位置:首页 > 编程语言 > C#

C#获取任务栏位置代码

2012-08-09 11:32 176 查看
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

[DllImport("user32.dll")]
public static extern int SystemParametersInfo(int uAction, int uParam, ref RECT re, int fuWinTni);

[DllImport("SHELL32", CallingConvention = CallingConvention.StdCall)]
public static extern uint SHAppBarMessage(int dwMessage, ref APPBARDATA pData);

private void button1_Click(object sender, EventArgs e)
{
int aaa=0x00000005;
APPBARDATA pdat=new APPBARDATA();
SHAppBarMessage(aaa,ref pdat);
}
}

[StructLayout(LayoutKind.Sequential)]
public struct APPBARDATA
{

public int cbSize;

public IntPtr hWnd;

public int uCallbackMessage;

public int uEdge;//属性代表上、下、左、右

public RECT rc;

public IntPtr lParam;

}

[StructLayout(LayoutKind.Sequential)]
public struct RECT
{

public int left;

public int top;

public int right;

public int bottom;

public override string ToString()
{

return "{left=" + left.ToString() + ", " + "top=" + top.ToString() + ", " +

"right=" + right.ToString() + ", " + "bottom=" + bottom.ToString() + "}";

}

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: