在消息处理函数tWndProc()里面的switch (message) {}下面增加这个处理就行了
RECT rect;
GetWindowRect(hWnd, &rect);//获取窗口高宽数据 if ((rect.bottom - rect.top) <= 500)//当高度大于500
{
MoveWindow(hWnd, rect.left, rect.top, 500, 400, true);//移动窗口
rect.bottom = rect.top + 500; }
if ((rect.right - rect.left) <= 400)//当宽度大于400
{
MoveWindow(hWnd, rect.left, rect.top, 500, 400, true);//移动窗口
rect.right = rect.left + 400;
}