comparison win/dw.c @ 1440:c50f445e891a

Fixed auto-sizing top-level Windows on Windows... Needed to take into account border and titlebar.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 08 Dec 2011 10:10:54 +0000
parents bde7ebced556
children b9577d1f0411
comparison
equal deleted inserted replaced
1439:09fa437d6a5f 1440:c50f445e891a
6553 * The following is an attempt to dynamically size a window based on the size of its 6553 * The following is an attempt to dynamically size a window based on the size of its
6554 * children before realization. Only applicable when width or height is less than one. 6554 * children before realization. Only applicable when width or height is less than one.
6555 */ 6555 */
6556 if ( (width < 1 || height < 1) && (thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA)) ) 6556 if ( (width < 1 || height < 1) && (thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA)) )
6557 { 6557 {
6558 int depth = 0; 6558 int depth = 0, border = GetSystemMetrics(SM_CXSIZEFRAME) * 2;
6559 6559
6560 /* Calculate space requirements */ 6560 /* Calculate space requirements */
6561 _resize_box(thisbox, &depth, width, height, 1); 6561 _resize_box(thisbox, &depth, width, height, 1);
6562 6562
6563 /* Might need to take into account the window border here */ 6563 /* Might need to take into account the window border here */
6564 if ( width < 1 ) width = thisbox->minwidth; 6564 if ( width < 1 ) width = thisbox->minwidth + border;
6565 if ( height < 1 ) height = thisbox->minheight; 6565 if ( height < 1 ) height = thisbox->minheight + GetSystemMetrics(SM_CYCAPTION) + border;
6566 } 6566 }
6567 6567
6568 /* Finally set the size */ 6568 /* Finally set the size */
6569 SetWindowPos(handle, (HWND)NULL, 0, 0, width, height, SWP_SHOWWINDOW | SWP_NOZORDER | SWP_NOMOVE); 6569 SetWindowPos(handle, (HWND)NULL, 0, 0, width, height, SWP_SHOWWINDOW | SWP_NOZORDER | SWP_NOMOVE);
6570 } 6570 }
6640 * The following is an attempt to dynamically size a window based on the size of its 6640 * The following is an attempt to dynamically size a window based on the size of its
6641 * children before realization. Only applicable when width or height is less than one. 6641 * children before realization. Only applicable when width or height is less than one.
6642 */ 6642 */
6643 if ( (width < 1 || height < 1) && (thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA)) ) 6643 if ( (width < 1 || height < 1) && (thisbox = (Box *)GetWindowLongPtr(handle, GWLP_USERDATA)) )
6644 { 6644 {
6645 int depth = 0; 6645 int depth = 0, border = GetSystemMetrics(SM_CXSIZEFRAME) * 2;
6646 6646
6647 /* Calculate space requirements */ 6647 /* Calculate space requirements */
6648 _resize_box(thisbox, &depth, width, height, 1); 6648 _resize_box(thisbox, &depth, width, height, 1);
6649 6649
6650 /* Might need to take into account the window border here */ 6650 /* Might need to take into account the window border here */
6651 if ( width < 1 ) width = thisbox->minwidth; 6651 if ( width < 1 ) width = thisbox->minwidth + border;
6652 if ( height < 1 ) height = thisbox->minheight; 6652 if ( height < 1 ) height = thisbox->minheight + GetSystemMetrics(SM_CYCAPTION) + border;
6653 } 6653 }
6654 6654
6655 /* Finally set the size */ 6655 /* Finally set the size */
6656 SetWindowPos(handle, (HWND)NULL, x, y, width, height, SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOACTIVATE); 6656 SetWindowPos(handle, (HWND)NULL, x, y, width, height, SWP_NOZORDER | SWP_SHOWWINDOW | SWP_NOACTIVATE);
6657 } 6657 }