⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dlgtab.cpp

📁 PCI7505的通信编程
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	m_ctrlN10.SetCurSel(0);
	m_ctrlN1.SetCurSel(0);
	m_ctrlN01.SetCurSel(0);
	m_nTheta=0.0f;
	m_ctrlClock.SetCheck(1);
	m_ctrlAntiClock.SetCheck(0);
	//end
}


void CDlgTAB::OnRadioClock() 
{
	// TODO: Add your control notification handler code here
	//顺时针
	m_bClock=TRUE;
}


void CDlgTAB::OnRadioAnticlock() 
{
	// TODO: Add your control notification handler code here
	//逆时针
	m_bClock=FALSE;	
}


void CDlgTAB::OnSelchangeComboN100() 
{
	// TODO: Add your control notification handler code here
	m_nN100=m_ctrlN100.GetCurSel();
	m_nTheta=float(m_nN100*100+m_nN10*10+m_nN1+m_nN01*0.1);
	UpdateData(FALSE);
	//end
}


void CDlgTAB::OnSelchangeComboN10() 
{
	// TODO: Add your control notification handler code here
	m_nN10=m_ctrlN10.GetCurSel();
	m_nTheta=float(m_nN100*100+m_nN10*10+m_nN1+m_nN01*0.1);	
	UpdateData(FALSE);
	//end
}


void CDlgTAB::OnSelchangeComboN1() 
{
	// TODO: Add your control notification handler code here
	m_nN1=m_ctrlN1.GetCurSel();	
	m_nTheta=float(m_nN100*100+m_nN10*10+m_nN1+m_nN01*0.1);
	UpdateData(FALSE);
	//end
}


void CDlgTAB::OnSelchangeComboN01() 
{
	// TODO: Add your control notification handler code here
	m_nN01=m_ctrlN01.GetCurSel();	
	m_nTheta=float(m_nN100*100+m_nN10*10+m_nN1+m_nN01*0.1);	
	UpdateData(FALSE);
	//end
}


void CDlgTAB::SetMaskMap1()
{
   /////////偶场///////////////////////
	int nLineWid = nScrnWidth/8;		//屏蔽一行
	BYTE *pMask = (BYTE *)pMask1;
	FillMemory(pMask,nSizeMask/2,0xff);
	long pos;
    int i;
	//屏蔽一方块
/*
	/////////屏蔽水平线////////////////////
	for(i=0;i<60;i++)
	{
		//从0行屏蔽起
		pos=i*nLineWid;
        pos+=0;                 //注意:pos代表字节数,一个字节8个象素        
		for(int j=0;j<22;j++)
		{
			*(pMask+pos)=0; 
			pos++;
		}
	}

	//屏蔽一横线,屏蔽第100行的80~160的像素点
	//如果奇、偶场使用的屏蔽图像一样,则屏蔽的是两行
	pos=128*nLineWid;    //128*2=256*2=512
	pos+=0;       //10个字节80个象素
	for(i=0;i<64;i++)
	{
		*(pMask+pos)=0;
		pos++;
	}

	pos=(192-1)*nLineWid/2;
//	pos+=10;
	for(i=0;i<50;i++)
	{
		*(pMask+pos)=0x0;
		pos++;
	}
	*/
	pos=(192)*nLineWid/2;
	for(i=1;i<63;i++)
	{
		*(pMask+pos)=0x0;
		pos++;
	}
	//屏蔽一列
	pos=32;			//该列离左边界32*8=256个像素
	for(i=0;i<800;i++)
	{
		//屏蔽8个像素的最左像素
		*(pMask+pos)=0xfe;		
		pos+=nLineWid/4;
	}
	//end
}


void CDlgTAB::SetMaskMap2()
{
	/////////奇场///////////////////////

	int nLineWid = nScrnWidth/8;		
	BYTE *pMask = (BYTE *)pMask2;
	FillMemory(pMask,nSizeMask/2,0xff);
	long pos=0;
	int i=0;
/*
	//屏蔽一行
	//屏蔽一方块
	for(i=0;i<60;i++)
	{
		//从0行屏蔽起
		pos=i*nLineWid;
		pos+=0;
		for(int j=0;j<22;j++)
		{
			*(pMask+pos)=0;
			pos++;
		}
	}

 
	//屏蔽一横线,屏蔽第100行的80~160的像素点
	//如果奇、偶场使用的屏蔽图像一样,则屏蔽的是两行

	pos=(191)*nLineWid/2;
	pos+=10;
	for(i=0;i<50;i++)
	{
		*(pMask+pos)=0xfe;
		pos++;
	}
*/
	//屏蔽一列
	pos=32;			//该列离左边界32*8=256个像素
	for(i=0;i<800;i++)      
	{
		*(pMask+pos)=0xfe;		//屏蔽8个像素的最左像素 
		pos+=nLineWid/4;
	}
	//end
}


