【MFC】WM_GETMINMAXINFO 设置无边框窗口最大花不遮挡任务栏

时间:2022-05-22 06:07:10
 LRESULT OnGetMinMaxInfo( UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/ )
{
MINMAXINFO * p = (MINMAXINFO * )lParam;
p->ptMinTrackSize.x = ; //最小值width
p->ptMinTrackSize.y = ; //最小值height //在多屏的时候,需要区分有任务栏的屏和没任务栏的屏
if (::MonitorFromWindow(::FindWindow(_T( "Shell_TrayWnd"), NULL), MONITOR_DEFAULTTONEAREST) == ::MonitorFromWindow(m_hWnd , MONITOR_DEFAULTTONEAREST)) //判断窗口最近的屏幕是否是任务栏所在的主屏幕
{
p->ptMaxPosition.x = ;
p->ptMaxPosition.y = ;
//测试发现,窗口最大化时,不需要加上后边的两个size。
p-> ptMaxSize.x = GetSystemMetrics(SM_CXFULLSCREEN) + GetSystemMetrics(SM_CXDLGFRAME);
     // + GetSystemMetrics(SM_CXBORDER)+ GetSystemMetrics(SM_CYBORDER);
p-> ptMaxSize.y = GetSystemMetrics(SM_CYFULLSCREEN) + GetSystemMetrics(SM_CYCAPTION);
     // + GetSystemMetrics(SM_ CYDLGFRAME) + GetSystemMetrics(SM_CYBORDER);
}
return TRUE;
}