On 10/15/2018 7:36 AM, Dan Muller wrote:
On Sunday, October 14, 2018 at 9:20:42 PM UTC-4, Alex Harsanyi wrote:
However, I don't think it is a good idea to create many widgets
dynamically in event callbacks, than just leave them around to be
garbage collected, which your example code does. In a real
application, you should consider:
* create all widgets you need before the top-level frame or dialog
is shown, the widgets that don't need to be visible can be created
with a 'deleted style. You can than use change-children to add or
remove widgets as needed, to change the visual contents of the
window as needed.
* for displaying tabular data, consider using a list-box% control,
as it supports multiple columns which can be shown/hidden.
I haven't investigated the problem - other than to confirm that it also
doesn't work on Win7 under 6.12.
I haven't done much GUI programming in Racket ... just playing ... but I
have done a lot of Windows GDI programming.
I would second Alex's warning about creating objects in the display
handler. Generally, updating the display needs to be as fast as
possible. If the update process is very complicated, you should
double-buffer by creating an offscreen (memory) drawing context,
modifying that as desired, and then copying it to the actual display.
For more see:
https://docs.microsoft.com/en-us/windows/desktop/gdi/windows-gdi
It will give you an idea of what works (or doesn't) in Windows so you
transliterate the ideas to Racket.
[ Aside: Windows has a poorly documented gotcha for multithreaded
programs. When a window's display is invalidated and has to be redrawn
(like when it emerges from behind something else, or the programmer can
invalidate manually), the thread that handles the WM_PAINT (draw me)
message gets a huge priority boost until the update is completed. This
can delay other program threads even if their base priorities are higher
than the one updating the display. A non-display thread has be
THREAD_PRIORITY_TIME_CRITICAL to be unaffected, but threads using very
high priority invite other issues.
This does NOT affect Racket's own threads, but is a concern for using
Racket places because they are built on Windows (OS) threads. ]
George
--
You received this message because you are subscribed to the Google Groups "Racket
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.