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

📄 blobshowwnd.cpp

📁 在VC中用ODBC实现LOB数据在多种数据库中的统一读写
💻 CPP
字号:
// BLOBShowWnd.cpp : implementation file
//

#include "stdafx.h"
#include "LOBTest.h"
#include "BLOBShowWnd.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CBLOBShowWnd

IMPLEMENT_DYNCREATE(CBLOBShowWnd, CFrameWnd)

CBLOBShowWnd::CBLOBShowWnd()
{
}

CBLOBShowWnd::~CBLOBShowWnd()
{
}


BEGIN_MESSAGE_MAP(CBLOBShowWnd, CFrameWnd)
	//{{AFX_MSG_MAP(CBLOBShowWnd)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBLOBShowWnd message handlers

void CBLOBShowWnd::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	if(m_Image.GetSafeHandle() == NULL )
		return ;

	CDC *pDC =&dc;
	// TODO: Add your message handler code here
    CDC     memDC;

    memDC.CreateCompatibleDC(pDC);

    CBitmap* pImage     = (CBitmap *)memDC.SelectObject(m_Image);

    CSize    imageSize  = m_Image.GetBitmapDimension();

    pDC->BitBlt(0,0,imageSize.cx,imageSize.cy,&memDC,0,0,SRCCOPY);


	//重新制定窗口的大小,使之和图像的大小匹配
	CRect rect;
	CRect clientRect;

	this->GetWindowRect(&rect);
	this->GetClientRect(&clientRect);

	rect.right = rect.Width()-clientRect.Width()+rect.left +imageSize.cx;
	rect.bottom = rect.Height()-clientRect.Height()+rect.top +imageSize.cy;

	this->MoveWindow(&rect);

	// Do not call CFrameWnd::OnPaint() for painting messages
}

////////////////////////////////////////////////////////////////////////////////
//函数名				SetImage
//函数输入参数			CString strFileName  图像文件路径
//函数返回值			无
//函数功能				将指定的BMP文件读入内存中
//函数开发人			林晨
//函数开发时间			2002年4月8日
//函数修改历史			...
//函数测试时间			2002年4月8日

void CBLOBShowWnd::SetImage(CString strFileName)
{
    HBITMAP hbm = (HBITMAP)::LoadImage(NULL,
                                       strFileName,
                                       IMAGE_BITMAP,
                                       0,
                                       0,
                                       LR_LOADFROMFILE);

    if  (m_Image.Attach(hbm))
    {
        BITMAP  bm;
        m_Image.GetBitmap(&bm);
        m_Image.SetBitmapDimension(bm.bmWidth,bm.bmHeight);
        return ;
    }
}

//	SetImage
/////////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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