void CDlgTAB::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	if(hcg300!=NULL)
	{
		CG300Capture(hcg300,FALSE);
		EndCG300(hcg300);
		hcg300=NULL;
	}
	if(hBmp!=NULL)
	{
		::GlobalUnlock((HGLOBAL)hBmp);
		::GlobalFree((HGLOBAL)hBmp);
		hBmp=NULL;
	}
	if(hMask!=NULL)
	{
		::GlobalUnlock((HGLOBAL)hMask);
		::GlobalFree((HGLOBAL)hMask);
		hMask=NULL;
	}	
	CDialog::OnClose();
	//end
}


void CDlgTAB::OnMove(int x, int y) 
{
	CDialog::OnMove(x, y);
	// TODO: Add your message handler code here

    /////试图解决平台窗口移动时,有视频残留的问题///////
	/*
	BOOL bRemove=FALSE;
	BOOL bClip=TRUE;
    CRect rect;
    GetWindowRect(&rect);
  
	int iWid = rect.Width();
	int iHeg = rect.Height();

	if( rect.left < 0 )
	{
		rect.left = 0;
		rect.right = rect.left + iWid;
		bRemove = TRUE;		
	}
	if( rect.top < 0 )
	{
		rect.top = 0;
		rect.bottom = rect.top + iHeg;
		bRemove = TRUE;
	}
	
	if( rect.right > nScrnWidth && bClip)
	{
		rect.right = nScrnWidth;
		rect.left = rect.right-iWid;
		bRemove = TRUE;
	}
	
	if( rect.bottom > nScrnHeight)
	{
		rect.bottom = nScrnHeight;
		rect.top = rect.bottom - iHeg;
		bRemove = TRUE;
	}

	int nMod =rect.left%4;
	if( nMod )
	{				// for x start at -4, 0, 4, 8, 12 ...
		rect.left -= nMod;
		rect.right -= nMod;
		bRemove = TRUE;
	}

   if(bRemove)	
	   MoveWindow(rect.left,rect.top,rect.Width(), rect.Height(), TRUE );

	CRect VideoRect;
	GetClientRect(&VideoRect);
	MapWindowPoints(NULL,&VideoRect);
	CG300SetInpVideoWindow(hcg300, 128, 32, 512, 512);
	CG300SetDispWindow(hcg300, (int)VideoRect.left, (int)VideoRect.top, VideoRect.Width(), VideoRect.Height());
*/     
	//end
}


void CDlgTAB::DrawNumber(CDC *pDC, CString sNumber, int nLeft, int nTop, COLORREF clr)
{
	if(sNumber == "A")
	{
		pDC->FillSolidRect(nLeft+5  ,nTop+15,   15  ,5, clr); // Top Line
		pDC->FillSolidRect(nLeft    ,nTop+20,  5  ,30, clr); // Left Top
		pDC->FillSolidRect(nLeft+20 ,nTop+20, 5  ,30, clr ); // Right Top
		pDC->FillSolidRect(nLeft+5  ,nTop+32,   15  ,5, clr );  // Central Line
		return;
	}

	if(sNumber == "P")
	{
		pDC->FillSolidRect(nLeft+5  ,nTop+15,   15  ,5, clr); // Top Line
		pDC->FillSolidRect(nLeft    ,nTop+20,  5  ,30, clr); // Left Top
		pDC->FillSolidRect(nLeft+20 ,nTop+20, 5  ,12, clr ); // Right Top
		pDC->FillSolidRect(nLeft+5  ,nTop+32,   15  ,5, clr );  // Central Line
		return;
	}

	if(sNumber == "M")
	{
		pDC->FillSolidRect(nLeft    ,nTop+15,  15 ,5, clr); // Top Line
		pDC->FillSolidRect(nLeft-5  ,nTop+20,  5  ,30, clr); // Left Top
		pDC->FillSolidRect(nLeft+15 ,nTop+20,  5  ,30, clr ); // Right Top
		pDC->FillSolidRect(nLeft+5  ,nTop+15,  5  ,15, clr ); // Small Line
		return;
	}

	if(sNumber == ":")
	{
		pDC->FillSolidRect(nLeft+12 , nTop + 12 , 7, 7,clr);
		pDC->FillSolidRect(nLeft+12 , nTop + 40 ,7, 7,clr);
		return;
	}

	if((sNumber != "1") && (sNumber != "4"))
	{
		pDC->FillSolidRect(nLeft,nTop,25,5, clr); // Top Line
	}

	if((sNumber != "2") && (sNumber != "1") && (sNumber != "3") && (sNumber != "7"))
	{
		pDC->FillSolidRect(nLeft-5,nTop+5,5,20, clr); // Left Top
	}

	if((sNumber != "6") && (sNumber != "5"))
	{
		pDC->FillSolidRect(nLeft+25,nTop+5,5,20, clr ); // Right Top
	}

	if((sNumber != "1") && (sNumber != "7") && (sNumber != "0"))
	{
		pDC->FillSolidRect(nLeft,nTop+25,25,5, clr );  // Central Line
	}

	if((sNumber != "1") && (sNumber != "4") && (sNumber != "7"))
	{
		pDC->FillSolidRect(nLeft,nTop+50,25,5, clr );  // Bottom Line
	}

	if((sNumber != "9") && (sNumber != "1") && (sNumber != "3") &&
		(sNumber != "4") && (sNumber != "5") && (sNumber != "7"))
	{
		pDC->FillSolidRect(nLeft-5,nTop+30,5,20, clr ); // Bottom Left
	}

	if(sNumber != "2")
	{
		pDC->FillSolidRect(nLeft+25,nTop+30,5,20, clr); // Bottom Right
	}

	//end
}


void CDlgTAB::DigitalScreen(int num)
{
	//拍摄图象数目代码//
	CWnd *nWnd=GetDlgItem(IDC_STATIC_PPNUM);
	CDC* pDC=(CDC*)nWnd->GetDC();
	CBrush backBrush(RGB(0, 0, 0));
    // Save the old brush
    CBrush* pOldBrush = pDC->SelectObject(&backBrush);
    // Get the current clipping boundary
    CRect rect;
	nWnd->GetClientRect(&rect);

    // Erase the area needed
    pDC->PatBlt(rect.left, rect.top+8, rect.Width(), rect.Height(), PATCOPY);
    pDC->SelectObject(pOldBrush); // Select the old brush back
	pOldBrush->DeleteObject();

	COLORREF clr = RGB(255,255,0);
	
	int nLeft =rect.left+5;
	int nTop = rect.top+8+10;
	
    int kk=num;
	char s[2];
	_itoa(kk,s,10);
	CString p;
	p.Format("%s",s);
	
	int nl=p.GetLength();
	
	if(nl==1)
	{
		DrawNumber(pDC ,p, nLeft+55 , nTop , clr);
	}
	else
	{
		DrawNumber(pDC ,p.Left(1), nLeft+5 , nTop , clr);
		DrawNumber(pDC ,p.Right(1), nLeft+55 , nTop , clr);
	}
	pDC->DeleteDC();
	//end
}


BOOL CDlgTAB::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if(pMsg->message == WM_KEYDOWN)
    {
        switch(pMsg->wParam)
        {
        case VK_RETURN://屏蔽回车
            return TRUE;
        case VK_ESCAPE://屏蔽Esc
            return TRUE;
        }
    }
    return CDialog::PreTranslateMessage(pMsg);
}


BOOL CDlgTAB::LoadPCI7505()
{
	if(pci7505dll!=NULL)
	{
		MessageBox("The pci7505vc.dll alread been loaded.");
		return TRUE;
	}

	pci7505dll=LoadLibrary("pci7505vc.dll");

	if(pci7505dll==NULL)
	{
		char msg[30];
		strcpy(msg,"Cannot load the pci7505.DLL DLL.");
		strcat(msg,"Make sure that the file pci7505vc.DLL");
		strcat(msg,"is in your \\WINDOWS\\SYSTEM directory.");
		MessageBox(msg);
	}     
	
	check=(pci7505check)GetProcAddress(pci7505dll,"pci7505check");
    dii=(pci7505di)GetProcAddress(pci7505dll,"pci7505di");
    doo=(pci7505do)GetProcAddress(pci7505dll,"pci7505do");
	close=(pci7505close)GetProcAddress(pci7505dll,"pci7505close");
	
	hplx=0;

    hplx=check(0, 0, FALSE,1);

	return hplx;
	//end
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -