Resizing Edit Control in a dialog box.

Resizing Edit Control in a dialog box.

Post by Steven Lyo » Sun, 01 Sep 1996 04:00:00



I want to be able to resize an Edit box when the parent dialog box is
resized. I cannot seem to get this to work and I am not having very
much with the online help.

This is my latest try at resizing:

void CAdderDialog::OnSize(UINT nType, int cx, int cy)
{
        CDialog::OnSize(nType, cx, cy);

        ((CEdit*) GetDlgItem(IDC_NEWTEXT))->MoveWindow (0,0, cx, cy, TRUE);

Quote:}

I keep getting an error that says, to the effect, that the edit
control is not a window. I thought CEdit was derived from CWnd,
thereby making it a window? Please help!

Lyons

--
Jayho

http://www.teleport.com/~lyons

 
 
 

Resizing Edit Control in a dialog box.

Post by Martin Vo » Sun, 01 Sep 1996 04:00:00


: I want to be able to resize an Edit box when the parent dialog box is
: resized. I cannot seem to get this to work and I am not having very
: much with the online help.

: This is my latest try at resizing:

: void CAdderDialog::OnSize(UINT nType, int cx, int cy)
: {
:       CDialog::OnSize(nType, cx, cy);
:      
:       ((CEdit*) GetDlgItem(IDC_NEWTEXT))->MoveWindow (0,0, cx, cy, TRUE);

: }

: I keep getting an error that says, to the effect, that the edit
: control is not a window. I thought CEdit was derived from CWnd,
: thereby making it a window? Please help!

Problem arised because OnSize is called also _before_ edit box is created.
You only have to make sure, that editbox window (not only edit box class)
does exist:

void CAdderDialog::OnSize(UIT nType, int cx, int cy)
{
        CDialog::OnSize(nType,cx,cy);
        CEdit * pEdit = (CEdit*) GetDlgItem(IDC_NEWTEXT);

        if (pEdit && pEdit->IsWindow())
                pEdit->MoveWindow(0,0,cx,cy,TRUE);

Quote:}

p.s. CWnd::IsWindow() doesn't state if the object is of type window, but check for
validity of objects m_hWnd handle.

--
---------------------------------------------------------------------------
 Jedina jistota je,    Martin Vobr at Prague University of Economics  wWWWw

 a ty mne ....         www:      http://manes.vse.cz/~xvobm02         ~ - ~
  (Zuby nehty)         hardware: PC Pentium + brain                    ~~~  
                       tel/fax:  +042 (02) 788 13 52    

 
 
 

Resizing Edit Control in a dialog box.

Post by Keith Benedic » Wed, 04 Sep 1996 04:00:00


:       if (pEdit && pEdit->IsWindow())
:               pEdit->MoveWindow(0,0,cx,cy,TRUE);

The previous code you added doesn't work.  IsWindow() is not a member of
CWnd or CEdit.  It is part of the API.  Replace the last two lines with...

        if (IsWindow(pEdit->GetSafeHwnd()))
                pEdit->MoveWindow(0,0,cx,cy,TRUE);

...and it works just fine.
--
Keith Benedict
Software Engineer
Triad Systems




: : I want to be able to resize an Edit box when the parent dialog box is
<snip>
:
: Problem arised because OnSize is called also _before_ edit box is
created.
: You only have to make sure, that editbox window (not only edit box class)

: does exist:
:
: void CAdderDialog::OnSize(UIT nType, int cx, int cy)
: {
:       CDialog::OnSize(nType,cx,cy);
:       CEdit * pEdit = (CEdit*) GetDlgItem(IDC_NEWTEXT);
:
:       if (pEdit && pEdit->IsWindow())
:               pEdit->MoveWindow(0,0,cx,cy,TRUE);
: }
:
:
: p.s. CWnd::IsWindow() doesn't state if the object is of type window, but
check for
: validity of objects m_hWnd handle.
:
: --
:
---------------------------------------------------------------------------
:  Jedina jistota je,    Martin Vobr at Prague University of Economics
wWWWw

-o-o-
:  a ty mne ....         www:      http://manes.vse.cz/~xvobm02         ~ -
~
:   (Zuby nehty)         hardware: PC Pentium + brain                  
~~~  
:                        tel/fax:  +042 (02) 788 13 52    
:  
:

 
 
 

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. GTA3 crashes even after fixes

3. Resizing/Moving edit control in a dialog box

4. Win 98 Disables Competitors' Software - Infoworld

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

6. Blue screen errors

7. resizing control in dialog box

8. xerox printer

9. Subclass a dialog box edit control?

10. Starting dialog box with a given edit control active

11. word wrap in a edit control of a dialog box

12. Adding an cr/lf to a modeless dialog box edit control?

13. Display format of edit control in a dialog box