1.判断位置
SystemParametersInfo(SPI_GETWORKAREA, 0, &rt, 0)
//任务栏在下面的高度
int y = ::GetSystemMetrics(SM_CYSCREEN)-rt.Height();
上面
int y = rt.top;
左
int y = rt.left;
右
int y = ::GetSystemMetrics(SM_CXSCREEN)-rt.Width();
2.得到高度,然后可判断位置
CRect rect;
CWnd *pWndPrev= FindWindow("Shell_TrayWnd", "");
pWndPrev->GetWindowRect(&rect);
//rect.bottom-rect.top 就是任务栏的高度
if(rect.top>0)//下面
if(rect.left>0)//左面
VC++得到和改变屏幕的分辨率
//获取屏幕的分辨率
int nFullWidth=GetSystemMetrics(SM_CXSCREEN);
int nFullHeight=GetSystemMetrics(SM_CYSCREEN);
DEVMODE lpDevMode;
lpDevMode.dmBitsPerPel=32;//修改为32位颜色
lpDevMode.dmPelsWidth=1024;//分辨率X为1024
lpDevMode.dmDisplayFrequency=85;//刷新率为85HZ
lpDevMode.dmPelsHeight=768;//分辨率Y为768
lpDevMode.dmSize=sizeof(lpDevMode);
lpDevMode.dmFields =DM_PELSWIDTH|DM_PELSHEIGHT|DM_BITSPERPEL|DM_DISPLAYFREQUENCY;
ChangeDisplaySettings(&lpDevMode,1);
ChangeDisplaySettings用VC实现动态改变Windows的显示特性
通过消息控制窗体最大化和还原
//还原
SendMessage(WM_SYSCOMMAND,SC_RESTORE,0);
//最大化
SendMessage(WM_SYSCOMMAND,SC_MAXIMIZE,0);
//最小化
SendMessage(WM_SYSCOMMAND,SC_MINIMIZE,0);
17:40 | 添加评论 | 固定链接 | 写入日志 | 计算机与 Internet
怎样用鼠标拖动没有标题栏的对话框
1.
WM_NCHITTEST消息
UINT CMyDlg:: OnNcHitTest (CPoint point )
{
UINT nHitTest =CDialog :: OnNcHitTest (point );
return (nHitTest ==HTCLIENT)? HTCAPTION : nHitTest ;
}
2.
void CXxxDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
//移动窗口
SendMessage(WM_SYSCOMMAND,SC_MOVE|HTCLIENT,0);
CDialog::OnLButtonDown(nFlags, point);
}
3.
void CYourDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
CDialog::OnLButtonDown(nFlags, point);
PostMessage( WM_NCLBUTTONDOWN, HTCAPTION, MAKELPARAM( point.x, point.y));
}
4.
LRESULT CGameDemoDlg::OnNcHitTest(CPoint point)
{
//移动窗口
ScreenToClient(&point);
if (point.y<28)
{
//返回该值,欺骗系统,让它相信这就是标题栏
return HTCAPTION;
}
return CDialog::OnNcHitTest(point);
}