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++
debugging
dialog box
document scanning
event handling
graphics
gui
linked list
modeless
multithreading
performance
progress bar
sleep function
software optimization
system calls
timer
user interface
windowprocedurewindows development
background
border drawing
c++
control handling
device context
error handling
event
gdi
graphics
message loop
opengl
paint handling
rich edit
static control
user interface
windowprocedurewindow resizing
windows api
wm_paint