Add a sizing border and handle WM_SIZING. Make sure that the left and right members of the rect* (LPARAM) don't change or exceed the desired width.
Another alternative is to handle WM_NCHITTEST. In it call DefWindowProc to get the current hit-test value, if it's either of HTRIGHT or HTLEFT then return HTCLIENT or HTBORDER and the cursor won't change to the sizing one, thus disabling it.
Code:
case WM_NCHITTEST:
{
LRESULT lRes = DefWindowProc(hWnd, msg, wParam, lParam);
if(lRes == HTLEFT || lRes == HTRIGHT)
{
return HTBORDER;
}
return lRes;
}
break;
If you don't want them to be able to click the corners to resize the window add HTBOTTOMLEFT, HTBOTTOMRIGHT, HTTOPLEFT and HTTOPRIGHT to the above. If you'd like the corners to be used, you'll have to implement WM_SIZING as above to enforce the width constraint.
For a dialog it's one of those times you have to explicitly set the return value.
Code:
#include <windowsx.h>
INT_PTR CALLBACK DlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static BOOL bRecursing = FALSE;
switch(msg)
{
case WM_NCHITTEST:
{
CheckDefDlgRecursion(&bRecursing);
LRESULT lRes = DefDlgProcEx(hWnd, msg, wParam, lParam, &bRecursing);
if(lRes == HTLEFT || lRes == HTRIGHT)
{
lRes = HTBORDER;
}
return SetDlgMsgResult(hWnd, msg, lRes);
}
break;
}
return FALSE;
}