carousel - yamaumima/hello.github.io GitHub Wiki
class CMemDC : public CDC
{
CSize m_size;
public:
int GetWidth(){return m_size.cx;}
int GetHeight(){return m_size.cy;}
BOOL LoadBitmap(UINT nBitmap,CDC* pDC=NULL)
{
CBitmap bmp;
if(!bmp.LoadBitmap(nBitmap))
return FALSE;
BITMAP bm;
bmp.GetBitmap(&bm);
m_size.cx = bm.bmWidth;
m_size.cy = bm.bmHeight;
CreateCompatibleDC(pDC);
SelectObject(&bmp);
return TRUE;
}
};
#include "stdafx.h"
#include "T1.h"
#include "T1Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CT1Dlg dialog
CRect CT1Dlg::m_rect[COUNT]=
{
CRect(CPoint(889,275),CSize(22,56)),
CRect(CPoint(918,275),CSize(22,56)),
CRect(CPoint(942,275),CSize(22,56)),
CRect(CPoint(970,275),CSize(22,56)),
};
CT1Dlg::CT1Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CT1Dlg::IDD, pParent)
{
m_nCurSel = 0;
//{{AFX_DATA_INIT(CT1Dlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CT1Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CT1Dlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CT1Dlg, CDialog)
//{{AFX_MSG_MAP(CT1Dlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CT1Dlg message handlers
BOOL CT1Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
int i =0;
while(i<COUNT)
{
m_dc[i].LoadBitmap(IDB_BITMAP1+i);
++i;
}
MoveWindow(0,0,m_dc[0].GetWidth(),m_dc[0].GetHeight(),FALSE);
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
}
// 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 CT1Dlg::OnPaint()
{
CPaintDC dc(this); // device context for painting
dc.BitBlt(0,0,m_dc[0].GetWidth(),m_dc[0].GetHeight(),&m_dc[m_nCurSel],0,0,SRCCOPY);
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CT1Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CT1Dlg::OnLButtonDown(UINT nFlags, CPoint point)
{
int i = 0;
while(i<COUNT)
{
if(m_rect[i].PtInRect(point))
{
m_nCurSel = i;
Invalidate(FALSE);
break;
}
++i;
}
CDialog::OnLButtonDown(nFlags, point);
}
void CT1Dlg::OnOK()
{
// TODO: Add extra validation here
//CDialog::OnOK();
}