Richedit Msftedit strange border

488 views Asked by At

I get really strange behavior when I use more than one RichEdit control:

The first richedit is the bottom one

LoadLibrary("Msftedit.dll");
RichEdit = CreateWindow("RICHEDIT50W", "", ES_READONLY | ES_MULTILINE | WS_HSCROLL | WS_VSCROLL | WS_VISIBLE | WS_CHILD | WS_BORDER | WS_TABSTOP, 5, 370, 600, 300, hwnd, NULL, NULL, NULL);

RichEdit2 = CreateWindow("RICHEDIT50W", "", /*0x550081C4*/ 0x50810804, 610, 65, 600, 300, hwnd, NULL, NULL, NULL);

The first EditControl works as it should, however the second one has some strange border around it. First I tried to use the same styles as for the first richedit, then I found out the style using Spy++. Even if I have the same styles, I get different results, probably the same as if I used WS_EX_CLIENTEDGE extended style for the second richedit. I even tried to free the library and load it again, but with the same result.

Thank You all in advance!

1

There are 1 answers

0
ProXicT On BEST ANSWER

So I figured it out. I have no Idea why, but the second RichEdit is somehow getting the WS_EX_CLIENTEDGE style after is created, so I simply remove the style like so:

LONG lExStyle = GetWindowLong(RichEdit2, GWL_EXSTYLE);
lExStyle &= ~WS_EX_CLIENTEDGE;
SetWindowLong(RichEdit2, GWL_EXSTYLE, lExStyle);

Now the RichEdit looks the same as the first one. But I have really no idea, where the style comes from.