From: Geo on
Hello everyone,

How can I do it dynamically, from a menu option say? I know that if I change
the multiline CEdit style to ES_AUTOHSCROLL, it will do it automatically. But
how can I modify the CEdit style to enable/disable ES_AUTOHSCROLL dynamically?

Thanks,
Geo
From: James Simpson on
Take a look at ModifyStyleEx for that control variable. It will allow you to
change the 'styles' of the control allowing for such change.

Regards,
James Simpson
From: Geo on
Thank you for your response. I tried it and it's not working. I added a menu
item called "Word Wrap". Here's what I'm doing:


1. In the OnInitDialog():
m_bWordWrap = ((m_edt.GetStyle() & (ES_AUTOHSCROLL | WS_HSCROLL)) == 0);


2. In the command handler of the menu item:
void CMyDlg::OnOptionWordwrap()
{
// TODO: Add your command handler code here
m_bWordWrap = !m_bWordWrap;

DWORD style = m_edt.GetStyle();
TRACE("Before: AutoHScroll=%d\n", ((style & ES_AUTOHSCROLL) ==
ES_AUTOHSCROLL));
TRACE("Before: HScrollBar=%d\n", ((style & WS_HSCROLL) == WS_HSCROLL));

if (m_bWordWrap == true)
m_edt.ModifyStyle(ES_AUTOHSCROLL | WS_HSCROLL, SWP_DRAWFRAME |
SWP_FRAMECHANGED | SWP_SHOWWINDOW);
else
m_edt.ModifyStyle(0, ES_AUTOHSCROLL | WS_HSCROLL, SWP_DRAWFRAME |
SWP_FRAMECHANGED | SWP_SHOWWINDOW);

style = m_edt.GetStyle();
TRACE("After: AutoHScroll = %d\n", ((style & ES_AUTOHSCROLL) ==
ES_AUTOHSCROLL));
TRACE("After: HScrollBar = %d\n", ((style & WS_HSCROLL) == WS_HSCROLL));
}


I would appreciate any help.

Thanks a lot,
Geo
From: AliR on
I don't think that that you can turn that flag on and off.

If you don't find a solution, you can simply delete your current edit
control and create a new one on the fly toggling the flag on and off each
time.

AliR.

"Geo" <Geo(a)discussions.microsoft.com> wrote in message
news:08C38AC3-A451-43D6-A63C-74FFA4AC188D(a)microsoft.com...
> Thank you for your response. I tried it and it's not working. I added a
menu
> item called "Word Wrap". Here's what I'm doing:
>
>
> 1. In the OnInitDialog():
> m_bWordWrap = ((m_edt.GetStyle() & (ES_AUTOHSCROLL | WS_HSCROLL)) == 0);
>
>
> 2. In the command handler of the menu item:
> void CMyDlg::OnOptionWordwrap()
> {
> // TODO: Add your command handler code here
> m_bWordWrap = !m_bWordWrap;
>
> DWORD style = m_edt.GetStyle();
> TRACE("Before: AutoHScroll=%d\n", ((style & ES_AUTOHSCROLL) ==
> ES_AUTOHSCROLL));
> TRACE("Before: HScrollBar=%d\n", ((style & WS_HSCROLL) ==
WS_HSCROLL));
>
> if (m_bWordWrap == true)
> m_edt.ModifyStyle(ES_AUTOHSCROLL | WS_HSCROLL, SWP_DRAWFRAME |
> SWP_FRAMECHANGED | SWP_SHOWWINDOW);
> else
> m_edt.ModifyStyle(0, ES_AUTOHSCROLL | WS_HSCROLL, SWP_DRAWFRAME |
> SWP_FRAMECHANGED | SWP_SHOWWINDOW);
>
> style = m_edt.GetStyle();
> TRACE("After: AutoHScroll = %d\n", ((style & ES_AUTOHSCROLL) ==
> ES_AUTOHSCROLL));
> TRACE("After: HScrollBar = %d\n", ((style & WS_HSCROLL) ==
WS_HSCROLL));
> }
>
>
> I would appreciate any help.
>
> Thanks a lot,
> Geo


From: Geo on
Thank you Alir for your response. I was thinking about doing the same as you
suggests, however I have 2 questions:

1. How can I delete the CEdit object if it was created from a dialog
resource using the dialog editor?

2. How can I get the edit control's (created in the dialog editor) rectangle
size and position to use in the CEdit::Create().

Thank you,
Geo

"AliR" wrote:

> I don't think that that you can turn that flag on and off.
>
> If you don't find a solution, you can simply delete your current edit
> control and create a new one on the fly toggling the flag on and off each
> time.
>
> AliR.
>
> "Geo" <Geo(a)discussions.microsoft.com> wrote in message
> news:08C38AC3-A451-43D6-A63C-74FFA4AC188D(a)microsoft.com...
> > Thank you for your response. I tried it and it's not working. I added a
> menu
> > item called "Word Wrap". Here's what I'm doing:
> >
> >
> > 1. In the OnInitDialog():
> > m_bWordWrap = ((m_edt.GetStyle() & (ES_AUTOHSCROLL | WS_HSCROLL)) == 0);
> >
> >
> > 2. In the command handler of the menu item:
> > void CMyDlg::OnOptionWordwrap()
> > {
> > // TODO: Add your command handler code here
> > m_bWordWrap = !m_bWordWrap;
> >
> > DWORD style = m_edt.GetStyle();
> > TRACE("Before: AutoHScroll=%d\n", ((style & ES_AUTOHSCROLL) ==
> > ES_AUTOHSCROLL));
> > TRACE("Before: HScrollBar=%d\n", ((style & WS_HSCROLL) ==
> WS_HSCROLL));
> >
> > if (m_bWordWrap == true)
> > m_edt.ModifyStyle(ES_AUTOHSCROLL | WS_HSCROLL, SWP_DRAWFRAME |
> > SWP_FRAMECHANGED | SWP_SHOWWINDOW);
> > else
> > m_edt.ModifyStyle(0, ES_AUTOHSCROLL | WS_HSCROLL, SWP_DRAWFRAME |
> > SWP_FRAMECHANGED | SWP_SHOWWINDOW);
> >
> > style = m_edt.GetStyle();
> > TRACE("After: AutoHScroll = %d\n", ((style & ES_AUTOHSCROLL) ==
> > ES_AUTOHSCROLL));
> > TRACE("After: HScrollBar = %d\n", ((style & WS_HSCROLL) ==
> WS_HSCROLL));
> > }
> >
> >
> > I would appreciate any help.
> >
> > Thanks a lot,
> > Geo
>
>
>