Dave Addey wrote: > Hi all, > > I¹m making good progress with some HID classes for MachO / Win32. I¹ve got > a ³data available² event callback working fine on MachO, following James > Milne¹s approach of creating factories to manage the creation of custom > objects. This works by calling an object instance¹s DataAvailable event > whenever data is available for that object. A reference to the object > instance is passed to the callback function installer, and this reference is > used (when the callback is called) to get a function pointer for the event > and call back into the RB code. > > I¹m now trying to do the same thing on Win32. My knowledge of Win32 coding > isn¹t great, but I think I have the following options: > > 1. Create a new (Win32) thread via CreateThread, with an event loop which > checks for custom events I have defined > 2. Hook in to a window event loop via the approach mentioned by Aaron here: > http://www.aaronballman.com/programming/REALbasic/WindowSubclassingArticle.p > hp to check for my custom events in the window > > 1) should work, I think, but I¹m pretty sure that calling back into RB code > from this background thread will cause problems due to RB not being > thread-safe. 2) would work also, I think, but ties the events to being > processed by a window, and really I want to call into the custom class > instance¹s event, not a custom window event. > > Is there any other way to do this on Win32? That is, to either define a > callback which isn¹t tied to a window, or to use a thread to check for the > events in the background whilst still safely calling into RB code from the > thread? > > Any help very much appreciated on this one!
Approach #1 is not gonna fly- you can't call into REALbasic code from that other thread. Bad Things Will Happen. Approach #2 is probably heading in the right direction. I must admit I've never attempted to do any HID work on Windows, so I don't know how it passes events to the application. What API are you using? You could create your own hidden offscreen window using the Win32 APIs and catch the HID events using your own WndProc. -- Kind regards, James Milne _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html>
