From: Steve Schlesinger on
I need to create controls dynamically in an app.

I wrote the following test code but can't get the dynamically created
CEdit control to show the client edge (WS_EX_CLIENTEDGE).

The dialog has a CEdit defined in the dialog editor
with a member variable m_edit.

the code is as follows:
BOOL CEditCtrlDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Dynamic control creation
// Get location of new control.
CRect editRect;
m_edit.GetWindowRect(&editRect);
editRect.top +=20;
editRect.bottom +=20;

// CEdit Dynamic
DWORD myeditStyle = WS_CHILD | ES_AUTOHSCROLL | WS_VISIBLE |
WS_EX_CLIENTEDGE;

BOOL res = m_dyn_edit.Create( myeditStyle, editRect, this, 1003 );
DWORD editStyle = m_edit.GetStyle();
DWORD editStyleX = m_edit.GetExStyle();
TRACE( "Edit 0x%x Ex 0x%x \n", editStyle, editStyleX );

m_dyn_edit.ModifyStyle( 0xffffffff, editStyle );
m_dyn_edit.ModifyStyleEx( 0xffffffff, editStyleX );
m_dyn_edit.ModifyStyleEx( 0, WS_EX_CLIENTEDGE );
m_dyn_edit.RedrawWindow();

return TRUE; // return TRUE unless you set the focus to a control
}

I have tried several variations, but m_dyn_edit always appears without any
border at all,
while m_edit looks like a standard edit control.

Thanks-

Steve


From: David Lowndes on
Steve,

>CEdit control to show the client edge (WS_EX_CLIENTEDGE).

Use CreateEx. For example:

m_dyn_edit.CreateEx( WS_EX_CLIENTEDGE, "Edit",
"Centre Aligned", ES_CENTER | WS_CHILD | WS_VISIBLE,
rc, this, IDC_EDIT1 );

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
From: Steve Schlesinger on
It worked, thanks. Dave.

I assume this means that WS_EX_CLIENTEDGE is a property
that can only be set at CreateEx time and that ModifyStyleEx can't change
it.

Correct?

-Steve

"David Lowndes" <davidl(a)example.invalid> wrote in message
news:p5p711t3kpjfqols5dvku4nbkj1m5u8tba(a)4ax.com...
> Steve,
>
> >CEdit control to show the client edge (WS_EX_CLIENTEDGE).
>
> Use CreateEx. For example:
>
> m_dyn_edit.CreateEx( WS_EX_CLIENTEDGE, "Edit",
> "Centre Aligned", ES_CENTER | WS_CHILD | WS_VISIBLE,
> rc, this, IDC_EDIT1 );
>
> Dave
> --
> MVP VC++ FAQ: http://www.mvps.org/vcfaq


From: David Lowndes on
>I assume this means that WS_EX_CLIENTEDGE is a property
>that can only be set at CreateEx time and that ModifyStyleEx can't change
>it.

I think it'd work (haven't tried it) if you did it this way:

m_Ctrl.ModifyStyleEx( 0, WS_EX_CLIENTEDGE, SWP_DRAWFRAME );

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq