B
beaker
Hello,
I'm trying to make a user control which acts as a frame grabber, and I'm
using the functionality in avicap32.dll to do this. I need to setup a
callback function which gets called whenever a new frame of video fills
the buffer.
My problem is that the breakpoint in the video callback is never
reached. I realise it's likely to be a problem with the way I'm using
avicap, but just wondered if I'm using the delegates correctly as this
is a completely new area to me, and I've been a little confused about them?
Thanks,
Gary
In my namespace I declare:
public delegate bool CallBack();
In my class I have the following for API calls:
[DllImport("user32", EntryPoint = "SendMessage")]
public static extern int SendMessage(int hWnd, uint Msg, int wParam,
int lParam);
// A version of SendMessage where the lparam is a delegate/callback
function
[DllImport("user32", EntryPoint = "SendMessage")]
public static extern int SendMessageWithLparamDelegate(int hWnd, uint
Msg, int wParam, CallBack lpFunc);
To set up my callback function (after successfully creating a capture
window, mCapHwnd) in one of my methods (return values indicate success):
CallBack vidCallBack = new CallBack(VideoStreamCallBack);
ret = SendMessageWithLparamDelegate(mCapHwnd,
WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, vidCallBack);
CallBack errCallBack = new CallBack(ErrorCallBack);
ret = SendMessageWithLparamDelegate(mCapHwnd,
WM_CAP_SET_CALLBACK_ERROR, 0, errCallBack);
And my callbacks (just got breakpoints on the return lines at the moment)
// Should be called everytime the video buffer is filled
public bool VideoStreamCallBack()
{
// Do something
return true;
}
// Error handling callback for avicap
public bool ErrorCallBack()
{
// Do something
return true;
}
I'm trying to make a user control which acts as a frame grabber, and I'm
using the functionality in avicap32.dll to do this. I need to setup a
callback function which gets called whenever a new frame of video fills
the buffer.
My problem is that the breakpoint in the video callback is never
reached. I realise it's likely to be a problem with the way I'm using
avicap, but just wondered if I'm using the delegates correctly as this
is a completely new area to me, and I've been a little confused about them?
Thanks,
Gary
In my namespace I declare:
public delegate bool CallBack();
In my class I have the following for API calls:
[DllImport("user32", EntryPoint = "SendMessage")]
public static extern int SendMessage(int hWnd, uint Msg, int wParam,
int lParam);
// A version of SendMessage where the lparam is a delegate/callback
function
[DllImport("user32", EntryPoint = "SendMessage")]
public static extern int SendMessageWithLparamDelegate(int hWnd, uint
Msg, int wParam, CallBack lpFunc);
To set up my callback function (after successfully creating a capture
window, mCapHwnd) in one of my methods (return values indicate success):
CallBack vidCallBack = new CallBack(VideoStreamCallBack);
ret = SendMessageWithLparamDelegate(mCapHwnd,
WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, vidCallBack);
CallBack errCallBack = new CallBack(ErrorCallBack);
ret = SendMessageWithLparamDelegate(mCapHwnd,
WM_CAP_SET_CALLBACK_ERROR, 0, errCallBack);
And my callbacks (just got breakpoints on the return lines at the moment)
// Should be called everytime the video buffer is filled
public bool VideoStreamCallBack()
{
// Do something
return true;
}
// Error handling callback for avicap
public bool ErrorCallBack()
{
// Do something
return true;
}