[plt-scheme] Interacting with win32 Event Loops

From: Christopher Bowron (cwbowron at gmail.com)
Date: Thu Jun 26 13:17:18 EDT 2008

I'm writing a couple extensions in C to get to some lower level platform
features using mzc, and I'm having trouble figuring out good ways to achieve
my goals.

I want to be able to interact with some win32 features including console
lock notifications and hotkey notifications.

The problem is the notifications come in through the window message loop,
and I don't know a good way to get that information back into the scheme

I've got it working for the console locks using the following method:

the scheme_initialize() function starts a thread that creates a hidden
dialog box with an event handler that toggles a global variable when the
console gets locked or unlocked.  The scheme_initialize() functions also
installs a function just checks the value of this global variable and
returns scheme_false or scheme_true.  Then inside the scheme environment I
basically poll on that function.

I would like to add some global hotkeys which I would also get notifications
of in the same event loop as the console lock notifications.

My current thinking is to create an input port in the C code that blocks
until a hot key message is processed in the event loop, and from the scheme
environment launch a thread that loops while reading in from that port.

There might be a better way to do this, and I'm not sure how to trigger the
input port when a message does get processed if I do go with this route.

My other thought is that this is inside a MrEd frame based program.  If
there were a way to extend the message loop of the MrEd frame itself, it
would also be possible to just register the hotkey with the MrEd frame's
HWND from (send frame get-handle).

Can anybody offer any advice?

This is for my media playback program I am working on
http://www.bazquux.com/wiki/Schemep3.  I want to be able to pause playback
while the computer is locked, and to be able to have global hotkeys for
controlling playback.

Thanks for any help.

Christopher W. Bowron <chris at bowron.us>
[ Nothing is exciting if you know what the outcome will be ]
- Joseph Campbell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20080626/82d08117/attachment.html>

Posted on the users mailing list.