Exemple #1
0
/*virtual*/ void CWnd::OnKey(ui16 nKey)
{
	if ( nKey & BIOS::KEY::KeyDown )
	{
		_ASSERT( m_pFocus == this ); // ja mam focus!
		CWnd *pFocus = _GetNextActiveWindow();
		
		// cycle items, when there are no more window, jump to first possible
		if ( !pFocus )
			pFocus = _GetFirstActiveWindow();

		if (pFocus)
		{
			// find first visible window wich can be focused
			if (pFocus->m_pFirst)
				pFocus = pFocus->m_pFirst;

			pFocus->SetFocus();
			this->Invalidate();
			pFocus->Invalidate();
		}
	}

	if ( nKey & BIOS::KEY::KeyUp )
	{
		_ASSERT( m_pFocus == this ); 
		CWnd *pFocus = _GetPrevActiveWindow();

		// cycle items
		if ( !pFocus )
			pFocus = _GetLastActiveWindow();

		if (pFocus)
		{
			if (pFocus->GetLast())
				pFocus = pFocus->GetLast();	

			pFocus->SetFocus();
			this->Invalidate();
			pFocus->Invalidate();
		}
	}

	if ( nKey & BIOS::KEY::KeyEscape )
	{
		if(m_pParent && m_pParent->m_pParent) {
			CWnd *pFocus = m_pParent->m_pParent->m_pFirst;
			if (pFocus)
			{
				if (pFocus->GetLast())
					pFocus = pFocus->GetLast();	

				pFocus->SetFocus();
				this->Invalidate();
				pFocus->Invalidate();
			}
		}
	}
}
Exemple #2
0
void HistoryDlg::OnSize(xpr_uint_t nType, xpr_sint_t cx, xpr_sint_t cy)
{
    super::OnSize(nType, cx, cy);

    if (mToolBar.m_hWnd != XPR_NULL)
    {
        CRect rcToolBar;
        mToolBar.GetWindowRect(&rcToolBar);
        mToolBar.MoveWindow(0, 0, cx, rcToolBar.Height());
    }

    if (mTabCtrl.m_hWnd != XPR_NULL)
    {
        CRect sRect;
        mTabCtrl.GetWindowRect(&sRect);
        ScreenToClient(&sRect);

        sRect.right = cx - sRect.left;

        mTabCtrl.MoveWindow(&sRect, XPR_FALSE);
        mTabCtrl.Invalidate(XPR_FALSE);
    }

    CWnd *sWnd = GetDlgItem(IDC_HISTORY_STATUS);
    if (sWnd != XPR_NULL && sWnd->m_hWnd != XPR_NULL)
        sWnd->Invalidate(XPR_FALSE);
}
Exemple #3
0
BOOL CConfigFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{
	CCreateContext context1, context2;
	CRuntimeClass* pView1 = RUNTIME_CLASS(CConfListViewLeft);
	CRuntimeClass* pView2 = RUNTIME_CLASS(CConfViewRight);
	CRuntimeClass* pView3 = RUNTIME_CLASS(CConfViewRight);
	context1.m_pNewViewClass = pView1;
	context1.m_pCurrentDoc   = new CConfDoc;
	context2.m_pNewViewClass = pView2;
	context2.m_pCurrentDoc   = context1.m_pCurrentDoc;
	if (!m_Splitterwnd.CreateStatic (this, 1, 2)) {
		TRACE0 ("Failed to create Splitter\n");
		return FALSE;
	}
	if (!m_Splitterwnd.CreateView (0, 0, pView1, CSize (280, 400), &context1)) {
		TRACE0 ("Failed to create first pane\n");
		return FALSE;
	}
	if (!m_Splitterwnd.CreateView (0, 1, pView2, CSize (350, 400), &context2)) {
		TRACE0 (" Failed to create second pane\n");
		return FALSE;
	}
	
    m_Splitterwnd.SetActivePane( 0,0); 
	CWnd* pWnd = m_Splitterwnd.GetPane (0,0);
	pWnd->Invalidate();
	m_Splitterwnd.RecalcLayout();
    m_bAllViewCreated = TRUE;

    DisplayContextBranch();

	return TRUE;
}
Exemple #4
0
void CDisplayProperty::OnChangeSumcolinch() 
{
	// TODO: Add your control notification handler code here

//	UpdateData();
	CWnd *pWnd = GetDlgItem( IDC_SUMCOLINCH );
	CString strVal;
	pWnd->GetWindowText( strVal );
	int SumColInch = atoi ( (const char *)strVal );
	if ( SumColInch == 0 ) return;

	CDC *cDC = GetDC();
	int PixInch = cDC->GetDeviceCaps( LOGPIXELSX );		// Pixels Per Inch

	int SumWidth = PixInch / SumColInch;
	if ( SumWidth == 0 ) SumWidth = 1;
	PixInch = PixInch / SumWidth;

	char str[20];
	_itoa( PixInch, str, 10 );

	pWnd = GetDlgItem( IDC_SUMCOLINCHDIS );
	pWnd->SetWindowText( str );
	pWnd->Invalidate();
	ReleaseDC(cDC);
//	UpdateData(FALSE);
	
}
BOOL CPageLangDisplay::OnInitDialog()
{
	// if we're not in a wizard, we want the abrev box uneditable
	// However, I can't get it to display correctly, even with this
	// code; it always looks editable.  I've also tried doing this
	// at ddx time, no difference, and tried with WS_DISABLED.
	//
	// Also tried putting this in OnCreate, but I couldn't get a
	// handle to the CEDit at that time

	CPropertyPage::OnInitDialog();

	if(m_bAbrevIsReadOnly)
	{
			CWnd *pWnd = GetDlgItem(IDC_EDITAbrev);
			::SendMessage(pWnd->m_hWnd, EM_SETREADONLY, (WPARAM)TRUE, 0);

	//		pWnd->ModifyStyle(NULL ,  ES_READONLY);
			pWnd->Invalidate();
			pWnd->GetParent()->Invalidate();
			Invalidate();
	}
	return TRUE;  // return TRUE unless you set the focus to a control
				  // EXCEPTION: OCX Property Pages should return FALSE
}
void CSkinWin::OnSize(UINT nType, int cx, int cy)
{
    //Default();
    CWnd *pWnd = CWnd::FromHandle(m_hWnd);
    CRect wr;    
    Default();
    pWnd->GetWindowRect(wr);
    pWnd->Invalidate();
    OnNcPaint(0);
    
//     if ( m_bTrans )
//         SetWindowRgn( m_hWnd, GetRegion(wr.Width(), wr.Height() ), TRUE );
//     else
//         SetWindowRgn( m_hWnd, NULL, TRUE );

	if (m_bTrans) 
	{
		// The operating system does not make a copy of the region, 
		// so do not make any further function calls with this region handle, 
		// and do not close this region handle
		HRGN hrgn = GetRegion(wr.Width(), wr.Height());
		SetWindowRgn(m_hWnd, hrgn, TRUE);
		
		DeleteObject(hrgn);		//wyw
	}
	else
		SetWindowRgn(m_hWnd, NULL, TRUE);


}
void CColumnResizer::MoveWnd(int WndIdx, int x, int Width)
{
	static const LMARGIN = -2;
	static const RMARGIN = 4;
	ASSERT(WndIdx >= 0 && WndIdx <= m_Parent.WndIdx);
	if (WndIdx == m_Parent.WndIdx)
		x -= GetHScroll();
	else {
		x += LMARGIN;
		Width = Width - (LMARGIN + RMARGIN);
	}
	int Rows = m_WndList == NULL ? GetRowCount() : 1;
	for (int i = 0; i < Rows; i++) {
		CRect	r;
		CWnd	*wp = m_WndList == NULL ? 
			GetWndList(i)[WndIdx] : m_WndList[WndIdx];
		wp->GetWindowRect(r);
		wp->GetParent()->ScreenToClient(r);
		int	PrevWidth = r.Width();
		r.left = x;
		r.right = x + Width;
		wp->MoveWindow(r);
		// if control width changed, must invalidate, otherwise certain control
		// types paint incorrectly, e.g. static control with horiz. centered text
		if (r.Width() != PrevWidth && WndIdx != m_Parent.WndIdx)
			wp->Invalidate(FALSE);
	}
}
void CCtrlResize::OnSize()
{
	if (!m_pWnd || !m_pWnd->IsWindowVisible())
		return;

	CRect rr, rectWnd;
	m_pWnd->GetClientRect(&rectWnd);
	
	for (INT_PTR i = 0; i < m_aCtrls.GetSize(); i++) {
		CControlInfo* pInfo = m_aCtrls.GetAt(i);
		if (pInfo) {
			CWnd* pControlWnd = pInfo->m_pControlWnd ? pInfo->m_pControlWnd :
				m_pWnd->GetDlgItem (pInfo->controlID);
			if (pControlWnd) {

				rr = pInfo->rectInitial;
				if (pInfo->bindtype & BIND_RIGHT) 
					rr.right = rectWnd.right -
						(m_rectInitialParent.Width() - pInfo->rectInitial.right);
				if (pInfo->bindtype & BIND_BOTTOM) 
					rr.bottom = rectWnd.bottom -
						(m_rectInitialParent.Height() - pInfo->rectInitial.bottom);
				if (pInfo->bindtype & BIND_TOP);
				else
					rr.top = rr.bottom - pInfo->rectInitial.Height();
				if (pInfo->bindtype & BIND_LEFT);
				else
					rr.left = rr.right - pInfo->rectInitial.Width();
				
				pControlWnd->MoveWindow(&rr);
				pControlWnd->Invalidate(FALSE);
			}
		}
	}
}
Exemple #9
0
/*********************************************************
函数名称:RefreshStatic(未完成)
功能描述:刷新静态标签的内容
作者:	  余志荣
创建时间:2016-08-29
参数说明:
返 回 值:
*********************************************************/
int CChatDlg::RefreshStatic(MSG_USERINFO * msg_info)
{
	/*
	// 2016年9月1日16:31:01修改
	MSG_USERINFO msg_info;
	memset(&msg_info, 0, sizeof(MSG_USERINFO));
	strcpy_s(msg_info.nID, m_nID);
	//((CMFCChatDlg*)GetParent())->m_Friend.GetDetailInfo(&msg_info);

	CWnd* pWnd = GetDlgItem(IDC_STATIC_INFO);
	CString strTemp1, strTemp2;
	strTemp1 = "账号:";
	strTemp2 = msg_info.nID;
	strTemp1 += strTemp2;
	strTemp1 += "\r\n姓名:";
	strTemp2 = msg_info.Name;
	strTemp1 += strTemp2;
	strTemp1 += "\r\n邮箱:";
	strTemp2 = msg_info.Email;
	strTemp1 += strTemp2;
	strTemp1 += "\r\n性别:";
	strTemp2 = msg_info.Sex;
	strTemp1 += strTemp2;
	pWnd->SetWindowTextW(strTemp1);
	*/

	CWnd* pWnd = GetDlgItem(IDC_STATIC_INFO);
	CString strTemp1, strTemp2;
	strTemp1 = "账号:";
	strTemp2 = msg_info->nID;
	strTemp1 += strTemp2;
	strTemp1 += "\r\n姓名:";
	strTemp2.Format(L"%s", msg_info->Name);
	//strTemp2 = msg_info->Name;
	strTemp1 += strTemp2;
	strTemp1 += "\r\n邮箱:";
	strTemp2 = msg_info->Email;
	strTemp1 += strTemp2;
	strTemp1 += "\r\n性别:";
	if (msg_info->Sex == 'm')
	{
		strTemp2 = "男";
	} 
	else if (msg_info->Sex == 'f')
	{
		strTemp2 = "女";
	}
	else
	{
		strTemp2 = "未知";
	}
	strTemp1 += strTemp2;
	pWnd->SetWindowTextW(strTemp1);

	pWnd->Invalidate();

	return 0;
}
void CSplitterControl::Relayout()
{
    CWnd* pParent = GetParent();
    ASSERT(pParent);
    ASSERT(IsWindow(pParent->m_hWnd));

    CRect rcSelf;
    this->GetWindowRect(rcSelf);

    //  relayout all registered window
    for (int i = 0; i < 2; i++)
    {
        for (POSITION pos = this->m_listLinkedWnds[i].GetHeadPosition(); NULL != pos;)
        {
            //  get the window object
            CWnd* pWnd = this->m_listLinkedWnds[i].GetNext(pos);
            if (NULL == pWnd)
            {
                continue;
            }
    
            //  calc the new pos(the code is not very good)
            CRect rcLinked;
            pWnd->GetWindowRect(rcLinked);
            if (SPS_VERTICAL&m_dwSplitterStyle)
            {
                if (SPLS_LINKED_LEFT == i)
                {
                    rcLinked.right  = rcSelf.left;
                }
                else
                {
                    rcLinked.left   = rcSelf.right;
                }
            }
            else
            {
                if (SPLS_LINKED_LEFT == i)
                {
                    rcLinked.bottom = rcSelf.top;
                }
                else
                {
                    rcLinked.top    = rcSelf.bottom;
                }
            }

            //  move it to new pos and then update
            pParent->ScreenToClient(rcLinked);
            pWnd->MoveWindow(rcLinked, TRUE);
            pWnd->Invalidate();
        }
    }
}
Exemple #11
0
void DlgMidf::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	// TODO: 在此处添加消息处理程序代码
	// 不为绘图消息调用 CDialogEx::OnPaint()
	CWnd* pWnd = GetDlgItem(IDC_pic);
	CDC* pDC = pWnd->GetDC();
	pWnd->Invalidate();
	pWnd->UpdateWindow();
	m_adp->Draw(pDC);

}
Exemple #12
0
void CMainWnd::OnMouseClick()
{
	CWnd* pTopDialog = GetFocus();
	while ( pTopDialog->m_pParent )
	{
		if ( pTopDialog->m_dwFlags & CWnd::WsModal )
			break;
		pTopDialog = pTopDialog->m_pParent;
	}

	CWnd* pWnd = GetWindowByPoint( pTopDialog, m_Mouse.GetX(), m_Mouse.GetY() );
	if ( pWnd )
	{
		if ( pWnd == pTopDialog )
		{
		} else
		if ( pWnd == GetFocus() )
		{
			if ( !(pWnd->m_dwFlags & CWnd::WsNoActivate) )
			{
				bool bProcess = true;
				pTopDialog->SendMessage( pWnd, ToWord('M', 'D'), (NATIVEPTR)&bProcess );
				if ( bProcess )
					pWnd->WindowMessage( CWnd::WmKey, BIOS::KEY::KeyEnter );
			}
		} else if ( !(pWnd->m_dwFlags & CWnd::WsNoActivate) )
		{
			CWnd* pPrevFocus = GetFocus();
			pWnd->SetFocus();
			pPrevFocus->Invalidate();
			bool bProcess = false;
			pTopDialog->SendMessage( pWnd, ToWord('M', 'C'), (NATIVEPTR)&bProcess );
			pWnd->Invalidate();
		}
	} else
	{
		GetFocus()->WindowMessage( CWnd::WmKey, BIOS::KEY::KeyEscape );
	}
}
Exemple #13
0
void CBaseView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) 
{
	// TODO: Add your specialized code here and/or call the base class
	CEditView::OnActivateView(bActivate, pActivateView, pDeactiveView);

	if( bActivate )
	{
		OnUpdate( NULL, UPDATE_HINT_BASEVIEW, NULL );
		CWnd * pParent = GetParent();
		if( pParent && ::IsWindow(pParent->GetSafeHwnd()) )
			pParent->Invalidate( );
	}
}
void CDlgProcessSequence::DoDataExchange(CDataExchange* pDX)
{
	if(!pDX->m_bSaveAndValidate)
	{
		if(!m_pSequence->isValidSequence(m_sValidMsg))
		{
			CWnd *pWnd = GetDlgItem(IDOK);
			pWnd->ModifyStyle(NULL, WS_DISABLED);
			pWnd->Invalidate();
		}
		else
		{
			CWnd *pWnd = GetDlgItem(IDOK);
			pWnd->ModifyStyle(WS_DISABLED, NULL);
			pWnd->Invalidate();
		}
	}

	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgProcessSequence)
	DDX_Control(pDX, IDC_Remove, m_btnRemove);
	DDX_Control(pDX, IDC_Properties, m_btnProperties);
	DDX_Control(pDX, IDC_InsertBefore, m_btnInsertBefore);
	DDX_Control(pDX, IDC_InsertAfter, m_btnInsertAfter);
	DDX_Control(pDX, IDC_ProcessList, m_processListCtrl);
	DDX_Text(pDX, IDC_ValidMsg, m_sValidMsg);
	//}}AFX_DATA_MAP


	if(pDX->m_bSaveAndValidate)
	{
		if(!m_pSequence->isValidSequence(m_sValidMsg))
		{
			AfxMessageBox(m_sValidMsg);
			pDX->Fail();
		}
	}
}
Exemple #15
0
void GPReDrawStatic( CWnd* pWndIn )
{
	if (!pWndIn || !::IsWindow(pWndIn->GetSafeHwnd()))
	{
		return;
	}
	CWnd* pSubWnd = pWndIn->GetWindow(GW_CHILD);
	while(pSubWnd != NULL)
	{
		if (pSubWnd->IsKindOf(RUNTIME_CLASS(CStatic)))
		{
			pSubWnd->Invalidate(TRUE);
		}

		pSubWnd = pSubWnd->GetWindow(GW_HWNDNEXT);
	}
}
Exemple #16
0
void CTDLFilterBar::SetFilterLabelAlignment(BOOL bLeft)
{
	UINT nAlign = bLeft ? SS_LEFT : SS_RIGHT;
	
	int nLabel = NUMFILTERCTRLS;
	
	while (nLabel--)
	{
		UINT nLabelID = FILTERCTRLS[nLabel].nIDLabel;

		if (nLabelID)
		{
			CWnd* pLabel = GetDlgItem(nLabelID);
			pLabel->ModifyStyle(SS_TYPEMASK, nAlign);
			pLabel->Invalidate();
		}
	}
}
Exemple #17
0
void CTechsView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{
	CTreeCtrl &treectrl = GetTreeCtrl();
	treectrl.DeleteAllItems( );

	CString	strClassLast;
	HTREEITEM	hTechClass = NULL, hTech = NULL, hTechClassCLK = NULL, hTechClassUser = NULL;
	UINT nTechUserCount = CTechUser::GetTechUserCount();
	for( UINT i=STT_MIN; i <= STT_MAX+nTechUserCount; i ++ )
	{
		UINT	nTech	=	i;
		if( nTech > STT_MAX )
			nTech	=	i-STT_MAX-1+STT_USER_MIN;

		CString	strClass	=	AfxGetSTTClassName(nTech);
		if( strClass.GetLength() > 0 && 0 != strClass.Compare(strClassLast) )
		{
			hTechClass = treectrl.InsertItem(strClass,IMG_TECHCLASS,IMG_TECHCLASS_SEL);
			treectrl.SetItemData( hTechClass, 0 );
			if( nTech >= STT_CLK_MIN && nTech <= STT_CLK_MAX )
				hTechClassCLK	=	hTechClass;
			if( nTech >= STT_USER_MIN )
				hTechClassUser	=	hTechClass;
		}

		strClassLast	=	strClass;

		if( NULL == hTechClass )
			hTechClass	=	TVI_ROOT;
		CString	strTechName	=	AfxGetSTTFullName(nTech);
		hTech	=	treectrl.InsertItem(strTechName,IMG_TECH,IMG_TECH_SEL,hTechClass);
		treectrl.SetItemData( hTech, nTech );
	}

	treectrl.Expand( hTechClassCLK, TVE_EXPAND );
	treectrl.Expand( hTechClassUser, TVE_EXPAND );
	treectrl.Select( hTechClassCLK, TVGN_CARET );
	treectrl.Select( treectrl.GetRootItem(), TVGN_FIRSTVISIBLE );

	CWnd * pParent = GetParent();
	if( pParent && ::IsWindow(pParent->GetSafeHwnd()) )
		pParent->Invalidate();
}
Exemple #18
0
void CGroupView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{
	CTreeCtrl &treectrl = GetTreeCtrl();
	treectrl.DeleteAllItems( );
	
	CString	strGroups, strDomains;
	VERIFY( strGroups.LoadString( IDS_GROUPVIEW_GROUP ) );
	VERIFY( strDomains.LoadString( IDS_GROUPVIEW_DOMAIN ) );

	HTREEITEM	hGroups = NULL, hDomains = NULL;
	VERIFY( hGroups = treectrl.InsertItem(strGroups,IMG_GROUPS,IMG_GROUPS_SEL) );
	VERIFY( hDomains = treectrl.InsertItem(strDomains,IMG_DOMAINS,IMG_DOMAINS_SEL) );
	
	if( NULL == hGroups || NULL == hDomains )
		return;

	HTREEITEM	hItem	=	NULL;
	CDomainContainer & groups = AfxGetGroupContainer();
	for( int k=0; k<groups.GetSize(); k ++ )
	{
		CDomain	&	domain	=	groups.ElementAt(k);
		VERIFY( hItem = treectrl.InsertItem(domain.m_strName, IMG_GROUP, IMG_GROUP_SEL,hGroups) );
		treectrl.SetItemData( hItem, GV_ITEM_GROUP );
	}
	CDomainContainer & domains = AfxGetDomainContainer();
	for( k=0; k<domains.GetSize(); k ++ )
	{
		CDomain	&	domain	=	domains.ElementAt(k);
		VERIFY( hItem = treectrl.InsertItem(domain.m_strName, IMG_DOMAIN, IMG_DOMAIN_SEL,hDomains) );
		treectrl.SetItemData( hItem, GV_ITEM_DOMAIN );
	}
	
	treectrl.Expand( hGroups, TVE_EXPAND );
	treectrl.Expand( hDomains, TVE_EXPAND );
	treectrl.Select( hGroups, TVGN_CARET );

	CWnd * pParent = GetParent();
	if( pParent && ::IsWindow(pParent->GetSafeHwnd()) )
		pParent->Invalidate();
}
Exemple #19
0
void MenuBaseC::MenuOpen(bool   defaultButtonOK,
                         bool   clearButtonOK)
{
    FormContainer* pForm = m_pFormContainer;
    ASSERT(pForm);
    CWnd* currWnd = pForm->GetWindow();

    buttonForm.Create(currWnd, WS_DLGFRAME);
    mainForm.Create(currWnd);
    pForm->ResetForm();
    mainForm.ShowWindow(SW_SHOW);
    mainForm.GetParentWnd()->ShowWindow(SW_SHOW);

    propClear.SetSensitive(clearButtonOK);
    propDefault.SetSensitive(defaultButtonOK);

    if (currWnd)
        {
            currWnd->Invalidate();  // attempt to fix RRs bug with overlaying menus
            currWnd->UpdateWindow();
        }
}
Exemple #20
0
void CDlgPanel::OnBnClickedButtonStart()
{
	if (m_pManager)
	{
		int nType = m_pCmbType->GetCurSel();
		if (nType == 0)
		{
			//采集
			CWnd* pCapWnd = GetDlgVideo();
			BOOL bInCap = m_pManager->IsInCapture();
			if (!bInCap)
			{
				CComboBox* pComboxMediaSource = m_pCmbSourceType;
				CComboBox* pVideoCombo = m_pCmbCamera ;
				CComboBox* pAudioCombo = m_pCmbMic ;
				CEdit* pEdtRtspSource = m_pEdtRtspStream;

				SOURCE_TYPE eType = (SOURCE_TYPE)pComboxMediaSource->GetCurSel();
				int nCamId = 0;
				int nAudioId = 0;
				char szURL[128] = {0,};
				CString strTemp = _T("");

				//视频参数设置
				int nWidth = m_sAVCapParamInfo.nVWidth;
				int nHeight = m_sAVCapParamInfo.nVHeight;
				int nFps = m_sAVCapParamInfo.nFps;
				int nBitrate = m_sAVCapParamInfo.nBitrate;
				char  szDataType[64];
				strcpy_s(szDataType, m_sAVCapParamInfo.strColorFormat )	;
				//音频参数设置
				int nASampleRate = m_sAVCapParamInfo.nASampleRate;
				int nAChannels =m_sAVCapParamInfo.nAChannels;

				if (eType == SOURCE_LOCAL_CAMERA)
				{
					nCamId = pVideoCombo->GetCurSel();
					nAudioId = pAudioCombo->GetCurSel();
					strTemp = _T("本地音视频采集");

				}
				else if ((eType == SOURCE_SCREEN_CAPTURE))
				{
					nCamId = -1;
					nAudioId = pAudioCombo->GetCurSel();
					strTemp = _T("屏幕采集");
					strcpy_s(szDataType , "RGB24");

					int nRet =m_pManager->GetScreenCapSize(nWidth, nHeight);
					if (nRet<1)
					{
						m_pManager->LogErr(_T("屏幕采集获取长宽失败,本地预览失败!"));
						return;
					}
				}
				else
				{
					//Start
					wchar_t wszURL[128] = {0,};
					if (NULL != pEdtRtspSource)
						pEdtRtspSource->GetWindowTextW(wszURL, sizeof(wszURL));
					if (wcslen(wszURL) < 1)		return;

					CString strURL = wszURL;
					CString strRTSP = strURL.Mid(0,4);
					if (strRTSP!=_T("rtsp")&&strRTSP!=_T("RTSP"))
					{
						strURL = _T("rtsp://")+strURL;
					}

					__WCharToMByte(strURL, szURL, sizeof(szURL)/sizeof(szURL[0]));
					strTemp = _T("网络音视频流采集");
				}

				int nRet = m_pManager->StartCapture( eType,  nCamId, nAudioId, pCapWnd->GetSafeHwnd(), szURL, nWidth, nHeight, nFps,nBitrate, szDataType, nASampleRate , nAChannels );
				if (nRet>0)
				{
					strTemp +=_T("成功!"); 
					m_pManager->LogErr(strTemp);
				} 
				else
				{
					strTemp +=_T("失败!"); 
					m_pManager->LogErr(strTemp);
					return;
				}

				//推送
				//获取服务器流地址信息
				ServerURLInfo URLInfo;
				memset(&URLInfo, 0, sizeof(ServerURLInfo));
				if (m_pMainDlg)
				{
					m_pMainDlg->	GetPushServerInfo(&URLInfo);
				}

				bool bPushRtmp = false;
				//流名称格式化
				FormatStreamName(URLInfo.sdpName);
				nRet = m_pManager->StartPush(URLInfo.pushServerAddr, URLInfo.pushServerPort,URLInfo.sdpName, URLInfo.nPushBufferLenth, bPushRtmp);
				CString strMsg = _T("");
				CString strIp;
				CString strName;
				strIp = URLInfo.pushServerAddr;
				strName = URLInfo.sdpName;
				if (nRet>=0)
				{
					strMsg.Format(_T("推送EasyDarwin服务器URL:rtsp://%s:%d/%s 成功!"), strIp , URLInfo.pushServerPort, strName);
					m_pManager->LogErr(strMsg);
					m_btnStart.SetWindowText(TEXT("Stop"));
					if (bPushRtmp)
					{
						strMsg.Format(_T("连接RTMP服务器成功,推送RTMP服务器URL:rtmp://%s:1935/live/%s 成功!"), strIp , strName);
						m_pManager->LogErr(strMsg);
					}
				} 
				else
				{
					strMsg.Format(_T("推送EasyDarwin服务器URL:rtsp://%s:%d/%s 失败!"), strIp, URLInfo.pushServerPort,strName);
					m_pManager->LogErr(strMsg);
					if (bPushRtmp)
					{
						if (nRet == -1)
							strMsg.Format(_T("连接RTMP服务器失败!"), strIp , strName);
						else
							strMsg.Format(_T("推送RTMP服务器URL:rtmp://%s:1935/live/%s 失败!"), strIp , strName);
						m_pManager->LogErr(strMsg);
					}
				}
			}
			else
			{
				m_pManager->LogErr(_T("停止推送!"));
				m_pManager->StopPush();

				m_pManager->StopCapture();
				m_btnStart.SetWindowText(TEXT("Start"));
				m_pManager->LogErr(_T("本地预览停止"));

				pCapWnd->Invalidate();	
			}
		} 
		else //直播
		{
			//RTSP
			CWnd* pPlayWnd = GetDlgVideo();
			BOOL bInPlay = m_pManager->IsInPlaying();
			if (!bInPlay)
			{
				char szIp[128] = {0,};
				wchar_t wszIp[128] = {0,};

				if (NULL != m_pEdtRtspStream)	
					m_pEdtRtspStream->GetWindowTextW(wszIp, sizeof(wszIp));
				if (wcslen(wszIp) < 1)		
					return;
				__WCharToMByte(wszIp, szIp, sizeof(szIp)/sizeof(szIp[0]));

				int nRet = m_pManager->StartPlay(szIp, pPlayWnd->GetSafeHwnd());
				m_btnStart.SetWindowText(TEXT("Stop"));
				CString strMsg = _T("");
				if (nRet>0)
				{
					strMsg.Format(_T("直播预览URL:%s 成功!"), wszIp);
				} 
				else
				{
					strMsg.Format(_T("直播预览URL:%s 失败!"), wszIp);
				}
				m_pManager->LogErr(strMsg);
			}
			else
			{
				m_pManager->StopPlay();
				m_btnStart.SetWindowText(TEXT("Start"));
				pPlayWnd->Invalidate();	
				m_pManager->LogErr(_T("停止直播"));
			}
		}
	}
}
void CEasyClientDlg::OnBnClickedBtnCapture()
{
	if (m_pManager)
	{
		CWnd* pCapWnd = easyVideoPanelObj.pDlgLocalPanel->GetDlgVideoHwnd();
		BOOL bInCap = m_pManager->IsInCapture();
		CButton* pBtnStartCapture = (CButton*)GetDlgItem(IDC_BTN_CAPTURE) ;
		if (!bInCap)
		{
			CComboBox* pComboxMediaSource = (CComboBox*)GetDlgItem(IDC_COMBO_SOURCE);
			CComboBox* pVideoCombo = (CComboBox*)GetDlgItem(IDC_COMBO_CAMERA) ;
			CEdit* pEdtRtspSource = (CEdit*)GetDlgItem(IDC_EDIT_SREAM_URL);

			SOURCE_TYPE eType = (SOURCE_TYPE)pComboxMediaSource->GetCurSel();
			int nCamId = 0;
			char szURL[128] = {0,};
			CString strTemp = _T("");
			if (eType == SOURCE_LOCAL_CAMERA)
			{
				nCamId = pVideoCombo->GetCurSel();
				strTemp = _T("±¾µØÒôÊÓƵ²É¼¯");
			} 
			else
			{
				//Start
				wchar_t wszURL[128] = {0,};
				if (NULL != pEdtRtspSource)
					pEdtRtspSource->GetWindowTextW(wszURL, sizeof(wszURL));
				if (wcslen(wszURL) < 1)		return;

				CString strURL = wszURL;
				CString strRTSP = strURL.Mid(0,4);
				if (strRTSP!=_T("rtsp")&&strRTSP!=_T("RTSP"))
				{
					strURL = _T("rtsp://")+strURL;
				}
				
				__WCharToMByte(strURL, szURL, sizeof(szURL)/sizeof(szURL[0]));
				strTemp = _T("ÍøÂçÒôÊÓƵÁ÷²É¼¯");

			}
			int nRet = m_pManager->StartCapture( eType,  nCamId, pCapWnd->GetSafeHwnd(), szURL);
			if (nRet>0)
			{
				strTemp +=_T("³É¹¦£¡"); 
			} 
			else
			{
				strTemp +=_T("ʧ°Ü£¡"); 
			}
			m_pManager->LogErr(strTemp);
			if (NULL != pBtnStartCapture)		pBtnStartCapture->SetWindowText(TEXT("Stop"));

		}
		else
		{
			m_pManager->StopCapture();
			if (NULL != pBtnStartCapture)		pBtnStartCapture->SetWindowText(TEXT("±¾µØÔ¤ÀÀ"));
			m_pManager->LogErr(_T("±¾µØÔ¤ÀÀÍ£Ö¹"));

			pCapWnd->Invalidate();	
		}
	}
}
void CEasyClientDlg::OnBnClickedBtnPlay()
{
	if (m_pManager)
	{
		CWnd* pPlayWnd = easyVideoPanelObj.pDlgRemotePanel->GetDlgVideo();
		CEdit* pIP = (CEdit*)GetDlgItem(IDC_EDIT_SERVER_IP);
		CEdit* pPort = (CEdit*)GetDlgItem(IDC_EDIT_SERVER_PORT);
		CEdit* pName = (CEdit*)GetDlgItem(IDC_EDIT_PUSH_NAME);
		CWnd* pCapWnd = easyVideoPanelObj.pDlgLocalPanel->GetDlgVideoHwnd();
		BOOL bInPlay = m_pManager->IsInPlaying();
		CButton* pBtnStartPlay= (CButton*)GetDlgItem(IDC_BTN_PLAY) ;
		if (!bInPlay)
		{
			char szIp[128] = {0,};
			char szPort[128] = {0,};
			char szName[128] = {0,};
			wchar_t wszIp[128] = {0,};
			wchar_t wszPort[128] = {0,};
			wchar_t wszName[128] = {0,};
			if (NULL != pIP)	
				pIP->GetWindowTextW(wszIp, sizeof(wszIp));
			if (wcslen(wszIp) < 1)		
				return;
			__WCharToMByte(wszIp, szIp, sizeof(szIp)/sizeof(szIp[0]));

			if (NULL != pPort)	
				pPort->GetWindowTextW(wszPort, sizeof(wszPort));
			if (wcslen(wszPort) < 1)		
				return;
			__WCharToMByte(wszPort, szPort, sizeof(szPort)/sizeof(szPort[0]));
			int nPort = atoi(szPort);

			if (NULL != pName)	
				pName->GetWindowTextW(wszName, sizeof(wszName));
			if (wcslen(wszName) < 1)		
				return;
			__WCharToMByte(wszName, szName, sizeof(szName)/sizeof(szName[0]));

			char szURL[128]= {0,};
			sprintf(szURL, "rtsp://%s:%d/%s", szIp,  nPort, szName );
			int nRet = m_pManager->StartPlay(szURL, pPlayWnd->GetSafeHwnd());
			if (NULL != pBtnStartPlay)		pBtnStartPlay->SetWindowText(TEXT("Stop"));
			CString strMsg = _T("");
			if (nRet>0)
			{
				strMsg.Format(_T("Ö±²¥Ô¤ÀÀURL£ºrtsp://%s:%d/%s ³É¹¦£¡"), wszIp, nPort, wszName);
			} 
			else
			{
				strMsg.Format(_T("Ö±²¥Ô¤ÀÀURL£ºrtsp://%s:%d/%s ʧ°Ü£¡"), wszIp, nPort, wszName);

			}
			m_pManager->LogErr(strMsg);
		}
		else
		{
			m_pManager->StopPlay();
			if (NULL != pBtnStartPlay)		pBtnStartPlay->SetWindowText(TEXT("Ö±²¥Ô¤ÀÀ"));
			pPlayWnd->Invalidate();	
			m_pManager->LogErr(_T("Í£Ö¹Ö±²¥"));
		}
	}
}
Exemple #23
0
HDWP CItemCtrl::OnSize(HDWP hDWP,int sizeType, CRect *pnRect, CRect *poRect, CRect *pR0, CWnd *pDlg)
{
	CRect	ctrlRect = m_wRect, curRect;
	CWnd   *pWnd = pDlg->GetDlgItem(m_nID);
	int		deltaX = pnRect->Width() - poRect->Width();
	int		deltaY = pnRect->Height()- poRect->Height();
	int	    deltaX0 = pnRect->Width() - pR0->Width();
	int		deltaY0 = pnRect->Height()- pR0->Height();
	int		newCx, newCy;
	int		st, bUpdateRect = 1;

	// process left-horizontal option
	st = CST_NONE;
	if ((sizeType & WST_LEFT) && m_stxLeft != CST_NONE) {
		ASSERT((sizeType & WST_RIGHT) == 0);

		st = m_stxLeft;
	}
	else if ((sizeType & WST_RIGHT) && m_stxRight != CST_NONE) {
		ASSERT((sizeType & WST_LEFT) == 0);

		st = m_stxRight;
	}
	
	switch(st) {
	case CST_NONE:
		if (m_stxLeft == CST_ZOOM || m_stxRight == CST_ZOOM ||
				m_stxLeft == CST_DELTA_ZOOM || m_stxRight == CST_DELTA_ZOOM)
		{
			pWnd->GetWindowRect(&curRect);
			pDlg->ScreenToClient(&curRect);

			ctrlRect.left = curRect.left;
			ctrlRect.right = curRect.right;

			bUpdateRect = 0;
		}

		break;

	case CST_RESIZE:
		ctrlRect.right += deltaX;
		break;

	case CST_REPOS:
		ctrlRect.left += deltaX;
		ctrlRect.right += deltaX;
		break;

	case CST_RELATIVE:
		newCx = ctrlRect.Width();
		ctrlRect.left = (int)((double)m_xRatio * 1.0 * pnRect->Width() - newCx / 2.0);
		ctrlRect.right = ctrlRect.left + newCx; /* (int)((double)m_xRatio * 1.0 * pnRect->Width() + newCx / 2.0); */
		break;

	case CST_ZOOM:
		ctrlRect.left = (int)(1.0 * ctrlRect.left  * (double)pnRect->Width() / pR0->Width());
		ctrlRect.right = (int)(1.0 * ctrlRect.right * (double)pnRect->Width() / pR0->Width());
		bUpdateRect = 0;
		break;

	case CST_DELTA_ZOOM:
		newCx = ctrlRect.Width();
		ctrlRect.right = (int)(ctrlRect.left * 1.0 + deltaX0 * 1.0 * m_xRatio + newCx * 1.0 + deltaX0 * m_cxRatio);
		ctrlRect.left += (int)(deltaX0 * 1.0 * m_xRatio);
		bUpdateRect = 0;
		break;

	default:
		break;
	}

	// process vertical option
	st = CST_NONE;
	if ((sizeType & WST_TOP) && (m_styTop != CST_NONE)) {
		ASSERT((sizeType & WST_BOTTOM) == 0);

		st = m_styTop;
	}
	else if ((sizeType & WST_BOTTOM) && (m_styBottom != CST_NONE)) {
		ASSERT((sizeType & WST_TOP) == 0);

		st = m_styBottom;
	}

	switch (st) {
	case CST_NONE:
		if (m_styTop == CST_ZOOM || m_styTop == CST_ZOOM ||
				m_styBottom == CST_DELTA_ZOOM || m_styBottom == CST_DELTA_ZOOM)
		{
			pWnd->GetWindowRect(&curRect);
			pDlg->ScreenToClient(&curRect);

			ctrlRect.top = curRect.top;
			ctrlRect.bottom = curRect.bottom;

			bUpdateRect = 0;
		}

		break;

	case CST_RESIZE:
		ctrlRect.bottom += deltaY;
		break;

	case CST_REPOS:
		ctrlRect.top += deltaY;
		ctrlRect.bottom += deltaY;
		break;

	case CST_RELATIVE:
		newCy = ctrlRect.Width();
		ctrlRect.top = (int)((double)m_yRatio * 1.0 * pnRect->Width() - newCy / 2.0);
		ctrlRect.bottom = ctrlRect.top + newCy; /* (int)((double)m_yRatio * 1.0 * pnRect->Width() + newCy / 2.0); */

	case CST_ZOOM:
		ctrlRect.top = (int)(1.0 * ctrlRect.top * (double)pnRect->Height() / pR0->Height());
		ctrlRect.bottom = (int)(1.0 * ctrlRect.bottom * (double)pnRect->Height() / pR0->Height());
		bUpdateRect = 0;
		break;

	case CST_DELTA_ZOOM:
		newCy = ctrlRect.Height();
		ctrlRect.bottom = (int)(ctrlRect.top * 1.0 + deltaY0 * 1.0 * m_yRatio + newCy * 1.0 + deltaY0 * m_cyRatio);
		ctrlRect.top += (int)(deltaY0 * 1.0 * m_yRatio);
		bUpdateRect = 0;
		break;

	default:
		break;
	}

	if (!bUpdateRect) {		// in this case, m_wRect is not the real pos of DlgItem(m_nID)
		pWnd->GetWindowRect(&curRect);
		pDlg->ScreenToClient(&curRect);
	}
	else {
		curRect = m_wRect;
	}

	if (ctrlRect != curRect) {
		if (m_bInvalidate) {
			pWnd->Invalidate();
		}

		hDWP = ::DeferWindowPos(hDWP, (HWND)*pWnd, NULL, ctrlRect.left, ctrlRect.top, ctrlRect.Width(), ctrlRect.Height(), SWP_NOZORDER);

#if 1	/* why No effect!!!! */
		if (m_bInvalidate) {
			pDlg->InvalidateRect(&curRect);
			pDlg->UpdateWindow();
		}
#endif	/* No effect???? */

		if (bUpdateRect) {
			m_wRect = ctrlRect;
		}
	}

	return hDWP;
}
void COutputWnd::WriteLog(eLogTarget etarget, eLogType etype, bool bringFrontWnd, bool mb, LPCTSTR lpszLog)
{
	CWnd* target = NULL;
	switch (etarget)
	{
	case eLOG_TARGET_OUTPUT:
		target = &m_wndOutputGeneral;
		break;
	case eLOG_TARGET_DEBUG:
		target = &m_wndOutputDebug;
		break;
	case eLOG_TARGET_PARAM:
		target = &m_wndOutputFind;
		break;
	default:
		return;
	}

	// prepare log string.
	CString log = lpszLog;

	// append prefix if needed.
	switch (etype)
	{
	case eLOG_WARN:
		log = _T("[WARN] ") + log;
		break;
	case eLOG_ERROR:
		log = _T("[ERROR] ") + log;
		break;
	}

	// attach time & date
	time_t timer;
	TCHAR szTime[25];
	struct tm tm_info;
	time(&timer);
	localtime_s(&tm_info, &timer);
	_tcsftime(szTime, 25, _T("[%Y/%m/%d %H:%M:%S] "), &tm_info);
	log = szTime + log;

	// show log string.
	switch (etarget)
	{
	case eLOG_TARGET_OUTPUT:
	case eLOG_TARGET_DEBUG:
	case eLOG_TARGET_PARAM:
		((COutputList*)target)->AddString(log);
		break;
	}
	target->Invalidate();
	target->UpdateWindow();
	

	// set the selected log window as active(front) window.
	if (bringFrontWnd)
		m_wndTabs.SetActiveTab(m_wndTabs.GetTabFromHwnd(target->GetSafeHwnd()));

	// message box
	if (mb)
		AfxMessageBox(log);

	// scroll down to the bottom
	((COutputList*)target)->SetSel(((COutputList*)target)->GetCount()-1, 1);
	((COutputList*)target)->SetTopIndex(((COutputList*)target)->GetCount()-1);
	((COutputList*)target)->SetScrollPos(SB_VERT, ((COutputList*)target)->GetCount()-1);
}
Exemple #25
0
void CSplitterWndEx::RecalcLayout()
{
    ASSERT_VALID(this);
    ASSERT(m_nRows > 0 && m_nCols > 0); // must have at least one pane

    CRect rectClient;
    GetClientRect(rectClient);
    rectClient.InflateRect(-m_cxBorder, -m_cyBorder);
    rectClient.top += m_upBorder;

    CRect rectInside;
    GetInsideRect(rectInside);

    // layout columns (restrict to possible sizes)
    LayoutRowCol(m_pColInfo, m_nCols, rectInside.Width(), m_cxSplitterGap);
    LayoutRowCol(m_pRowInfo, m_nRows, rectInside.Height(), m_cySplitterGap);

    // adjust the panes (and optionally scroll bars)

    // give the hint for the maximum number of HWNDs
    AFX_SIZEPARENTPARAMS layout;
    layout.hDWP = ::BeginDeferWindowPos((m_nCols + 1) * (m_nRows + 1) + 1);

    // size of scrollbars
    int cx = (rectClient.right - rectInside.right - bNotWin4);// - afxData.bNotWin4;
    int cy = (rectClient.bottom - rectInside.bottom - bNotWin4);// - afxData.bNotWin4;

    // reposition size box
    if (m_bHasHScroll && m_bHasVScroll) {
        CWnd* pScrollBar = GetDlgItem(AFX_IDW_SIZE_BOX);
        ASSERT(pScrollBar != NULL);

        // fix style if necessary
        BOOL bSizingParent = (GetSizingParent() != NULL);
        // modifyStyle returns TRUE if style changes
        if (pScrollBar->ModifyStyle(SBS_SIZEGRIP|SBS_SIZEBOX,
                bSizingParent ? SBS_SIZEGRIP : SBS_SIZEBOX))
            pScrollBar->Invalidate();
        pScrollBar->EnableWindow(bSizingParent);

        // reposition the size box
        DeferClientPos(&layout, pScrollBar,
            rectInside.right + bNotWin4,
            rectInside.bottom + bNotWin4, cx, cy, TRUE);
    }

    // reposition scroll bars
    if (m_bHasHScroll) {
        int cxSplitterBox = m_cxSplitter + bNotWin4;// split box bigger
        int x = rectClient.left;
        int y = rectInside.bottom + bNotWin4;
        for (int col = 0; col < m_nCols; col++) {
            CWnd* pScrollBar = GetDlgItem(AFX_IDW_HSCROLL_FIRST + col);
            ASSERT(pScrollBar != NULL);
            int cx = m_pColInfo[col].nCurSize;
            if (col == 0 && m_nCols < m_nMaxCols)
                x += cxSplitterBox, cx -= cxSplitterBox;
            DeferClientPos(&layout, pScrollBar, x, y, cx, cy, TRUE);
            x += cx + m_cxSplitterGap;
        }
    }

    if (m_bHasVScroll) {
        int cySplitterBox = m_cySplitter + bNotWin4;// split box bigger
        int x = rectInside.right + bNotWin4;
        int y = rectClient.top;
        for (int row = 0; row < m_nRows; row++)
        {
            CWnd* pScrollBar = GetDlgItem(AFX_IDW_VSCROLL_FIRST + row);
            ASSERT(pScrollBar != NULL);
            int cy = m_pRowInfo[row].nCurSize;
            if (row == 0 && m_nRows < m_nMaxRows)
                y += cySplitterBox, cy -= cySplitterBox;
            DeferClientPos(&layout, pScrollBar, x, y, cx, cy, TRUE);
            y += cy + m_cySplitterGap;
        }
    }

    //BLOCK: Reposition all the panes
    {
        int x = rectClient.left;
        for (int col = 0; col < m_nCols; col++) {
            int cx = m_pColInfo[col].nCurSize;
            int y = rectClient.top;
            for (int row = 0; row < m_nRows; row++) {
                int cy = m_pRowInfo[row].nCurSize;
                CWnd* pWnd = GetPane(row, col);
                DeferClientPos(&layout, pWnd, x, y, cx, cy, FALSE);
                y += cy + m_cySplitterGap;
            }
            x += cx + m_cxSplitterGap;
        }
    }

    // move and resize all the windows at once!
    if (layout.hDWP == NULL || !::EndDeferWindowPos(layout.hDWP))
        TRACE0("Warning: DeferWindowPos failed - low system resources.\n");

    // invalidate all the splitter bars (with NULL pDC)
    DrawAllSplitBars(NULL, rectInside.right, rectInside.bottom);
}
void CQuickParseView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CQuickParseView)
	DDX_Check(pDX, IDC_CHECKTrace, m_bTrace);
	DDX_Text(pDX, IDC_EDITInput, m_sInput);
	DDX_Text(pDX, IDC_EDITAmpleOutput, m_sOutput);
	DDX_Text(pDX, IDC_EDITTraceMorphs, m_sTraceMorphs);
	DDX_Check(pDX, IDC_CHECKManualParse, m_bManualParse);
	//}}AFX_DATA_MAP

	if(!pDX->m_bSaveAndValidate)
	{
		CEdit* pE = (	CEdit*)GetDlgItem(IDC_EDITTraceMorphs);
		if(pE)
			pE->EnableWindow(m_bTrace);
#ifndef hab218
		CButton* pB = (CButton*)GetDlgItem(IDC_CHECKManualParse);
		if (pB)
			pB->EnableWindow(m_bTrace);
		CStatic* pS = (CStatic*)GetDlgItem(IDC_STATICManualParse);
		if (pS)
			pS->EnableWindow(m_bTrace);
#endif // hab218
	}
		// i removed the button because opening a window with this text
	// will take some more work

	if(!pDX->m_bSaveAndValidate && m_pAmpleProcess)
	{
		//CWnd* pButton = GetDlgItem(IDC_Errors);
		CWnd* pMessage = GetDlgItem(IDC_ErrorStatic);
		CWnd* pMessageNoTrace = GetDlgItem(IDC_ErrorStatic2);
		CWnd* pIcon = GetDlgItem(IDC_ErrorIcon);
		CWnd* pMessageRefreshed = GetDlgItem(IDC_RefreshNotice);


		// jdh 3/14/2000
		if(m_bDidRefresh)
			pMessageRefreshed->ModifyStyle(NULL, WS_VISIBLE);
		else
			pMessageRefreshed->ModifyStyle(WS_VISIBLE,NULL);
		pMessageRefreshed->Invalidate();


		if(/*pButton &&*/ pIcon && m_pAmpleProcess->getLastRunHadError())
		{
			//pButton->ModifyStyle(NULL, WS_VISIBLE);
			pMessage->ModifyStyle(NULL, WS_VISIBLE);
			pMessage->Invalidate();
			if(!m_bTrace)
			{
				pMessageNoTrace->ModifyStyle(NULL, WS_VISIBLE);
				pMessageNoTrace->Invalidate();
			}
			else // trace is on
			{
				pMessageNoTrace->ModifyStyle(WS_VISIBLE, NULL);
				pMessageNoTrace->Invalidate();
			}

			pIcon->ModifyStyle(NULL, WS_VISIBLE);
			pIcon->Invalidate();
		}
		else if(/*pButton &&*/ pIcon)
		{
			//pButton->ModifyStyle(WS_VISIBLE, NULL);
			pMessage->ModifyStyle(WS_VISIBLE, NULL);
			pMessage->Invalidate();
			pMessageNoTrace->ModifyStyle(WS_VISIBLE, NULL);
			pMessageNoTrace->Invalidate();
			pIcon->ModifyStyle(WS_VISIBLE, NULL);
			pIcon->Invalidate();
		}
		this->Invalidate();
	}
}
void CDlgIntensity::OnPaint() 
{
	// 字符串
	CString str;
	
	// 循环变量
	LONG i;
	
	// 最大计数
	LONG lMaxCount = 0;
	
	// 设备上下文
	CPaintDC dc(this);
	
	// 获取绘制坐标的文本框
	CWnd* pWnd = GetDlgItem(IDC_COORD);
	
	// 指针
	CDC* pDC = pWnd->GetDC();
	pWnd->Invalidate();
	pWnd->UpdateWindow();
	
	pDC->Rectangle(0,0,330,300);
	
	// 创建画笔对象
	CPen* pPenRed = new CPen;
	
	// 红色画笔
	pPenRed->CreatePen(PS_SOLID,1,RGB(255,0,0));
	
	// 创建画笔对象
	CPen* pPenBlue = new CPen;
	
	// 蓝色画笔
	pPenBlue->CreatePen(PS_SOLID,1,RGB(0,0, 255));
	
	// 创建画笔对象
	CPen* pPenGreen = new CPen;
	
	// 绿色画笔
	pPenGreen->CreatePen(PS_DOT,1,RGB(0,255,0));
	
	// 选中当前红色画笔,并保存以前的画笔
	CGdiObject* pOldPen = pDC->SelectObject(pPenRed);
	
	// 绘制坐标轴
	pDC->MoveTo(10,10);
	
	// 垂直轴
	pDC->LineTo(10,280);
	
	// 水平轴
	pDC->LineTo(320,280);
	
	// 写X轴刻度值
	str.Format("0");
	pDC->TextOut(10, 283, str);
	str.Format("50");
	pDC->TextOut(60, 283, str);
	str.Format("100");
	pDC->TextOut(110, 283, str);
	str.Format("150");
	pDC->TextOut(160, 283, str);
	str.Format("200");
	pDC->TextOut(210, 283, str);
	str.Format("255");
	pDC->TextOut(265, 283, str);
	
	// 绘制X轴刻度
	for (i = 0; i < 256; i += 5)
	{
		if ((i & 1) == 0)
		{
			// 10的倍数
			pDC->MoveTo(i + 10, 280);
			pDC->LineTo(i + 10, 284);
		}
		else
		{
			// 10的倍数
			pDC->MoveTo(i + 10, 280);
			pDC->LineTo(i + 10, 282);
		}
	}
	
	// 绘制X轴箭头
	pDC->MoveTo(315,275);
	pDC->LineTo(320,280);
	pDC->LineTo(315,285);
	
	// 绘制X轴箭头
	pDC->MoveTo(10,10);
	pDC->LineTo(5,15);
	pDC->MoveTo(10,10);
	pDC->LineTo(15,15);
	
	// 计算最大计数值
	for (i = m_iLowGray; i <= m_iUpGray; i ++)
	{
		// 判断是否大于当前最大值
		if (m_lCount[i] > lMaxCount)
		{
			// 更新最大值
			lMaxCount = m_lCount[i];
		}
	}
	
	// 输出最大计数值
	pDC->MoveTo(10, 25);
	pDC->LineTo(14, 25);
	str.Format("%d", lMaxCount);
	pDC->TextOut(11, 26, str);
	
	// 更改成绿色画笔
	pDC->SelectObject(pPenGreen);	
	
	// 绘制窗口上下限
	pDC->MoveTo(m_iLowGray + 10, 25);
	pDC->LineTo(m_iLowGray + 10, 280);
	
	pDC->MoveTo(m_iUpGray + 10, 25);
	pDC->LineTo(m_iUpGray + 10, 280);
	
	// 更改成蓝色画笔
	pDC->SelectObject(pPenBlue);	
	
	// 判断是否有计数
	if (lMaxCount > 0)
	{
		// 绘制直方图
		for (i = m_iLowGray; i <= m_iUpGray; i ++)
		{
			pDC->MoveTo(i + 10, 280);
			pDC->LineTo(i + 10, 281 - (int) (m_lCount[i] * 256 / lMaxCount));
		}
	}
	
	// 恢复以前的画笔
	pDC->SelectObject(pOldPen);	
	
	// 删除新的画笔
	delete pPenRed;
	delete pPenBlue;
	delete pPenGreen;
	
}
/*--------------------------------------*/
void CFrontier_API_SVDlg::OnPaitMap(void)
{
		if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
	int m_CXpos=0,m_CYpos=0,m_CorYLenth = 160,m_CorXLenth = 160;
	int GraphLimit;
	struct 
	{
		int RobRadia;// 机器人的半径
	}VisRobot = {25};// 机器人的图形显示参数
	CRect rect2,rect3;

	CWnd* pWnd = GetDlgItem(IDC_LOCDRAW);//
	CDC* pControlDC = pWnd->GetDC();
	pWnd->Invalidate();
	pWnd->UpdateWindow();

	pWnd->GetWindowRect(rect2);
	m_CXpos = (rect2.right-rect2.left)/2;
	m_CYpos = (rect2.bottom-rect2.top)/2;
	GraphLimit = 150;
	pControlDC->MoveTo(m_CXpos,m_CYpos-m_CorYLenth);// 机器人朝向,纵轴
	pControlDC->LineTo(m_CXpos,m_CYpos+m_CorYLenth);
	pControlDC->SelectStockObject(LTGRAY_BRUSH);//LTGRAY_BRUSH
	pControlDC->Ellipse(m_CXpos-5, m_CYpos-m_CorYLenth-5,m_CXpos+5, m_CYpos-m_CorYLenth+5 );

	pControlDC->MoveTo(m_CXpos-m_CorXLenth,m_CYpos);// 机器人横轴
	pControlDC->LineTo(m_CXpos+m_CorXLenth,m_CYpos);
	pControlDC->SelectStockObject(LTGRAY_BRUSH);//LTGRAY_BRUSH
	pControlDC->Ellipse(m_CXpos-m_CorXLenth-5, m_CYpos-5,m_CXpos-m_CorXLenth+5, m_CYpos+5 );

	pControlDC->SelectStockObject(HOLLOW_BRUSH);//LTGRAY_BRUSH
	pControlDC->Ellipse(m_CXpos-140-VisRobot.RobRadia, m_CYpos-140-VisRobot.RobRadia,m_CXpos+140+VisRobot.RobRadia, m_CYpos+140+VisRobot.RobRadia);	// 远处
	pControlDC->Ellipse(m_CXpos-20-VisRobot.RobRadia, m_CYpos-20-VisRobot.RobRadia,m_CXpos+20+VisRobot.RobRadia,m_CYpos+20+VisRobot.RobRadia);	//近处

	float temp_dist,temp_ang;
	int temp_far,temp_near;
	temp_far = 2500;
	temp_near = 300;
	int m_tempXPos;
	int m_tempYPos;
	BOOL temp_Blob[6];
	
	temp_Blob[0] = m_Blob1;
	temp_Blob[1] = m_Blob2;
	temp_Blob[2] = m_Blob3;
	temp_Blob[3] = m_Blob4;
	temp_Blob[4] = m_Blob5;
	temp_Blob[5] = m_Blob6;

	UpdateData(TRUE);

	/*------目标物显示------*/
	for (int k=0;k<6;k++)
	{
		if (temp_Blob[k] && VisionBlob[k][0].area>0)
		{	
			DISTANG temp_DistAng;
			memcpy(&temp_DistAng,&VisionDistAng[k][0],sizeof(temp_DistAng));
			CPen pen,*ppen;
			
			COLORREF ObjColor;
			ObjColor = ColorHLSToRGB((WORD)VisionBlob[k][0].hue,150,240);
			pen.CreatePen(PS_SOLID,1,ObjColor);
			CBrush ObjBrush;
			ObjBrush.CreateSolidBrush(ObjColor);
			pControlDC->SelectObject(&ObjBrush);
			ppen = pControlDC->SelectObject(&pen);
			
			if (temp_DistAng.Dist >= temp_far)
			{
				temp_dist = (float)temp_far;
			}
			else if (temp_DistAng.Dist <= temp_near)
			{
				temp_dist = (float)temp_near;
			}
			else
			{
				temp_dist = (float)temp_DistAng.Dist;
			}
			temp_dist = (temp_dist-temp_near)*120/(temp_far-temp_near+300)+(20+VisRobot.RobRadia);
			temp_ang = temp_DistAng.Angle;
			m_tempXPos = (int)(m_CXpos - temp_dist*sin(temp_ang*PI/180));
			m_tempYPos = (int)(m_CYpos - temp_dist*cos(temp_ang*PI/180));
			if (m_bVision)
				pControlDC->Ellipse(m_tempXPos-10,m_tempYPos-10,m_tempXPos+10,m_tempYPos+10);	
			pen.DeleteObject();
			ppen->DeleteObject();
		}
	}


	pWnd->ReleaseDC(pControlDC);
}
Exemple #29
0
void CLDlg::OnPaint() 
{
///////////////////////////////////////////////////////////////////////////////////////
	////OnPaint redefined 
//	CBitmap bm;
//	bm.LoadBitmap(IDB_BITMAP2);
	//DisplayBitmap(pControlDC,&bm,0,0,100,100);
	CWnd* pWnd = GetDlgItem(IDC_STATIC1);     // IDC_STATIC1 specified
                                              //  in the dialog editor
    CDC* pControlDC = pWnd->GetDC();
	
    pWnd->Invalidate();
    pWnd->UpdateWindow();

    pControlDC->SelectStockObject(0);
	pBrush=new CBrush();
	pBrush->CreateSolidBrush(RGB(50,25,50));
	CRect rect;
	rect.left=0;
	rect.top=0;
	rect.bottom=650;
	rect.right=650;
    pControlDC->Rectangle(rect);      // black square bullet
//	pControlDC->Ellipse(CRect(0,0,100,100));
	pControlDC->FillRect(rect,pBrush);

	switch(lflag)
	{
	case 0:	{
			int intrval=650/cnt;
			for(int cntr=1;cntr<cnt;cntr++)
			{
				pControlDC->MoveTo(0,intrval*cntr);
				pControlDC->LineTo(650,intrval*cntr);

			}
			}
			break;
	case 1:
		{
		if(flDV)
		{
		int interval=650/flrows[crflid];
		for(int i=1;i<flrows[crflid];i++)
		{
				pControlDC->MoveTo(0,interval*i);
				pControlDC->LineTo(650,interval*i);
			
		}
		interval=650/flclmns[crflid];
		for(i=1;i<flclmns[crflid];i++)
		{
			pControlDC->MoveTo(interval*i,0);
			pControlDC->LineTo(interval*i,650);
		}
		}
		///////// formation of labs ///////////
		CBrush *pBrush=new CBrush();
		pBrush->CreateSolidBrush(RGB(0,0,155));
		for(int tempcntr=0;tempcntr<labcount;tempcntr++)
		{
			if(labfl[tempcntr]==crflid)
			{
				//int x1=pt1[tempcntr].y*(650/flclmns[crflid]),y1=pt1[tempcntr].x*(650/flrows[crflid]) ;
				//int x2=pt2[tempcntr].y*(650/flclmns[crflid]),y2=pt2[tempcntr].x*(650/flrows[crflid]) ;
				long xx1=pt1[tempcntr].x,yy1=pt1[tempcntr].y;
				long xx2=pt2[tempcntr].x,yy2=pt2[tempcntr].y;
									

				if(xx1>xx2)
				{
					int temp=xx1;
					xx1=xx2;
					xx2=temp;
				}
				if(yy1>yy2)
				{
					int temp=yy1;
					yy1=yy2;
					yy2=temp;
				}
				char str1[30],str2[10];
				itoa(xx1,str1,10);
				itoa(yy1,str2,10);
				strcat(str1,"#");
				strcat(str1,str2);
				itoa(xx2,str2,10);
				strcat(str1,"#");
				strcat(str1,str2);
				itoa(yy2,str2,10);
				strcat(str1,"#");
				strcat(str1,str2);
				//AfxMessageBox(str1);
				pControlDC->SelectStockObject(1);
				//rect.left=5000;
				//rect.top=5000;
				//rect.right=0;
				//rect.bottom=0;
				//int xyflag=1;
				//int xleft,ytop,xright,ybottom;
				//for(int i=xx1;i<=xx2;i++)
				//	for(int j=yy1;j<=yy2;j++)
					//{
						
						rect.left=yy1*(650/flclmns[crflid]);
						rect.top=xx1*(650/flrows[crflid]);
						rect.bottom=(xx2+1)*(650/flrows[crflid]);
						rect.right=(yy2+1)*(650/flclmns[crflid]);
					
					//}
					pControlDC->FillRect(rect,pBrush);
					pControlDC->Draw3dRect(rect,COLORREF(RGB(255,0,0)),COLORREF(RGB(255,0,0)));

			
				

			}
		}
		///////// formation of labs ///////////
		
		}
		break;
	case 2:
		{
			
			int interval=650/crrows;
			for(int i=1;i<crrows;i++)
			{
					pControlDC->MoveTo(0,interval*i);
					pControlDC->LineTo(650,interval*i);
				
			}
			interval=650/crclmns;
			for(i=1;i<crclmns;i++)
			{
				pControlDC->MoveTo(interval*i,0);
				pControlDC->LineTo(interval*i,650);
			}

			//////////////////// placing computers ///////////////
			for(int tempcntr=0;tempcntr<cmcount;tempcntr++)
				{
					if(cmlabid[tempcntr]==crlabid)
					{
						long xx1=cmpt[tempcntr].x,yy1=cmpt[tempcntr].y;
						/////////////// place computer img /////////////////////
						/// ...........................
						rect.left=yy1*(650/crclmns);
						rect.top=xx1*(650/crrows);
						rect.bottom=(xx1+1)*(650/crrows);
						rect.right=(yy1+1)*(650/crclmns);
				
					//}
					pControlDC->FillRect(rect,pBrush);
					pControlDC->Draw3dRect(rect,COLORREF(RGB(255,0,0)),COLORREF(RGB(255,0,0)));

						/////////////// place computer img /////////////////////

					}
			}
			//////////////////// placing computers ///////////////

		}break;
	}
  


	pWnd->ReleaseDC(pControlDC);
////////////////////////////////////////////////////////////////////////////////////////
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting
	
		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}
Exemple #30
0
void CDlgPointWin::OnPaint()
{
    // 字符串
    CString str;
    // 设备上下文
    CPaintDC dc ( this );
    // 获取绘制坐标的文本框
    CWnd* pWnd = GetDlgItem ( IDC_COORD );
    // 指针
    CDC* pDC = pWnd->GetDC();
    pWnd->Invalidate();
    pWnd->UpdateWindow();
    pDC->Rectangle ( 0, 0, 330, 300 );
    // 创建画笔对象
    CPen* pPenRed = new CPen;
    // 红色画笔
    pPenRed->CreatePen ( PS_SOLID, 2, RGB ( 255, 0,
                                            0 ) );
    // 创建画笔对象
    CPen* pPenBlue = new CPen;
    // 蓝色画笔
    pPenBlue->CreatePen ( PS_SOLID, 2, RGB ( 0, 0,
                          255 ) );
    // 创建画笔对象
    CPen* pPenGreen = new CPen;
    // 绿色画笔
    pPenGreen->CreatePen ( PS_DOT, 1, RGB ( 0, 255,
                                            0 ) );
    // 选中当前红色画笔,并保存以前的画笔
    CGdiObject* pOldPen = pDC->SelectObject (
                              pPenRed );
    // 绘制坐标轴
    pDC->MoveTo ( 10, 10 );
    // 垂直轴
    pDC->LineTo ( 10, 280 );
    // 水平轴
    pDC->LineTo ( 320, 280 );
    // 写坐标
    str.Format ( L"0" );
    pDC->TextOut ( 10, 281, str );
    str.Format ( L"255" );
    pDC->TextOut ( 265, 281, str );
    pDC->TextOut ( 11, 25, str );
    // 绘制X轴箭头
    pDC->LineTo ( 315, 275 );
    pDC->MoveTo ( 320, 280 );
    pDC->LineTo ( 315, 285 );
    // 绘制X轴箭头
    pDC->MoveTo ( 10, 10 );
    pDC->LineTo ( 5, 15 );
    pDC->MoveTo ( 10, 10 );
    pDC->LineTo ( 15, 15 );
    // 更改成绿色画笔
    pDC->SelectObject ( pPenGreen );
    // 绘制窗口上下限
    pDC->MoveTo ( m_bLow + 10, 25 );
    pDC->LineTo ( m_bLow + 10, 280 );
    pDC->MoveTo ( m_bUp + 10, 25 );
    pDC->LineTo ( m_bUp + 10, 280 );
    // 更改成蓝色画笔
    pDC->SelectObject ( pPenBlue );
    // 绘制坐标值
    str.Format ( L"(%d, %d)", m_bLow, m_bLow );
    pDC->TextOut ( m_bLow + 10, 281 - m_bLow, str );
    str.Format ( L"(%d, %d)", m_bUp, m_bUp );
    pDC->TextOut ( m_bUp + 10, 281 - m_bUp, str );
    // 绘制用户指定的窗口(注意转换坐标系)
    pDC->MoveTo ( 10, 280 );
    pDC->LineTo ( m_bLow + 10, 280 );
    pDC->LineTo ( m_bLow + 10, 280 - m_bLow );
    pDC->LineTo ( m_bUp + 10, 280 - m_bUp );
    pDC->LineTo ( m_bUp + 10, 25 );
    pDC->LineTo ( 265, 25 );
    // 恢复以前的画笔
    pDC->SelectObject ( pOldPen );
    // 绘制边缘
    pDC->MoveTo ( 10, 25 );
    pDC->LineTo ( 265, 25 );
    pDC->LineTo ( 265, 280 );
    // 删除新的画笔
    delete pPenRed;
    delete pPenBlue;
    delete pPenGreen;
}