I have solved the problem! See the original post, "A strange problem with modeless dialog boxes", for details.
This is a repost, incorporating the latest simplifications of the problem statement, and a minimal reproducible example of the code...
I'm having a problem with modeless dialog boxes...
application
c++
code optimization
debugging
dialog boxes
event handling
file scanning
graphics
gui
linked list
modeless
multi-threading
performance
progress bar
sleep function
system calls
timers
user interface
windowprocedurewindows development
background color
border drawing
c++
control handling
device context
error handling
events
gdi
graphics
message loop
opengl
paint handling
rich edit
static control
user interface
windowprocedurewindow resizing
windows api
wm_paint