bops 1 Posting Whiz in Training

Hello.

I am having a little trouble with enabling and disabling word wrapping in a normal edit control.

hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", 
        WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL,
        0, 0, 100, 100, hwnd, NULL, GetModuleHandle(NULL), NULL);

// This is how my control was created...

And this is how I am trying to Enable/Disable word wrapping at the moment.

LONG_PTR hEditStyles;
hEditStyles = GetWindowLongPtr(hEdit, GWL_STYLE);     

if (hEditStyles & WS_HSCROLL) // Does hEdit contain style WS_HSCROLL?
{
    SetWindowLongPtr(hEdit, GWL_STYLE, WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE | ES_AUTOVSCROLL);
    //SetWindowLongPtr(hEdit, GWL_STYLE, hEditStyles & ~ES_AUTOHSCROLL);
    //SetWindowLongPtr(hEdit, GWL_STYLE, hEditStyles & ~WS_HSCROLL);
}
                       
if (!(GetWindowLongPtr(hEdit, GWL_STYLE) & WS_HSCROLL))
{                                                  
    SetWindowLongPtr(hEdit, GWL_STYLE, WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL | ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL);
    //SetWindowLongPtr(hEdit, GWL_STYLE, hEditStyles & WS_HSCROLL);
    //SetWindowLongPtr(hEdit, GWL_STYLE, hEditStyles & ES_AUTOHSCROLL);
}

SendMessage(hwnd, WM_SIZE, 0, 0); // Done so the change is visible immediately.

/* Obviously the commented out code I have also tried, but neither work. I have also tried using a global flag variable to decide which course of action to take (Enable or Disable) with no success. */

My code makes the horizontal scrollbar appear and disappear etc, but the text inside the control behaves as it did.

I did however notice that if I specify when creating the control i.e. in the first code snippet that if I explicitly define the window styles to include or not include WS_HSCROLL and ES_AUTOSCROLL, word wrapping is enabled or disabled from the start. The edit control just doesn't seem to take any notice of the messages I am sending it.

Am I going about this the wrong way or is there a not-too-complex work-around? (I'm just getting back into the swing of things after a long time not doing this kind of stuff, so please don't ask me to subclass and what have you!)

Thanks in advance.