Re: Capturing PostMessages
On Wed, 21 May 2008 15:01:29 -0700, "Nick Schultz" <nick.schultz@flir.com>
wrote:
Hi there,
I was wondering how I should go about capturing messages posted by the
Kvaser CANLIB Driver in a class that does not make sense for it to a window.
I am creating a push pipeline that takes packets delivered from CANLIB to my
parser, then to filter which pushes it to various objects. Instead of
continuously polling CANLIB for packets, I want it to alert my parser when a
packet is ready. Reading the CANLIB API, it supports asynchonous
notification, however it posts these messages to windows. My problem is
that my parser really shouldn't be a window, infact, I was wanting to make
the whole pipeline its own entity as a DLL. So how should I be capturing
these messages?
Maybe a message-only window?
http://msdn.microsoft.com/en-us/library/ms632599(VS.85).aspx#message_only
CANLIB does have a setCallback procedure that I can specify a callback
function the driver will call on these events, however there are 4 total
events (Rx,Tx,Err,Status) and I need access to 3 of those events. There is
a limitation to this setCallBack proc, which is that only one function can
be assigned per CANLIB handle
the third way CANLIB provides is to wait of an event of ANY kind, this even
includes events internal to the driver. The call does not return with any
useful information(read event, status event, etc...) and doesn't seem like
the greatest option.
Look for functions to retrieve that information; the "wait" function may be
analogous to the Windows WaitMessage function.
So what I would really like to do is have some way to tap into the message
loop that CANLIB posts to and capture its messages without being a window.
It seems that no matter what you do, you need to run a separate thread to
handle these events. Is that how it works? (Even if you go the message
route and your DLL relies on the host program's message loop, you will be
at the mercy of the host going modal for extended periods, which wouldn't
be good for you.)
--
Doug Harrison
Visual C++ MVP