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

📄 navigationdialog.cpp

📁 影像融合与融合精度评价源码影像融合与融合精度评价源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
	{
		ReleaseCapture();
		if(DisplayRect.PtInRect(point))
		{
			CursorStatus=NAVDLG_HAND_CATCH;
			::SetCursor(m_HandCatch);
		}
		else
		{
			CursorStatus=NAVDLG_DO_NOTHING;
		}
	}
	
	CDialog::OnLButtonUp(nFlags, point);
}

BOOL CNavigationDialog::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
{
 	if (nHitTest == HTCLIENT)
	{
		switch(CursorStatus)
		{
		case NAVDLG_DO_NOTHING:
			{
				CDialog::OnSetCursor(pWnd, nHitTest, message);
				return 0;
			}
		case NAVDLG_HAND_POINT:
			{
				::SetCursor(m_HandPoint);
				return 0;
			}
		case NAVDLG_HAND_CATCH:
			{
				::SetCursor(m_HandCatch);
				return 0;
			}
		case NAVDLG_HAND_MOVE:
			{
				::SetCursor(m_HandMove);
				return 0;
			}
		default:
			{
				CDialog::OnSetCursor(pWnd, nHitTest, message);
				return 0;
			}
		}	
	}
	return CDialog::OnSetCursor(pWnd, nHitTest, message);
}

void CNavigationDialog::OnChangeScaleEdit() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	bEditChanged= TRUE;	
}

void CNavigationDialog::OnSize(UINT nType, int cx, int cy) 
{
	CDialog::OnSize(nType, cx, cy);
	bpbmpChanged=TRUE;
	bRedrawControl = TRUE;
	PostMessage(WM_REDRAWDISPLAYRECT);
}

LRESULT CNavigationDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
	//control the window not too small
	if(message==WM_SIZING)
	{
		LPRECT lpRect=(LPRECT)lParam;
		if(lpRect->right-lpRect->left < NavWndWidth )
		{
			if(wParam==WMSZ_LEFT||wParam==WMSZ_BOTTOMLEFT||wParam==WMSZ_TOPLEFT)
				lpRect->left+=(lpRect->right-lpRect->left-NavWndWidth);
			if(wParam==WMSZ_RIGHT||wParam==WMSZ_BOTTOMRIGHT||wParam==WMSZ_TOPRIGHT)
				lpRect->right-=(lpRect->right-lpRect->left-NavWndWidth);
		}
		if(lpRect->bottom-lpRect->top < NavWndHeight )
		{
			if(wParam==WMSZ_TOP||wParam==WMSZ_TOPRIGHT||wParam==WMSZ_TOPLEFT)
				lpRect->top+=(lpRect->bottom-lpRect->top-NavWndHeight);
			if(wParam==WMSZ_BOTTOM||wParam==WMSZ_BOTTOMRIGHT||wParam==WMSZ_BOTTOMLEFT)
				lpRect->bottom-=(lpRect->bottom-lpRect->top-NavWndHeight);
		}
	}
	//move to default location
	if(message==WM_MOVING)
	{
		LPRECT lpRect=(LPRECT)lParam;
		CMDIFrameWnd* pAppFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd;
		ASSERT(pAppFrame->IsKindOf(RUNTIME_CLASS( CMDIFrameWnd )));

		CRect rc;
		pAppFrame->GetClientRect(&rc);
		pAppFrame->ClientToScreen(&rc);//Screen Coordinate

		CRect NavRect;
		GetWindowRect(&NavRect);//Screen Coordinate

		CRect DefaultRect;
		DefaultRect.left=rc.right-NavRect.Width()-2;
		DefaultRect.right=DefaultRect.left+NavRect.Width();
		DefaultRect.top=rc.top+50;
		DefaultRect.bottom=DefaultRect.top+NavRect.Height();

		if(abs(DefaultRect.left-lpRect->left)<=5
			&& abs(DefaultRect.right-lpRect->right)<=5
			&& abs(DefaultRect.top-lpRect->top)<=5
			&& abs(DefaultRect.bottom-lpRect->bottom)<=5 )
		{
			lpRect->left=DefaultRect.left;
			lpRect->right=DefaultRect.right;
			lpRect->top=DefaultRect.top;
			lpRect->bottom=DefaultRect.bottom;
		}
	}

	return CDialog::WindowProc(message, wParam, lParam);
}

