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

📄 daohangqi.cpp

📁 《数字图象工程案例》原码
💻 CPP
字号:
// DAOHANGQI.cpp : implementation file
//

#include "stdafx.h"
#include "Designer.h"
#include "DAOHANGQI.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "DIB.h"
extern HANDLE hDIBDH;
/////////////////////////////////////////////////////////////////////////////
// DAOHANGQI dialog
DAOHANGQI::DAOHANGQI(CView *pView)
{	
}

BOOL DAOHANGQI::Create()
{	
		if(!hDIBDH) 
		{	
			AfxMessageBox("No picture loaded,Please load picture first!");
			return FALSE;
		}
	return CDialog::Create(DAOHANGQI::IDD);
}

DAOHANGQI::DAOHANGQI(CWnd* pParent /*=NULL*/)
	: CDialog(DAOHANGQI::IDD, pParent)
{
	//{{AFX_DATA_INIT(DAOHANGQI)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT

}


void DAOHANGQI::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(DAOHANGQI)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(DAOHANGQI, CDialog)
	//{{AFX_MSG_MAP(DAOHANGQI)
	ON_WM_PAINT()
	ON_WM_HSCROLL()
	ON_WM_VSCROLL()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// DAOHANGQI message handlers

void DAOHANGQI::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	if(hDIBDH)
	{
		DIB cdib;
		cdib.PaintDIBTrue(dc.GetSafeHdc(),destRect,hDIBDH,srcRect,SRCCOPY);
		
	}
	
}

BOOL DAOHANGQI::OnInitDialog() 
{
	CDialog::OnInitDialog();
	

		if(!hDIBDH) 
			
			
			return FALSE;
	
	this->GetClientRect(&winRect);
	this->ScreenToClient(&winRect);
	
		m_Client_Bottom = winRect.bottom;
		
		
	
		LPBITMAPINFOHEADER lpbi;
		lpbi = (LPBITMAPINFOHEADER)GlobalLock(hDIBDH);
		int width,height;
		width = lpbi->biWidth;
		height = lpbi->biHeight;
		GlobalUnlock(hDIBDH);
		m_Old_Scroll_Pos_H = width;
		m_Old_Scroll_Pos_V = height;

		srcRect.left = 0;
		srcRect.right = winRect.right-winRect.left;
		srcRect.top = 0;
		srcRect.bottom = winRect.bottom-winRect.top;
		destRect.left = 0;
		destRect.right = winRect.right - winRect.left;
		destRect.top = 0;
		destRect.bottom = winRect.bottom-winRect.top;
		
	
		this->SetScrollRange(SB_HORZ,0,width,TRUE);
		this->SetScrollRange(SB_VERT,0,height,TRUE);
		this->SetScrollPos(SB_VERT,height,TRUE);
		this->SetScrollPos(SB_HORZ,width,TRUE);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void DAOHANGQI::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	// TODO: Add your message handler code here and/or call default
	if(nSBCode ==SB_THUMBPOSITION  )
	{
	
	
		
			srcRect.left -= (int)nPos -m_Old_Scroll_Pos_H;
			srcRect.right -= (int)nPos -m_Old_Scroll_Pos_H;
			m_Old_Scroll_Pos_H = (int)nPos;
			this->SetScrollPos(SB_HORZ,m_Old_Scroll_Pos_H,TRUE);
			Invalidate();

		
	
	}
	CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}

void DAOHANGQI::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	// TODO: Add your message handler code here and/or call default
	if(nSBCode ==SB_THUMBPOSITION  )
	{
	
			srcRect.top -=(int)nPos - m_Old_Scroll_Pos_V;
			srcRect.bottom -=(int)nPos - m_Old_Scroll_Pos_V;
			m_Old_Scroll_Pos_V = (int)nPos;
				this->SetScrollPos(SB_VERT,m_Old_Scroll_Pos_V,TRUE);
			Invalidate();

		
	}
	CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}

⌨️ 快捷键说明

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