views:

43

answers:

1

This is something I'd expect to be quite straightforward, but after a couple of hours browsing Visual Explorer online help and ploughing through various forums, I'm still at a loss...

Basically, I'd like to be able to create a custom Windows event which sends a vector of short integers to its recipient. I'd actually like to create the event inside a Fortran DLL, but if I can find the correct API calls to do it from C++ then I should be able to figure the rest out. All of the examples I've been able to find so far, even for C++, use the .NET library and I cannot access this from Fortran, so it would have to be the native Windows API.

If it makes any difference, the event would subsequently be captured as a QEvent by a GUI application written using Qt.

Any ideas would be appreciated.

A: 

Use SendMessage to send a message: http://msdn.microsoft.com/en-us/library/ms644950%28VS.85%29.aspx

Then simply use a number that is not yet used by any other message. You can use RegisterWindowMessage to get a unique number: http://msdn.microsoft.com/en-us/library/ms644947%28VS.85%29.aspx If you only need to communicate in your own app, you don't need this and you can pick any number between 0x0400 and 0x7FFF.

Ruud v A
This looks very promising, thank you. It's the classic thing with online searches - I should have typed in "message" rather than "event" and perhaps I'd have found the answer.In the meantime I'm looking at an alternative approach where, when the GUI application calls the DLL, it supplies a callback function which the DLL can invoke when it has data ready; the callback can then either generate a QEvent or an ordinary Qt signal. If I can get this to work then it should be a better solution, as it would be more portable than anything which uses the Windows API directly.
Eos Pengwern
An update; the callback approach works well and is a much better solution for what I'm trying to do, which is to give the GUI periodic updates of how a long calculation in the DLL is proceeding. Doing it this way, all of the event-based communication is held within the GUI code, which in my case means Qt signals-and-slots. This is both simpler and more portable.
Eos Pengwern
Just use whatever seems best for you :) If it works fine with callbacks, there's no need to use messages.
Ruud v A