void CNavigationDialog::OnDefaultSize() 
{
	CRect NavRect;
	GetWindowRect(&NavRect);//Screen Coordinate
	int nFullWidth=::GetSystemMetrics(SM_CXSCREEN);
	int nFullHeight=::GetSystemMetrics(SM_CYSCREEN);
	if( NavRect.left >= nFullWidth-100 || NavRect.top >= nFullHeight-100 )
		SetWindowPos(&(this->wndTop),NavRect.left,NavRect.top,NavWndWidth,NavWndHeight,SWP_SHOWWINDOW   );//	SWP_NOACTIVATE
	else
		SetWindowPos(&(this->wndTop),NavRect.right-NavWndWidth,NavRect.top,NavWndWidth,NavWndHeight,SWP_SHOWWINDOW   );//	SWP_NOACTIVATE
	bpbmpChanged=TRUE;
	bRedrawControl = TRUE;
	PostMessage(WM_REDRAWDISPLAYRECT);
}

void CNavigationDialog::OnUpdateDefaultSize(CCmdUI* pCmdUI) 
{
	//This function make no use.why? I don't konw
	CRect NavRect;
	GetWindowRect(&NavRect);//Screen Coordinate
	BOOL bEnable=FALSE;
	if( NavRect.Width()!=NavWndWidth || NavRect.Height()!=NavWndHeight )
		bEnable=TRUE;
	pCmdUI->Enable(bEnable);
}

void CNavigationDialog::OnDefaultLocation() 
{
	CMDIFrameWnd* pAppFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd;
	ASSERT(pAppFrame->IsKindOf(RUNTIME_CLASS( CMDIFrameWnd )));

	CRect rc;
	pAppFrame->GetClientRect(&rc);
	pAppFrame->ClientToScreen(&rc);//Screen Coordinate

	CRect NavRect;
	GetWindowRect(&NavRect);//Screen Coordinate

	CRect DefaultRect;
	DefaultRect.left=rc.right-NavRect.Width()-2;
	DefaultRect.right=DefaultRect.left+NavRect.Width();
	DefaultRect.top=rc.top+50;
	DefaultRect.bottom=DefaultRect.top+NavRect.Height();

	SetWindowPos(&(this->wndTop),DefaultRect.left,DefaultRect.top,DefaultRect.Width(),DefaultRect.Height(),SWP_NOACTIVATE);	
}
void CNavigationDialog::OnUpdateDefaultLocation(CCmdUI* pCmdUI) 
{
	//This function make no use.why? I don't konw
	CMDIFrameWnd* pAppFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd;
	ASSERT(pAppFrame->IsKindOf(RUNTIME_CLASS( CMDIFrameWnd )));

	CRect rc;
	pAppFrame->GetClientRect(&rc);
	pAppFrame->ClientToScreen(&rc);//Screen Coordinate

	CRect NavRect;
	GetWindowRect(&NavRect);//Screen Coordinate

	CRect DefaultRect;
	DefaultRect.left=rc.right-NavRect.Width()-2;
	DefaultRect.right=DefaultRect.left+NavRect.Width();
	DefaultRect.top=rc.top+50;
	DefaultRect.bottom=DefaultRect.top+NavRect.Height();

	BOOL bEnable;
	if( DefaultRect.left==NavRect.left
		&& DefaultRect.right==NavRect.right
		&& DefaultRect.top==NavRect.top
		&& DefaultRect.bottom==NavRect.bottom )
		bEnable=FALSE;
	else
		bEnable=TRUE;
}

void CNavigationDialog::OnContextMenu(CWnd*, CPoint point)
{
	// CG: This block was added by the Pop-up Menu component
	{
		if (point.x == -1 && point.y == -1){
			//keystroke invocation
			CRect rect;
			GetClientRect(rect);
			ClientToScreen(rect);

			point = rect.TopLeft();
			point.Offset(5, 5);
		}

		CMenu menu;
		VERIFY(menu.LoadMenu(CG_IDR_POPUP_NAVIGATION_DIALOG));

		CMenu* pPopup = menu.GetSubMenu(0);
		ASSERT(pPopup != NULL);
		CWnd* pWndPopupOwner = this;

		while (pWndPopupOwner->GetStyle() & WS_CHILD)
			pWndPopupOwner = pWndPopupOwner->GetParent();

		pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,
			pWndPopupOwner);
	}
}

