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

📄 anim.h

📁 c语言经典教程
💻 H
字号:
// anim.h
// Header file for the animation module
// of the Threads demo program

#ifndef __ANIMATION_H
#define __ANIMATION_H

#define ABS(x) ((x) < 0? -(x) : (x) > 0? (x) : 0)

const int STATIC_SIZE = 0;
const int RELATIVE_SIZE = 1;
const int sizeX = 24;
const int sizeY = 24;

const int MAX_THREADS = 4;

/////////////////////////////////////////////////////////////////////////////

class MAnimation {
public:
	// Animation window client area and bouncing shape color/size parameters
	HWND m_hWnd;				// Handle for window in which ...
								// ... the shape appears.
	RECT m_clientRect;

	UINT m_nIDColor;
	COLORREF m_clrShape;

	BOOL m_bFastSpeed;         // Shape's current speed.

	POINT m_ptCenter;          // Shape's current center.
	POINT m_ptPixel;           // Pixel size.
	SIZE m_sizeRadius;         // Radius of shape.
	SIZE m_sizeMove;           // Motion speed.
	SIZE m_sizeTotal;          // Total size of shape's bitmap.
	int m_sizeMode;

	HBITMAP m_bmShape;
	HBITMAP m_bmMem;
	HBITMAP m_bmMask;

	HDC m_clientDC;
	HDC m_memDC;
	HDC m_maskDC;

	HGDIOBJ m_oldClientDC;
	HGDIOBJ m_oldBitmapDC;
	HGDIOBJ m_oldMemDC;
	HGDIOBJ m_oldMaskDC;
	HGDIOBJ m_oldBrushDC;

	HBRUSH m_hBrush;

public:
	// Default 'structors.
	MAnimation();
	MAnimation(HWND hWnd);
	~MAnimation () { ReleaseDC(m_hWnd, m_clientDC); }

	// Other member functions.
	void OnColor(UINT nIDColor, COLORREF clrShape);
	void SetSize(HWND hWnd, UINT nType, int cx, int cy);
	void AnimateShape(RECT rcClient);
	void SetClientDC(HDC hdc) { m_clientDC = hdc; }
	void SetMemDC(HDC hdc) { m_memDC = hdc; }
	void MakeNewShape();
	void SetSizeMode(int mode) { m_sizeMode = mode; }

	HDC GetClientDC() { return m_clientDC; }
	HDC GetMemDC() { return m_memDC; }
	HGDIOBJ GetOldBMDC() { return m_oldBitmapDC; }
	HBITMAP GetShape() { return m_bmShape; }
	
	void SetWindow(HWND hWnd) { m_hWnd = hWnd; }
	void SetClientRect(RECT rect) { m_clientRect = rect; }
	void SetColor(UINT color) { m_nIDColor = color; }
	void SetColorRef(COLORREF clr) { m_clrShape = clr; }
	void SetCenter(int x, int y) { m_ptCenter.x = x; m_ptCenter.y = y; }
	void SetPixel(int x, int y) { m_ptPixel.x = x; m_ptPixel.y = y; }
	void SetSizeRadius(int x, int y)
		{ m_sizeRadius.cx = x; m_sizeRadius.cy = y; }
	void SetSizeMove(int x, int y)
		{ m_sizeMove.cx = x; m_sizeMove.cy = y; }
	void SetSizeTotal(int x, int y)
		{ m_sizeTotal.cx = x; m_sizeTotal.cy = y; }

	HWND GetWindow() { return m_hWnd; }
	RECT GetClientRect() { return m_clientRect; }
	UINT GetColor() { return m_nIDColor; }
	COLORREF GetColorRef() { return m_clrShape; }
	POINT GetCenter() { return m_ptCenter; }
	POINT GetPixel() { return m_ptPixel; }
	SIZE GetSizeRadius() { return m_sizeRadius; }
	SIZE GetSizeMove() { return m_sizeMove; }
	SIZE GetSizeTotal() { return m_sizeTotal; }

	void ChangeSpeed();
};

#endif // __ANIMATION_H

⌨️ 快捷键说明

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