changing size of dialog box 
Author Message
 changing size of dialog box

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



Sat, 31 Jan 2004 02:58:47 GMT  
 changing size of dialog box
You should use the GetWindowRect() instead of the GetClientRect()

Cheers
Check Abdoul
-----------------

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



Sat, 31 Jan 2004 03:35:54 GMT  
 changing size of dialog box
MoveWindow is moving the entire window ... not the client window.  Use
GetWindowRect() instead not GetClientRect().

HTH,
John

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



Sat, 31 Jan 2004 03:46:14 GMT  
 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



Sat, 31 Jan 2004 04:03:13 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. change size of dialog box according to number of lines in Cstring

2. How to change the color,size,font of text in a dialog box

3. How to change the color,size,font of text in a dialog box

4. Moving / Resizing and window AND Changing the size of an edit box control

5. Edit box position and size change

6. Cdialog box keeps changes size

7. how to change edit box font size?

8. changing caret size in edit box

9. owner-draw combo box does not change its size

10. changing the size of the text of a static box

11. Edit box position and size change

12. dialog size in evc++ dialog editor not the same as size in pixels on device

 

 
Powered by phpBB® Forum Software