您的位置:首页 > 其它

获取系统任务栏位置宽高信息的方法

2014-06-12 11:34 323 查看
获取系统任务栏位置宽高信息的方法  

void GetTaskbarInfo(int &width, int &height, int &pos)
{//获取系统任务栏状态位置有四种情况:左、上、右、下,此外要考虑任务栏自动隐藏的情况
int wx = GetSystemMetrics(SM_CXSCREEN);
int wy = GetSystemMetrics(SM_CYSCREEN);
CRect rtWorkArea;
SystemParametersInfo(SPI_GETWORKAREA, 0, &rtWorkArea, 0);
//1.任务栏停靠在左边情况
if (0!=rtWorkArea.left)
{
width = wx - rtWorkArea.Width();
height = wy;
pos = 0;
return;
}
//2.任务栏停靠在上边情况
if(0!=rtWorkArea.top)
{
width = wx;
height = wy - rtWorkArea.Height();
pos = 1;
return;
}
//3.任务栏停靠在右边情况
if(0==rtWorkArea.left && wx!=rtWorkArea.Width())
{
width = wx - rtWorkArea.Width();
height = wy;
pos = 2;
return;
}
//4.任务栏停靠在下边情况
if(0==rtWorkArea.top && wy!=rtWorkArea.Height())
{
width = wx;
height = wy - rtWorkArea.Height();
pos = 3;
return;
}
//5.任务栏自动隐藏的情况,这样其宽高都是0
if(0==rtWorkArea.left && 0==rtWorkArea.top
&& wx==rtWorkArea.Width() && wy==rtWorkArea.Height())
{
width = 0;
height =0;
pos = 4;
return;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: