Search code examples
c#winapidirectshowdirectshow.net

Direct Show SetNotifyWindow function


From sourceforge I have downloaded some samples to help me in using Direct Show library.In the code he defined a constant(use it as address) to use it in SetNotifyWindow I don't understand why we refer to certain Message defined finally by us.

Constant (Message):

 // Application-defined message to notify app of filtergraph events
 public const int WM_GRAPHNOTIFY = 0x8000 + 1;

Media event property:

// provides method to retrieve the events 
IMediaEventEx mediaEventEx;

SetNotifyWindow function use this address:

 //set the notify window
        //(NB:hr-->hresult (com device error for more http://msdn.microsoft.com/en-us/library/windows/desktop/dd375623%28v=vs.85%29.aspx)
        int hr = mediaEventEx.SetNotifyWindow(ptr, WM_GRAPHNOTIFY, IntPtr.Zero);

Solution

  • You are setting up the notification. You tell FGM what message to send back to you when you are supposed to jump in with some processing.

    From MSDN on IMediaEventEx::SetNotifyWindow:

    When the window receives the message, it should call the IMediaEvent::GetEvent method to retrieve the event. Events are asynchronous, so the queue might contain several events (or none). Call GetEvent repeatedly, until it returns an error code.