void CNavigationDialog::OnHideNavdlg() 
{
	if( (GetStyle() & WS_VISIBLE) != 0)
	{
		ShowWindow(SW_HIDE);
	}
}

BOOL CNavigationDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	bpbmpChanged = FALSE;
	bRedrawControl = FALSE;

	CRect NavPos;
	NavPos.left = AfxGetApp()->GetProfileInt("NAVIGATION","NavPosLeft",-1);
	NavPos.right = AfxGetApp()->GetProfileInt("NAVIGATION","NavPosRight",32767);
	NavPos.top = AfxGetApp()->GetProfileInt("NAVIGATION","NavPosTop",-1);
	NavPos.bottom = AfxGetApp()->GetProfileInt("NAVIGATION","NavPosBottom",32767);

	int nFullWidth=::GetSystemMetrics(SM_CXSCREEN);
	int nFullHeight=::GetSystemMetrics(SM_CYSCREEN);
	if(NavPos.left<0 || NavPos.right<0 || NavPos.top<0 || NavPos.bottom<0
		|| NavPos.left>=nFullWidth-100 || NavPos.top>=nFullHeight-100 
		|| NavPos.Width()<NavWndWidth || NavPos.Height()<NavWndHeight )
	{		
		CMDIFrameWnd* pAppFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd;
		ASSERT(pAppFrame->IsKindOf(RUNTIME_CLASS( CMDIFrameWnd )));

		CRect rc;
		pAppFrame->GetClientRect(&rc);
		pAppFrame->ClientToScreen(&rc);//Screen Coordinate

		//create NavigationDialog with cx=NavWndWidth and cy=NavWndHeight
		SetWindowPos(&(this->wndTop),rc.right-(NavWndWidth+2),rc.top+50,NavWndWidth,NavWndHeight,SWP_NOACTIVATE);
	}
	else
	{
		SetWindowPos(&(this->wndTop),NavPos.left,NavPos.top,NavPos.Width(),NavPos.Height(),SWP_NOACTIVATE);
	}	

	NavZoomOut.AutoLoad(IDC_NAV_ZOOMOUT,this);
	NavZoomIn.AutoLoad(IDC_NAV_ZOOMIN,this);
	m_ZoomEdit.SetParseType( SES_FLOATINGPT ); 
	m_NavigationCtrl.SetRange(1,100);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CNavigationDialog::OnNavZoomout() 
{
	CMDIFrameWnd* pAppFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd;
	CMDIChildWnd * pChild=(CMDIChildWnd* )pAppFrame->MDIGetActive();
	CMYFUSIONView *  pImageLayer= (CMYFUSIONView *)(pChild->GetActiveView());	
	pImageLayer->AdjustZoomOut();
}

void CNavigationDialog::OnNavZoomin() 
{
	CMDIFrameWnd* pAppFrame = (CMDIFrameWnd*) AfxGetApp()->m_pMainWnd;
	CMDIChildWnd * pChild=(CMDIChildWnd* )pAppFrame->MDIGetActive();
	CMYFUSIONView * pImageLayer = (CMYFUSIONView *)(pChild->GetActiveView());	
	pImageLayer->AdjustZoomIn();
}

void CNavigationDialog::OnDoubleclickedNavZoomin() 
{
	OnNavZoomin();
}

void CNavigationDialog::OnDoubleclickedNavZoomout() 
{
	OnNavZoomout() ;
}

void CNavigationDialog::OnDestroy() 
{
	CDialog::OnDestroy();
	
	// TODO: Add your message handler code here and/or call default
	CRect NavPos;
	GetWindowRect(&NavPos);
	//wirte Navigation Dialog position in REGISTER before quit the system;
	AfxGetApp()->WriteProfileInt("NAVIGATION","NavPosLeft",NavPos.left);
	AfxGetApp()->WriteProfileInt("NAVIGATION","NavPosRight",NavPos.right);
	AfxGetApp()->WriteProfileInt("NAVIGATION","NavPosTop",NavPos.top);
	AfxGetApp()->WriteProfileInt("NAVIGATION","NavPosBottom",NavPos.bottom);
}

void CNavigationDialog::OnClose() 
{
	ShowWindow(SW_HIDE);
	UpdateWindow();		
	CDialog::OnClose();
}

⌨️ 快捷键说明

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