Commit 902afbc6 authored by Dylan Smith's avatar Dylan Smith Committed by Alexandre Julliard

richedit: Prevented using NULL hwnd for certain operations.

Certain operations will simply not be done for windowless richedit controls, such as WM_PAINT which isn't done for windowless richedit controls since ITextServices provides a TxDraw method.
parent 05c788ac
......@@ -338,6 +338,7 @@ typedef struct tagME_TextEditor
ME_TextBuffer *pBuffer;
ME_Cursor *pCursors;
DWORD styleFlags;
DWORD exStyleFlags;
int nCursors;
SIZE sizeWindow;
int nTotalLength, nLastTotalLength;
......
......@@ -1036,7 +1036,6 @@ static void ME_DrawParagraph(ME_Context *c, ME_DisplayItem *paragraph)
void ME_ScrollAbs(ME_TextEditor *editor, int x, int y)
{
LONG winStyle;
BOOL bScrollBarIsVisible, bScrollBarWillBeVisible;
int scrollX = 0, scrollY = 0;
......@@ -1065,20 +1064,23 @@ void ME_ScrollAbs(ME_TextEditor *editor, int x, int y)
NULL, NULL, SW_INVALIDATE);
ME_Repaint(editor);
winStyle = GetWindowLongW(editor->hWnd, GWL_STYLE);
bScrollBarIsVisible = (winStyle & WS_HSCROLL) != 0;
bScrollBarWillBeVisible = (editor->nTotalWidth > editor->sizeWindow.cx)
|| (editor->styleFlags & ES_DISABLENOSCROLL);
if (bScrollBarIsVisible != bScrollBarWillBeVisible)
ITextHost_TxShowScrollBar(editor->texthost, SB_HORZ,
bScrollBarWillBeVisible);
bScrollBarIsVisible = (winStyle & WS_VSCROLL) != 0;
bScrollBarWillBeVisible = (editor->nTotalLength > editor->sizeWindow.cy)
|| (editor->styleFlags & ES_DISABLENOSCROLL);
if (bScrollBarIsVisible != bScrollBarWillBeVisible)
ITextHost_TxShowScrollBar(editor->texthost, SB_VERT,
bScrollBarWillBeVisible);
if (editor->hWnd)
{
LONG winStyle = GetWindowLongW(editor->hWnd, GWL_STYLE);
bScrollBarIsVisible = (winStyle & WS_HSCROLL) != 0;
bScrollBarWillBeVisible = (editor->nTotalWidth > editor->sizeWindow.cx)
|| (editor->styleFlags & ES_DISABLENOSCROLL);
if (bScrollBarIsVisible != bScrollBarWillBeVisible)
ITextHost_TxShowScrollBar(editor->texthost, SB_HORZ,
bScrollBarWillBeVisible);
bScrollBarIsVisible = (winStyle & WS_VSCROLL) != 0;
bScrollBarWillBeVisible = (editor->nTotalLength > editor->sizeWindow.cy)
|| (editor->styleFlags & ES_DISABLENOSCROLL);
if (bScrollBarIsVisible != bScrollBarWillBeVisible)
ITextHost_TxShowScrollBar(editor->texthost, SB_VERT,
bScrollBarWillBeVisible);
}
ME_UpdateScrollBar(editor);
}
......@@ -1152,8 +1154,14 @@ void ME_UpdateScrollBar(ME_TextEditor *editor)
editor->horz_si.nMin = si.nMin;
editor->horz_si.nMax = si.nMax;
editor->horz_si.nPage = si.nPage;
if (bScrollBarWillBeVisible || bScrollBarWasVisible)
SetScrollInfo(editor->hWnd, SB_HORZ, &si, TRUE);
if (bScrollBarWillBeVisible || bScrollBarWasVisible) {
if (editor->hWnd) {
SetScrollInfo(editor->hWnd, SB_HORZ, &si, TRUE);
} else {
ITextHost_TxSetScrollRange(editor->texthost, SB_HORZ, si.nMin, si.nMax, FALSE);
ITextHost_TxSetScrollPos(editor->texthost, SB_HORZ, si.nPos, TRUE);
}
}
}
if (si.fMask & SIF_DISABLENOSCROLL)
......@@ -1186,8 +1194,14 @@ void ME_UpdateScrollBar(ME_TextEditor *editor)
editor->vert_si.nMin = si.nMin;
editor->vert_si.nMax = si.nMax;
editor->vert_si.nPage = si.nPage;
if (bScrollBarWillBeVisible || bScrollBarWasVisible)
SetScrollInfo(editor->hWnd, SB_VERT, &si, TRUE);
if (bScrollBarWillBeVisible || bScrollBarWasVisible) {
if (editor->hWnd) {
SetScrollInfo(editor->hWnd, SB_VERT, &si, TRUE);
} else {
ITextHost_TxSetScrollRange(editor->texthost, SB_VERT, si.nMin, si.nMax, FALSE);
ITextHost_TxSetScrollPos(editor->texthost, SB_VERT, si.nPos, TRUE);
}
}
}
if (si.fMask & SIF_DISABLENOSCROLL)
......
......@@ -58,6 +58,7 @@ ITextHost *ME_CreateTextHost(HWND hwnd, BOOL bEmulateVersion10)
texthost->bEmulateVersion10 = bEmulateVersion10;
editor = ME_MakeEditor((ITextHost*)texthost, bEmulateVersion10);
editor->exStyleFlags = GetWindowLongW(hwnd, GWL_EXSTYLE);
editor->hWnd = hwnd; /* FIXME: Remove editor's dependance on hWnd */
SetWindowLongPtrW(hwnd, 0, (LONG_PTR)editor);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment