riched20: Wrap marked paragraphs at Text Services initialization.

Today, CreateTextServices() returns an Rich Edit object without row
start and end marks, which are expected to exist by many Rich Edit
operations as well as EM_* message handlers.

This leads to a crash when certain messages (e.g., EM_SCROLLCARET) are
sent to the Rich Edit object via ITextServices::TxSendMessage(), unless
ME_WrapMarkedParagraphs() has been called beforehand.

Fix this by calling wrap_marked_paras_dc() early in the initialization
process.

This is not a problem for windowed Rich Edit controls, which already
calls ME_WrapMarkedParagraphs() before the user or application starts
interacting with it.
This commit is contained in:
Jinoh Kang 2023-07-01 13:22:46 +09:00 committed by Alexandre Julliard
parent f1b9150451
commit b70eb32c5f
2 changed files with 19 additions and 0 deletions

View file

@ -222,6 +222,7 @@ void ME_MakeFirstParagraph(ME_TextEditor *editor)
wine_rb_init( &editor->marked_paras, para_mark_compare );
para_mark_add( editor, para );
ME_DestroyContext(&c);
wrap_marked_paras_dc( editor, hdc, FALSE );
ITextHost_TxReleaseDC( editor->texthost, hdc );
}

View file

@ -1292,6 +1292,23 @@ static void test_set_selection_message( void )
ITextHost_Release( host );
}
static void test_scrollcaret( void )
{
ITextServices *txtserv;
ITextHost *host;
LRESULT result;
HRESULT hr;
if (!init_texthost(&txtserv, &host))
return;
hr = ITextServices_TxSendMessage(txtserv, EM_SCROLLCARET, 0, 0, &result);
ok( hr == S_OK, "got %08lx\n", hr );
ITextServices_Release( txtserv );
ITextHost_Release( host );
}
START_TEST( txtsrv )
{
ITextServices *txtserv;
@ -1326,6 +1343,7 @@ START_TEST( txtsrv )
test_TxGetScroll();
test_notifications();
test_set_selection_message();
test_scrollcaret();
}
if (wrapperCodeMem) VirtualFree(wrapperCodeMem, 0, MEM_RELEASE);
}