11.2. 获得当前任务栏的坐标位置:getCurTaskbarLocation
// get current taskbar position(X, Y), support 4 mode: taskbar bottom/right/up/left
public System.Drawing.Point getCurTaskbarLocation()
{
int xPos = 0, yPos = 0;
if ((Screen.PrimaryScreen.Bounds.Width == Screen.PrimaryScreen.WorkingArea.Width) &&
(Screen.PrimaryScreen.WorkingArea.Y == 0))
{
//taskbar bottom
xPos = 0;
yPos = Screen.PrimaryScreen.WorkingArea.Height;
}
else if ((Screen.PrimaryScreen.Bounds.Height == Screen.PrimaryScreen.WorkingArea.Height) &&
(Screen.PrimaryScreen.WorkingArea.X == 0))
{
//taskbar right
xPos = Screen.PrimaryScreen.WorkingArea.Width;
yPos = 0;
}
else if ((Screen.PrimaryScreen.Bounds.Width == Screen.PrimaryScreen.WorkingArea.Width) &&
(Screen.PrimaryScreen.WorkingArea.Y > 0))
{
//taskbar up
xPos = 0;
yPos = 0;
}
else if ((Screen.PrimaryScreen.Bounds.Height == Screen.PrimaryScreen.WorkingArea.Height) &&
(Screen.PrimaryScreen.WorkingArea.X > 0))
{
//taskbar left
xPos = 0;
yPos = 0;
}
return new System.Drawing.Point(xPos, yPos);
}
例 11.2. getCurTaskbarLocation 的使用范例
Point curTaskbarLocation = crl.getCurTaskbarLocation();