views:

174

answers:

2

Hi,

I want to embed the native camera application into custom form. The RECT r properties where I want to embed the camera are the following:

r.top = 26; r.bottom = 220; r.left = 0; r.right = 320;

and this is the method which runs the native camera application:

HRESULT CPhotoCapture::CameraCapture(HWND hwndOwner, LPTSTR pszFilename) { HRESULT hResult; SHCAMERACAPTURE shcc;

//Set the SHCAMERACAPTURE structure
ZeroMemory(&shcc, sizeof(shcc));
shcc.cbSize = sizeof(shcc);
shcc.hwndOwner = hwndOwner;
shcc.pszInitialDir = _T("\\My Documents");
shcc.pszDefaultFileName = _T("test.jpg");
shcc.pszTitle = _T("Camera Demo");
shcc.StillQuality = CAMERACAPTURE_STILLQUALITY_HIGH;
shcc.VideoTypes = CAMERACAPTURE_VIDEOTYPE_MESSAGING;
shcc.nResolutionWidth   = 1024;
shcc.nResolutionHeight  = 768;
shcc.nVideoTimeLimit    = 15;
shcc.Mode = CAMERACAPTURE_MODE_STILL;

//display the camera capture dialog
hResult = SHCameraCapture(&shcc);

if(hResult == S_OK)
{
    //TODO:: Write to log
}

return hResult;

}

The method above is called from the window which dimensions are equal to r:

HRESULT hr = S_OK;
hr = m_PhotoCapture.CameraCapture(this->m_hWnd, L"test");

Does anyone know how to modify the above function (hwndOwner) the way to display the embedded resource in the rectangle r?

A: 

You're not too clear on what hwndOwner points to. My *guess on how this probably works is that you need to create a Window that is a child of your main display Window whose location matches your rect (and is visible), then pass it's handle in and that the capture API then uses DShow to pipe the output of the frame grabs from the camera to that Window that the handle represents.

ctacke
Yes, I have a child window CCameraView and the method is called the following way: HRESULT hr = S_OK; hr = m_PhotoCapture.CameraCapture(this->m_hWnd, L"test");
niko
+1  A: 

I think you need to put a picture box (sized to your desired dimensions) on your custom form, and then pass the windows handle of the picture box instead of the handle of the form itself.

MusiGenesis