I have a Tab Control in my Dialog.
IN myDlg.h file
struct DialogItem
{
CWnd* wnd; int ItemID;
int iTab; BOOL bTabStop; };
afx_msg void CapturePhoto();
MyTab m_cTab;
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;
}
void myDlg::CapturePhoto()
{
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);
}
}
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; int nID;
int iTab; BOOL bTabStop; };
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);
pItem->bTabStop = FALSE;
pItem->nID=nID;
pItem->iTab = iTab;
pItem->wnd = (CWnd*)(PicpStatic2);
}
else
{
PicpStatic->ShowWindow(SW_HIDE);
}
obArray.Add((CObject*)pItem);
}
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.