// 位图显示Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "位图显示.h"
#include "位图显示Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyDlg dialog
CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMyDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMyDlg)
m_Num = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMyDlg)
DDX_Control(pDX, IDC_SCROLLBAR, m_ScrollBar);
DDX_Text(pDX, IDC_PICNUM, m_Num);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
//{{AFX_MSG_MAP(CMyDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_OPEN, OnOpen)
ON_WM_TIMER()
ON_WM_HSCROLL()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyDlg message handlers
BOOL CMyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CMyDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CMyDlg::OnPaint()
{
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();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMyDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CMyDlg::OnOpen()
{
CFileDialog dlg(TRUE,"bmp",".bmp",OFN_HIDEREADONLY| OFN_OVERWRITEPROMPT,"位图文件(*.BMP)|*.BMP||");
if(dlg.DoModal()==IDOK)
{
caculate();
hwnd = GetDlgItem(IDC_PIC);
hDesDC = hwnd->GetDC()->m_hDC;
hSrcDC = CreateCompatibleDC(hDesDC);
hBitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),dlg.GetPathName(),IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
GetObject(hBitmap, sizeof BITMAP, &bm);
SelectObject(hSrcDC, hBitmap);
hwnd->GetClientRect(&rect);
::SetStretchBltMode(hDesDC,COLORONCOLOR);
::StretchBlt(hDesDC, rect.left, rect.top, rect.right, rect.bottom, hSrcDC, 0, 0, bm.bmWidth, bm.bmHeight,+SRCCOPY);
SetTimer(IDT_TIMER,50,NULL);
//确定当前位图的位置
iPos=0;
while(family[iPos]!=dlg.GetPathName())
{
iPos++;
}
m_ScrollBar.SetScrollRange(0,picnum-1);
m_ScrollBar.SetScrollPos(iPos);
m_Num.Format("第 %d 张,共 %d 张",iPos+1,picnum);
UpdateData(false);
}
else
{
//刷新
SetTimer(IDT_TIMER,30,NULL);
}
}
void CMyDlg::OnTimer(UINT nIDEvent)
{
::StretchBlt(hDesDC, rect.left, rect.top, rect.right, rect.bottom, hSrcDC, 0, 0, bm.bmWidth, bm.bmHeight,+SRCCOPY);
CDialog::OnTimer(nIDEvent);
}
//遍历文件夹
void CMyDlg::caculate()
{
picnum=0;
CFileFind finder;
Work = finder.FindFile("*.BMP");
while(Work)
{
char FileName[100];
Work=finder.FindNextFile();
sprintf(FileName,"%s",finder.GetFilePath());
family[picnum]=FileName;
picnum+=1;
}
iPos=-1;
}
void CMyDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
switch(nSBCode)
{
case SB_LINERIGHT:
{
if(iPos<picnum-1)
{
hBitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),family[iPos],IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
GetObject(hBitmap, sizeof BITMAP, &bm);
SelectObject(hSrcDC, hBitmap);
::SetStretchBltMode(hDesDC,COLORONCOLOR);
::StretchBlt(hDesDC, rect.left, rect.top, rect.right, rect.bottom, hSrcDC, 0, 0, bm.bmWidth, bm.bmHeight,+SRCCOPY);
iPos+=1;
m_ScrollBar.SetScrollPos(iPos);
m_Num.Format("第 %d 张,共 %d 张",iPos+1,picnum);
UpdateData(FALSE);
}
}
break;
case SB_LINELEFT:
{
if(iPos>0)
{
hBitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),family[iPos],IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
GetObject(hBitmap, sizeof BITMAP, &bm);
SelectObject(hSrcDC, hBitmap);
::SetStretchBltMode(hDesDC,COLORONCOLOR);
::StretchBlt(hDesDC, rect.left, rect.top, rect.right, rect.bottom, hSrcDC, 0, 0, bm.bmWidth, bm.bmHeight,+SRCCOPY);
iPos-=1;
m_ScrollBar.SetScrollPos(iPos);
m_Num.Format("第 %d 张,共 %d 张",iPos+1,picnum);
UpdateData(FALSE);
}
}
break;
case SB_THUMBTRACK:
{
iPos=nPos;
m_ScrollBar.SetScrollPos(iPos);
hBitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),family[iPos],IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
GetObject(hBitmap, sizeof BITMAP, &bm);
SelectObject(hSrcDC, hBitmap);
::SetStretchBltMode(hDesDC,COLORONCOLOR);
/*m_Num.Format("%d",m_Num);*/
::StretchBlt(hDesDC, rect.left, rect.top, rect.right, rect.bottom, hSrcDC, 0, 0, bm.bmWidth, bm.bmHeight,+SRCCOPY);
m_Num.Format("第 %d 张,共 %d 张",iPos+1,picnum);
UpdateData(FALSE);
}
break;
}
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
Continuous-Play.rar (31个子文件)
Continuous Play
位图显示Dlg.cpp 7KB
res
位图显示.rc2 400B
位图显示.ico 1KB
位图显示.rc 5KB
位图显示.opt 54KB
位图显示.cpp 2KB
位图显示.h 1KB
位图显示.aps 20KB
位图显示.ncb 97KB
位图显示Dlg.h 2KB
位图显示.dsw 541B
StdAfx.cpp 210B
resource.h 913B
位图显示.plg 250B
位图显示.clw 1KB
StdAfx.h 1KB
Debug
StdAfx.obj 103KB
位图显示.sbr 0B
位图显示.pch 6.68MB
位图显示.pdb 361KB
位图显示.obj 14KB
vc60.idb 201KB
位图显示.exe 108KB
StdAfx.sbr 1.31MB
位图显示.res 2KB
vc60.pdb 356KB
位图显示Dlg.sbr 0B
位图显示.ilk 225KB
位图显示Dlg.obj 36KB
位图显示.bsc 4.85MB
位图显示.dsp 4KB
共 31 条
- 1
资源评论
御道御小黑
- 粉丝: 61
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功