AnimatBitmapView.cpp
上传用户:gao_853
上传日期:2020-04-10
资源大小:362k
文件大小:4k
- // AnimatBitmapView.cpp : implementation of the CAnimatBitmapView class
- //
- #include "stdafx.h"
- #include "AnimatBitmap.h"
- #include "AnimatBitmapDoc.h"
- #include "AnimatBitmapView.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CAnimatBitmapView
- IMPLEMENT_DYNCREATE(CAnimatBitmapView, CView)
- BEGIN_MESSAGE_MAP(CAnimatBitmapView, CView)
- //{{AFX_MSG_MAP(CAnimatBitmapView)
- ON_COMMAND(IDM_Anime1, OnAnime1)
- ON_COMMAND(IDM_Anime2, OnAnime2)
- ON_COMMAND(IDM_Anime3, OnAnime3)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CAnimatBitmapView construction/destruction
- CAnimatBitmapView::CAnimatBitmapView()
- {
- HBITMAP hbmp = (HBITMAP)::LoadImage (AfxGetInstanceHandle(),
- "Demo2.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
- ImgBmp.Attach (hbmp);
- AnimeCode = 25; Speed = 1;
- }
- CAnimatBitmapView::~CAnimatBitmapView()
- {
- if (ImgBmp.DeleteObject()) ImgBmp.Detach();
- }
- BOOL CAnimatBitmapView::PreCreateWindow(CREATESTRUCT& cs)
- {
- // TODO: Modify the Window class or styles here by modifying
- // the CREATESTRUCT cs
- return CView::PreCreateWindow(cs);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CAnimatBitmapView drawing
- void CAnimatBitmapView::OnDraw(CDC* pDC)
- {
- CAnimatBitmapDoc* pDoc = GetDocument();
- ASSERT_VALID(pDoc);
- CRect rect; GetClientRect(&rect);
- DIBSECTION ds; ImgBmp.GetObject (sizeof (DIBSECTION), &ds);
- int x = (rect.Width() - ds.dsBm.bmWidth) / 2,
- y = (rect.Height() - ds.dsBm.bmHeight) / 2;
-
- if (x >= 0 && y >= 0)
- {
- SetCursorPos(180,30); ShowCursor(FALSE);
- pDC->SetBkMode(TRANSPARENT);
- pDC->DrawText("Veuillez patientez !nMerci", rect, DT_TOP | DT_CENTER);
- // Fonction Animation & Transformation Image Bitmap dans "AnimeBitmap.lib"
- ImgBmp.AnimeBmp_OmBoran(pDC, x, y, AnimeCode, Speed);
- ShowCursor(TRUE);
- }
- else AfxMessageBox("Fen阾re < Image");
- }
- /////////////////////////////////////////////////////////////////////////////
- // CAnimatBitmapView diagnostics
- #ifdef _DEBUG
- void CAnimatBitmapView::AssertValid() const
- {
- CView::AssertValid();
- }
- void CAnimatBitmapView::Dump(CDumpContext& dc) const
- {
- CView::Dump(dc);
- }
- CAnimatBitmapDoc* CAnimatBitmapView::GetDocument() // non-debug version is inline
- {
- ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CAnimatBitmapDoc)));
- return (CAnimatBitmapDoc*)m_pDocument;
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CAnimatBitmapView message handlers
- void CAnimatBitmapView::OnAnime1()
- {
- if (ImgBmp.DeleteObject()) ImgBmp.Detach();
- HBITMAP hbmp = (HBITMAP)::LoadImage (AfxGetInstanceHandle(),
- "Demo2.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
- ImgBmp.Attach (hbmp);
- AnimeCode = 30; Speed = 1; Invalidate();
- }
- void CAnimatBitmapView::OnAnime2()
- {
- if (ImgBmp.DeleteObject()) ImgBmp.Detach();
- HBITMAP hbmp = (HBITMAP)::LoadImage (AfxGetInstanceHandle(),
- "Demo1.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
- ImgBmp.Attach (hbmp);
- AnimeCode = 10; Speed = 15; Invalidate();
- }
- void CAnimatBitmapView::OnAnime3()
- {
- if (ImgBmp.DeleteObject()) ImgBmp.Detach();
- HBITMAP hbmp = (HBITMAP)::LoadImage (AfxGetInstanceHandle(),
- "Demo3.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
- ImgBmp.Attach (hbmp);
- AnimeCode = 9; Speed = 5; Invalidate();
- }