0

When trying to rerender a window with a textbox the corner of the textbox is not rendered correctly. It's just white, there is no corner. Directly after creating the textbox, everything is OK. After rerendering using InvalidateRect(NULL, NULL, true);, the box is away and there is only the text in it until I move the mouse over it.

The edit is created using CreateWindowEx with the parameters WS_EX_CLIENTEDGE and WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL

Update: Just found out that the problem is away when rendering outside of a rectangle.

Example: When loading the WinAPI example project which ships with Mono-D (winsamp.d) and adding the following code to WM_PAINT: RoundRect(dc, 0, 0, 300, 300, 1, 1); and the following code to a button click handler (the one with IDC_BTNCLICK)

                try
                {
                    HMENU h = CreateWindowExW(WS_EX_CLIENTEDGE, "edit".toUTF16z, "".toUTF16z, WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | WS_CLIPCHILDREN, 100, 100, 100, 100, hWnd, cast(HMENU)100, GetModuleHandleA(null), null);
                    HFONT font = CreateFontW(15, 0, 0, 0, FW_NORMAL, 0, 0, 0, CP_UTF8, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, ("Tahoma").toUTF16z);
                    SendMessageA(h, WM_SETFONT, cast(int)font, 0);
                    InvalidateRect(null, null, true);
                }
                catch(Throwable e) {}

the problem occurs.

user3684240
  • 1,420
  • 2
  • 12
  • 18
  • Does your parent window contain the `WS_CLIPCHILDREN` flag? – IInspectable Oct 01 '14 at 14:32
  • No, it does not. When adding it, nothing happens. – user3684240 Oct 01 '14 at 14:51
  • 2
    Please post an [MCVE](http://stackoverflow.com/help/mcve) to make your question complete, answerable, and more valuable to future visitors. – IInspectable Oct 01 '14 at 15:13
  • Just updated the post. – user3684240 Oct 01 '14 at 17:04
  • 1
    I think I had similar problem, perhaps [my solution](http://stackoverflow.com/questions/23378938/edit-control-not-repainted-entirely-with-chosen-brush) can help you? *Please go through my question to make sure I understood your post correct. Look at the pictures and see if that is the problem you get. Thank you.* – AlwaysLearningNewStuff Oct 01 '14 at 19:40
  • I tried calling `RedrawWindow(null, null, null, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE);` as you did but that doesn't work. – user3684240 Oct 01 '14 at 20:04
  • What do you mean exactly when you say "rerender a window"? – Jonathan Potter Oct 01 '14 at 20:11
  • Calling `InvalidateRect(null, null, true);` – user3684240 Oct 01 '14 at 20:25
  • I believe this is a theming issue where the underlying parent window colour is being clipped out by the child's rect. Does your parent have `WS_CLIPCHILDREN` applied? – user1793036 Oct 02 '14 at 01:34
  • 2
    What is the rationale for using the `WS_CLIPCHILDREN` window style for your Edit control? And where is the code that creates the Edit control's parent window? Don't ignore the documentation for [`InvalidateRect`](http://msdn.microsoft.com/en-us/library/windows/desktop/dd145002.aspx) either. The `hWnd` parameter has the following advice: *"Setting this parameter to `NULL` is not recommended."* – IInspectable Oct 02 '14 at 09:04
  • 1
    IInspectable is right: When hWnd is set, the error doesn't occur. Thank you very much for your help! – user3684240 Oct 02 '14 at 12:01

0 Answers0