
changing size of dialog box
Hi Dave,
The reason the dialog went to the upper left hand corner is because
you used GetClientRect. You need to use GetWindowRect if you want to
keep it in the same place.
Below is a sample of the code I use when I want to resize a dialog
// Create local CRect variable to hold Dialog size
CRect rRect;
// Get the Dialog size
GetWindowRect(rRect);
//Make sure values are positive
rRect.NormalizeRect();
// x position of dialog top left corner
int lx = rRect.left;
// y position of dialog top left corner
int ly = rRect.top;
// width of dialog
int lcx = rRect.right - rRect.left;
// height of dialog
int lcy = rRect.bottom - rRect.top;
// Make sure I subtracted right. Don't want negative values
if(lcx < 0)
lcx = 0 - lcx;
if(lcy < 0)
lcy = 0 - lcy;
//Want to decrease height by 40
lcy = lcy - 40;
// Redraw the dialog in same place but shorter
SetWindowPos(&wndTop, lx, ly, lcx, lcy, SWP_SHOWWINDOW);
Clark
Quote:
>I have a modal dialog box that was created in a resource editor. Under
>certain circumstances, I need some of the controls to go away. I basically
>just need to move a few buttons up and make the whole dialog have a smaller
>height. Moving the buttons seems to work find but when I try to shrink the
>dialog itself like this
>CRect rect(0,0,0,0);
>GetClientRect(rect);
>ClientToScreen(rect);
>rect.bottom -= 30
>MoveWindow(rect);
>it usually ends up shrinking the dialog way to much and putting it in the
>upper left corner of the screen. It seems like I've got my coordinate
>systems confused. How should I be doing this?
>Thanks,
>Dave