2008-12-12 93 views
1

我想將本機相機應用程序嵌入到自定義表單中。 我想嵌入相機的RECT r屬性如下:如何在屏幕上重新定位/調整資源大小?

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

,這是運行於本地相機應用程序的方法,包括:

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; 

}

的方法,上述從窗口,其尺寸等於r稱爲:

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

沒有人知道如何修改上述功能(hwndOwner)的方式在矩形r中顯示嵌入的資源?

回答

0

您對hwndOwner指出的內容不太清楚。我**猜測這可能是如何工作的,你需要創建一個窗口,它是你的主顯示窗口的一個子窗口,它的位置與你的矩形匹配(並且是可見的),然後傳遞它的句柄,然後捕獲API使用DShow將管道抓取的輸出從相機傳送到句柄表示的窗口。

+0

是的,我有一個子窗口CCameraView和方法被調用以下方式: HRESULT hr = S_OK; hr = m_PhotoCapture.CameraCapture(this-> m_hWnd,L「test」); – 2008-12-12 15:16:49

1

我認爲你需要在你的自定義窗體上放置一個圖片框(大小適合你所需的尺寸),然後傳遞圖片框的窗口句柄而不是窗體本身的句柄。