diff --git a/windows/area.cpp b/windows/area.cpp index 2d301855..bdad93f5 100644 --- a/windows/area.cpp +++ b/windows/area.cpp @@ -89,8 +89,7 @@ void uiAreaSetSize(uiArea *a, intmax_t width, intmax_t height) void uiAreaQueueRedrawAll(uiArea *a) { // don't erase the background; we do that ourselves in doPaint() - if (InvalidateRect(a->hwnd, NULL, FALSE) == 0) - logLastError(L"error queueing uiArea redraw"); + invalidateRect(a->hwnd, NULL, FALSE); } void uiAreaScrollTo(uiArea *a, double x, double y, double width, double height) diff --git a/windows/areadraw.cpp b/windows/areadraw.cpp index 77e9aeaf..17b64705 100644 --- a/windows/areadraw.cpp +++ b/windows/areadraw.cpp @@ -127,6 +127,5 @@ void areaDrawOnResize(uiArea *a, RECT *newClient) // according to Rick Brewster, we must always redraw the entire client area after calling ID2D1RenderTarget::Resize() (see http://stackoverflow.com/a/33222983/3408572) // we used to have a uiAreaHandler.RedrawOnResize() method to decide this; now you know why we don't anymore - if (InvalidateRect(a->hwnd, NULL, TRUE) == 0) - logLastError(L"error redrawing area on resize"); + invalidateRect(a->hwnd, NULL, TRUE); } diff --git a/windows/areascroll.cpp b/windows/areascroll.cpp index 782755a9..3e05d0aa 100644 --- a/windows/areascroll.cpp +++ b/windows/areascroll.cpp @@ -33,8 +33,7 @@ static void scrollto(uiArea *a, int which, struct scrollParams *p, intmax_t pos) // Direct2D doesn't have a method for scrolling the existing contents of a render target. // We'll have to just invalidate everything and hope for the best. - if (InvalidateRect(a->hwnd, NULL, FALSE) == 0) - logLastError(L"error invalidating uiArea after scrolling"); + invalidateRect(a->hwnd, NULL, FALSE); *(p->pos) = pos; diff --git a/windows/colorbutton.cpp b/windows/colorbutton.cpp index 21c56cf6..edbba35d 100644 --- a/windows/colorbutton.cpp +++ b/windows/colorbutton.cpp @@ -134,8 +134,7 @@ void uiColorButtonSetColor(uiColorButton *b, double r, double g, double bl, doub b->g = g; b->b = bl; b->a = a; - // TODO don't we have a helper function for this? - InvalidateRect(b->hwnd, NULL, TRUE); + invalidateRect(b->hwnd, NULL, TRUE); } void uiColorButtonOnChanged(uiColorButton *b, void (*f)(uiColorButton *, void *), void *data) diff --git a/windows/fontdialog.cpp b/windows/fontdialog.cpp index ef1fae11..c30230f0 100644 --- a/windows/fontdialog.cpp +++ b/windows/fontdialog.cpp @@ -174,8 +174,7 @@ static WCHAR *fontStyleName(struct fontCollection *fc, IDWriteFont *font) static void queueRedrawSampleText(struct fontDialog *f) { // TODO TRUE? - if (InvalidateRect(f->sampleBox, NULL, TRUE) == 0) - logLastError(L"error queueing a redraw of the font dialog's sample text"); + invalidateRect(f->sampleBox, NULL, TRUE); } static void styleChanged(struct fontDialog *f) diff --git a/windows/uipriv_windows.hpp b/windows/uipriv_windows.hpp index 555c687b..7c43874b 100644 --- a/windows/uipriv_windows.hpp +++ b/windows/uipriv_windows.hpp @@ -65,6 +65,7 @@ extern HWND parentOf(HWND child); extern HWND parentToplevel(HWND child); extern void setWindowInsertAfter(HWND hwnd, HWND insertAfter); extern HWND getDlgItem(HWND hwnd, int id); +extern void invalidateRect(HWND hwnd, RECT *r, BOOL erase); // text.cpp extern WCHAR *windowTextAndLen(HWND hwnd, LRESULT *len); diff --git a/windows/winutil.cpp b/windows/winutil.cpp index 024260f2..2faf8192 100644 --- a/windows/winutil.cpp +++ b/windows/winutil.cpp @@ -130,3 +130,9 @@ HWND getDlgItem(HWND hwnd, int id) logLastError(L"error getting dialog item handle"); return out; } + +void invalidateRect(HWND hwnd, RECT *r, BOOL erase) +{ + if (InvalidateRect(hwnd, r, erase) == 0) + logLastError(L"error invalidating window rect"); +}