Well why not. At least Wine code is doing it.
Code:
/* Get the text size */
GetClientRect(GetDlgItem(hwnd, MSGBOX_IDTEXT), &rect);
rect.top = rect.left = rect.bottom = 0;
DrawTextA( hdc, lpszText, -1, &rect,
DT_LEFT | DT_EXPANDTABS | DT_WORDBREAK | DT_CALCRECT);
/* Min text width corresponds to space for the buttons */
tleft = 2 * ileft + iwidth;
twidth = max((bw + bspace) * buttons + bspace - tleft, rect.right);
theight = rect.bottom;
And after that they are calling SetWindowPos() for the buttons.
Code:
/* Position the buttons */
bpos = (wwidth - (bw + bspace) * buttons + bspace) / 2;
for (buttons = i = 0; i < 7; i++) {
/* some arithmetic to get the right order for YesNoCancel windows */
hItem = GetDlgItem(hwnd, (i + 5) % 7 + 1);
if (GetWindowLongA(hItem, GWL_STYLE) & WS_VISIBLE) {
if (buttons++ == ((lpmb->dwStyle & MB_DEFMASK) >> 8)) {
SetFocus(hItem);
SendMessageA( hItem, BM_SETSTYLE, BS_DEFPUSHBUTTON, TRUE );
}
SetWindowPos(hItem, 0, bpos, tiheight, bw, bh,
SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOREDRAW);
bpos += bw + bspace;
}
}
In this code you can see some Wine internals, but you should be
able to change it to your own data structs.
And all of the above is done at WM_INITDIALOG.
Delf