如何使用Logitech Web Cam在CStatic上捕获图像 [英] how to capture image on CStatic using Logitech Web Cam

查看:63
本文介绍了如何使用Logitech Web Cam在CStatic上捕获图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的对话框中有一个Tab控件.
在myDlg.h文件中

I have a Tab Control in my Dialog.
IN myDlg.h file

struct DialogItem
	{
	
		CWnd* wnd;		//our control
		int ItemID;
		int iTab;		//which tab it belongs to
		BOOL bTabStop;	//does this control allow tabstop
	};
afx_msg void CapturePhoto();
MyTab m_cTab;


在myDlg.cpp文件中


In myDlg.cpp file

BOOL myDlg::OnInitDialog()
{
 	CDialog::OnInitDialog();
	m_cTab.Init();
	m_cTab.InsertItem(0,"Register new user");
	m_cTab.InsertItem(1,"Identify fingerprints");
	m_cTab.InsertItem(2,"WebCam");
m_cTab.CreateImageArea("camera",4000,2,0,50,365);
m_cTab.CreateButton("WebCam",27,2,0,704,300,60);

retuen true;
	}
//On Button click
void myDlg::CapturePhoto()
{
	//hMyWindow = capCreateCaptureWindow("handle", WS_CHILD | WS_VISIBLE, 50, 150, ImageX, ImageY, this->m_hWnd,90);
	
		int id,tabID;
		tabID=m_cTab.GetCurFocus();
		INT_PTR iCount =m_cTab.obArray.GetCount();
		for(INT_PTR i=0; i<iCount; i++)
		{
		DialogItem* pItem = (DialogItem*)m_cTab.obArray[i]; 
			if(pItem->ItemID==4000&tabID==2)
			{
				id=pItem->ItemID;
				break;
			}
		}
	
		hMyWindow=::GetDlgItem(m_cTab.GetSafeHwnd(),id);
		
	bool xx = capDriverConnect( hMyWindow,0);
	if(xx == false)
	{
		AfxMessageBox("Webcam not found ",0,0);
	}
}



在MyTab.h文件中



In MyTab.h file

public:
void CreateImageArea(LPCTSTR sCaption, int nID, int iTab, UINT uLocation=0, int iX=0, int iY=0);
struct ITEM
	{
		
		CWnd* wnd;		//our control
		int nID;
		int iTab;		//which tab it belongs to
		BOOL bTabStop;	//does this control allow tabstop
	};


在MyTab.cpp文件中


In MyTab.cpp file

void MyTab::CreateImageArea(LPCTSTR sCaption, int nID, int iTab, UINT uLocation, int iX, int iY)
{
	ITEM* pItem = new ITEM;
	else if(iTab==2)
	{
	    PicpStatic2=new CStatic();		PicpStatic2->Create(sCaption,WS_CHILD|WS_VISIBLE|SS_BITMAP,CRect(50, 150,ImageX,ImageY),this,nID);
		PicpStatic2->SetFont(GetFont());
		PicpStatic2->ShowWindow(SW_HIDE);   
		//save the item struct to the object array
		pItem->bTabStop = FALSE;
		pItem->nID=nID;
		pItem->iTab = iTab;
		pItem->wnd = (CWnd*)(PicpStatic2);
		
	}
	else
	{
		PicpStatic->ShowWindow(SW_HIDE);
	}
	obArray.Add((CObject*)pItem);

}

当我不使用capCreateCaptureWindow()方法时,在单击按钮时,它会显示一条消息找不到网络摄像头".
当我使用capCreateCaptureWindow()方法并注释:: GetDlgItem(m_cTab.GetSafeHwnd(),id);它执行得很好.
我不想使用capCreateCaptureWindow()方法.我想使用在CreateImageArea()方法中动态创建的窗口.

On button click when I does not use capCreateCaptureWindow() method, it gives a message "Webcam not found".
When I use capCreateCaptureWindow() method and comment ::GetDlgItem(m_cTab.GetSafeHwnd(),id); it executes perfectly.
I do not want to use capCreateCaptureWindow() method. I want to use window which is dynamically created in CreateImageArea() method.

推荐答案

函数capDriverConnect()需要捕获窗口的句柄.这样的窗口处理发送给它的WM_CAP_xxx消息.您的窗口似乎无法处理这些消息. capDriverConnect()是将WM_CAP_DRIVER_CONNECT消息发送到窗口的宏.如果未处理此消息,则返回FALSE.
The function capDriverConnect() expects a handle to a capture window. Such a window handles the WM_CAP_xxx messages that are send to it. Your window seems not handling these messages. capDriverConnect() is a macro that sends the WM_CAP_DRIVER_CONNECT message to the window. When this message is not handled, FALSE is returned.


这篇关于如何使用Logitech Web Cam在CStatic上捕获图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