Integrated Application Platform › Forums › General › Display issues with adding/removing from VertConrol › Re: Re: Display issues with adding/removing from VertConrol
That makes sense.
When it creates the control (via Hwnd.CreateWindow) it does not know the final size or position – this is determined by the layout Recalc
So it creates it at an arbitrary position and size and then the first Resize adjusts the position and size.
This works fine when you are constructing the whole window at once because you only see the final result. But not so good with dynamically creating controls.
I’m still not sure why it’s actually getting painted with the original (wrong) position/size. I thought painting wasn’t done till you returned to the message loop and processed paint messages. Unless you call UpdateWindow, but I do not think it is getting called.
Maybe what we should be doing is creating the controls without WS.VISIBLE and then making them visible after the first Resize (SetWindowPos)
I made this simple test:
Window(Controller
{
Xmin: 800
Ymin: 600
Controls: (Vert (Button Add))
On_Add()
{ .Vert.Insert(.Vert.Tally(), #(Field)) }
})
It flickers. If I add this in Hwnd.CreateWindow just before CreateWindowEx
.show = (style & WS.VISIBLE) is WS.VISIBLE
style &= ~WS.VISIBLE
and add this in Hwnd.Resize just before SetWindowPos
if .show
{
.SetVisible(true)
.show = false
}
Now my simple test does not flicker 🙂 But RepeatControl still flickers 🙁 Maybe something to do with it using WndPaneControl ?
WARNING: Be careful modifying Hwnd or similar code. For example, if you make a syntax error you can crash the Suneido UI. I usually Dump() just before making these kinds of changes. Then if you crash you can restore with suneido -load