resizing control in dialog box

resizing control in dialog box

Post by David Stri » Sun, 22 Sep 2002 03:22:44



I know there are lots of articles on this in CodeGuru and the like, but
they don't quit fit the bill.

CListWindow is a dialog box that contains nothing but an edit control. I
want the control to fill the dialog window, and I want it resizable.
When I create the dialog, I set the frame type to resizable and add an
OnSize handler. The handler looks like

     void CListWindow::OnSize(UINT nType, int cx, int cy)
     {
       CDialog::OnSize(nType, cx, cy);
       if (m_init)
         m_edit_control.MoveWindow(0, 0, cx, cy);
     }

m_init is a bol that is initialized to false, set to true in
OnInitDialog. This is necessary because OnSize appears to be called
during creation, before the edit control is created.
So far, so good. The control resizes as the dialog window is sized. One
problem - When the dialog first appears, the edit box is as big as it is
drawn in the visual layout. The layout leaves a border of ~15 pixels
(what's this frame called?) in the dialog where you can't put controls.
When the window is resized, the control fills this area.

How to fix this?
One way is to keep the control from expanding into this frame area. If
so, how do you get the width of this frame?

I prefer the look of the fully expanded box. How do I invoke the
m_edit_control.MoveWindow() during the dialog creation, *after* the
control has been created? I know I could probably do this by creating
CFullSizeEdit, inheriting from CEdit, then putting what I need in the
Create or something like that. I would prefer not to go this route. I
would prefer the handling to occur in the dialog class.

Thanks
David Strip

 
 
 

resizing control in dialog box

Post by Scott McPhillip » Sun, 22 Sep 2002 10:54:33



> I know there are lots of articles on this in CodeGuru and the like, but
> they don't quit fit the bill.

> CListWindow is a dialog box that contains nothing but an edit control. I
> want the control to fill the dialog window, and I want it resizable.
> When I create the dialog, I set the frame type to resizable and add an
> OnSize handler. The handler looks like

>      void CListWindow::OnSize(UINT nType, int cx, int cy)
>      {
>        CDialog::OnSize(nType, cx, cy);
>        if (m_init)
>          m_edit_control.MoveWindow(0, 0, cx, cy);
>      }

> m_init is a bol that is initialized to false, set to true in
> OnInitDialog. This is necessary because OnSize appears to be called
> during creation, before the edit control is created.
> So far, so good. The control resizes as the dialog window is sized. One
> problem - When the dialog first appears, the edit box is as big as it is
> drawn in the visual layout. The layout leaves a border of ~15 pixels
> (what's this frame called?) in the dialog where you can't put controls.
> When the window is resized, the control fills this area.

> How to fix this?
> One way is to keep the control from expanding into this frame area. If
> so, how do you get the width of this frame?

> I prefer the look of the fully expanded box. How do I invoke the
> m_edit_control.MoveWindow() during the dialog creation, *after* the
> control has been created? I know I could probably do this by creating
> CFullSizeEdit, inheriting from CEdit, then putting what I need in the
> Create or something like that. I would prefer not to go this route. I
> would prefer the handling to occur in the dialog class.

> Thanks
> David Strip

I think the border area you are seeing is merely a layout guide that you
can turn on or off in the resource editor.  When in the editor, try the
Layout:Guide Settings menu command.

You shouldn't have to invoke OnSize yourself - it will be called after
the control is created and before the window is displayed.  If that's
not happening for you try changing "if (m_init)" to "if
(m_edit_control.GetSafeHwnd())"

--
Scott McPhillips [VC++ MVP]

 
 
 

resizing control in dialog box

Post by David Stri » Wed, 25 Sep 2002 01:34:34



> I think the border area you are seeing is merely a layout guide that you
> can turn on or off in the resource editor.  When in the editor, try the
> Layout:Guide Settings menu command.

thanks - that did it. Should have looked there.

Quote:> You shouldn't have to invoke OnSize yourself - it will be called after
> the control is created and before the window is displayed.  If that's
> not happening for you try changing "if (m_init)" to "if
> (m_edit_control.GetSafeHwnd())"

It is called by the framework, not me, so that's not a problem.

--
David Strip                           Eastman Kodak Company

505-294-8515                      Albuquerque, NM  87112-1881
505-294-8565 (fax)

 
 
 

1. Resizing dialog Box or Elastic control tool for Dialog Boxes.

Hi
        I desperately need an elastic control tools/classes for my dialog boxes.
I'm compiling my application with UNICODE. Are there any product like this
available on the market ? I need them for Visual C++ 4.2 or higher.

Please help me
Aparna
--
Software Moguls Inc

URL :http://www.moguls.com

2. NET

3. Resizing/Moving edit control in a dialog box

4. Encarta '94 WAV files

5. Resizing Edit Control in a dialog box.

6. Windows problem ... A: drive access.

7. Resizing subclassed edit control in a resizing dialog???

8. Boot from CD problems

9. list box controls in dialog box

10. resizing e-mail dialog box

11. Resizing List Box along with Main Dialog

12. Resizing dialog boxes

13. Resizing Dialog Box - Min/Max Size?