nav-left cat-right
cat-right
Home > Blog > Programming > C++ > MFC > Flicker Free example with dialog

Flicker Free example with dialog

The example for the moving objects is called MovingPixels:

MovingPixels.h

#pragma once
 
#include <vector>
using namespace std; 
 
class CMovingPixels
{
public:
	CMovingPixels(void);
	CMovingPixels(int x, int y);
	~CMovingPixels(void);
private:
	int m_size_x;
	int m_size_y;
	int m_color_start;
	COLORREF m_color;
public:
	vector</vector><vector <COLORREF> > m_Array; 
	void SetColor(int value);
	COLORREF GetColor();
	void SetSize(int x, int y);
	void SetStartColor(int start);
	void IterateNewContent();
};

MovingPixels.cpp

#include "StdAfx.h"
#include "MovingPixels.h"
 
CMovingPixels::CMovingPixels(void)
{
	SetSize(1,1);
	SetStartColor(0);
}
 
CMovingPixels::CMovingPixels(int x, int y)
{
    SetSize(x,y);
	SetStartColor(0);
}
 
CMovingPixels::~CMovingPixels(void)
{
}
 
void CMovingPixels::SetColor(int value)
{
	m_color = RGB(value,value,value);
}
 
COLORREF CMovingPixels::GetColor()
{
	return m_color;
}
 
void CMovingPixels::SetStartColor(int start)
{
	m_color_start = start;
}
 
void CMovingPixels::SetSize(int x, int y)
{
	if ((x>=0) && (y>=0))
	{		
		m_size_x = x;
		m_size_y = y;
		m_Array.resize(m_size_x); 
		for(int x = 0; x < m_size_x; x++) 
			m_Array[x].resize(m_size_y); 
	}
}
 
void CMovingPixels::IterateNewContent()
{
	int color = m_color_start;
	for (int x=0; x< m_size_x; x++) 
	{
		for (int y=0; y< m_size_y; y++) 
		{
			color++;
			if (color > 256) { color=0; }
			SetColor(color);
			m_Array[x][y] = GetColor();
		}
	}
	m_color_start = color + 1;
}

Seiten: 1 2 3

2 Antworten : “Flicker Free example with dialog”

  1. Maximus sagt:

    I would like to see a continuation of the topic

  2. What exactly do you want to see?

Trackbacks/Pingbacks

  1. Matthias Pospiech :: MFC: Flicker Free example with CStatic Control - [...] It works very similar to the description of Flicker Free example with dialog. [...]

Einen Kommentar schreiben

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *

*


*

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">

Spam Protection by WP-SpamFree