Application::DoEvents
does a lot more than just refresh the screen. It actually pumps the message queue for the application's UI thread. If you wanted to do this in assembler, you would need to pump the message queue yourself. However, I don't recommend this. Using DoEvents
in any UI framework is a definite anti-pattern, whether it provides such a function or not. More information is here and here.
If all you want to do is ensure that your listbox control gets repainted, then you need to invalidate it and force a redraw. In WinForms, that would be:
myListBox.Invalidate();
myListBox.Update();
In assembler, you will need to invoke the appropriate Win32 API functions yourself. In particular, you can use InvalidateRect
to invalidate the client area of your listbox control and then UpdateWindow
to ensure that it gets repainted immediately.
I don't know the syntax for MASM, but in unmanaged C++, it would look like this:
InvalidateRect(hListBox, /* handle to your listbox control */
NULL, /* invalidate the entire client area */
TRUE); /* erase the background */
UpdateWindow(hListBox);
In most cases, invalidating the window is enough. You don't need to force an immediate repaint, because the next time that your application processes messages (in its regular message loop), it will process a WM_PAINT
message and redraw the control. The only reason this wouldn't work is if you were blocking the UI thread by performing some type of long-running operation, which you should not be doing in the first place—spin off a background thread to perform calculations.
The reason sending a WM_SETREDRAW
message doesn't work here is because that basically sets a flag indicating whether the control is allowed to redraw itself. As the linked documentation explains, the window still needs to be redrawn in order to see the changes. It says you can force this by calling, e.g., RedrawWindow
or doing the same thing we did above.