Hook into the main message loop?


#1

Is there any way to hook into the main message loop? I know you normally don't want to do this on a cross-platform app. But I'm dealing with the TWAIN standard for accessing scanners and that's what you need to do. And I need the native message/event. Yes I know it's different on Windows and Mac; I'm just implementing Windows at first. All skeptics feel free to peruse the spec. at twain.org.

Failing that, I will need to implement [url=http://www.juce.com/forum/topic/win32notificationwindow]something like this[/url]. But it's not as good for a reason of which I'll mercifully spare you the explaination for now.

Jim


#2

Wow, is TWAIN still going? That's a technology that deserved to die long ago!

I don't provide any way to hook into the message loop because it's so platform-specific and isn't even possible on some OSes. But yes, the easiest way on win32 would be to use a message window like in the post you linked to.


#3

Thanks for the quick answer!

TWAIN is still active since the TWAIN working group has recently churned out versions 2.0 through 2.3 and is currently working on version 2.4. Because it's been around so long, it's still the most popular standard on Windows by far, warts and all. There's not so much use on Mac anymore---most scanner manufacturer's just provide a proprietary interface and their own application but I think the ICA standard is starting to pick up there.

An aspect of TWAIN that can be difficult to deal with is that the scanner driver (data source) displays it's own user interface which means it needs to get messages from the application for button presses and other GUI events. That's why you normally need to hook the main message loop. And it uses the window handle of the app's main window to post messages back to the app. That's not a problem when using a different thread's message queue like in the post I linked to. But the other purpose of the window handle is to act as the parent window of the driver's GUI so the driver's GUI is always displayed in front of the app. So if the window handle comes from the hidden window, as it would in the linked-to post, the driver's GUI won't neccessarily be displayed in front of the app's main window. That's the problem with that method. Perhaps there's a way to chain the windows together, I don't know. I'll have to look into that.


#4

Hey Jules, We have a similar problem in trying to implament this 3DCONNEXION SpaceMouse: https://www.3dconnexion.com/products/spacemouse.html

The spacemouse is initialized by passing a HWND, & you are supposed to hook in to that specific windows callback system – here is a description from 3DConnexion:slight_smile:
https://www.3dconnexion.com/forum/viewtopic.php?f=19&t=8967&p=36169&hilit=callback+for+3d+mouse#


#5

No idea if it existed 3 years ago when this thread started (I wish people wouldn’t revive such old threads!), but you might want to look at this class:

Don’t think it’s public but shows how you could set up a HWND you can use like that.