Click here to Skip to main content
15,883,883 members
Articles / Desktop Programming / MFC

Effecto Player

Rate me:
Please Sign up or sign in to vote.
4.78/5 (39 votes)
23 Sep 20035 min read 163.6K   14.8K   97  
Media audio player with 3D and 2D effects and skinning.
// 3D.cpp : implementation file
//

#include "stdafx.h"
#include "Effecto.h"
#include "3D.h"
#include "D3d8types.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include "EffectoDlg.h" 
/////////////////////////////////////////////////////////////////////////////
// C3D dialog

IMPLEMENT_DYNAMIC(C3D, CDialog)

C3D::C3D(CWnd* pParent /*=NULL*/)
	: CDialog(C3D::IDD, pParent)
{
	//{{AFX_DATA_INIT(C3D)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	bit=NULL;
}


void C3D::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(C3D)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(C3D, CDialog)
	//{{AFX_MSG_MAP(C3D)
	ON_WM_LBUTTONDOWN()
	ON_WM_MOUSEMOVE()
	ON_WM_LBUTTONUP()
	ON_WM_PAINT()
	ON_WM_CANCELMODE()
	//}}AFX_MSG_MAP
	ON_WM_DESTROY()
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// C3D message handlers
void C3D::PICS(UINT pic)
{
	
    CDC bitmapdc;
	CClientDC dc2(this);
	bitmapdc.CreateCompatibleDC (this->GetDC());
	CBitmap * Old=bitmapdc.SelectObject (bit);
	BITMAP B;
	bit->GetBitmap (&B);
	CRect rect;
	GetClientRect(rect);
    dc2.BitBlt(rect.CenterPoint().x-20,rect.CenterPoint().y-20,45 ,51 ,&bitmapdc,0,0,SRCCOPY);
	bitmapdc.SelectObject (Old);	
	
}

bool C3D::load(UINT pic)
{
	bit=new CBitmap();
	if(!bit->LoadBitmap ( pic))
	{
		AfxMessageBox ("failed");
		return false;
	}
	return true;
}

void C3D::OnLButtonDown(UINT nFlags, CPoint point) 
{
	if(myrect.PtInRect(point))
	{
		SetCapture();
		CRect rect;
		m_dragging=true;
		GetClientRect(&rect);
		ClientToScreen(&rect);
		::ClipCursor(&rect);
	}
	
	
	CDialog::OnLButtonDown(nFlags, point);
}

void C3D::OnMouseMove(UINT nFlags, CPoint point) 
{
	if(m_dragging==true)
	{
		
		/*CDC* dc=this->GetDC();
		HBRUSH *old =(HBRUSH *) dc->SelectObject(::GetStockObject(BLACK_BRUSH));
		dc->Rectangle(myrect);
		CPen myPen;
		myPen.CreatePen( PS_SOLID, 1, RGB(255,100,0) );
		dc->SelectObject(myPen);
		CBrush*ok=new CBrush(RGB(0,255,31));*/
		myrect.left=point.x;
		myrect.right=point.x+20;
		myrect.top=point.y;
		myrect.bottom =point.y+20;
		//dc->FillRect(myrect,ok);
		//dc->SelectObject(old);
		this->Invalidate(false);
	}
	
	CDialog::OnMouseMove(nFlags, point);
}

void C3D::OnLButtonUp(UINT nFlags, CPoint point) 
{
	if(m_dragging==true)
	{
		m_dragging=false;
		::ReleaseCapture();
		::ClipCursor(NULL);
		this->Invalidate(false);
		Adjustpos(point);
	}	
	
	CDialog::OnLButtonUp(nFlags, point);
}

void C3D::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
		CRect rect;
	GetClientRect(&rect);
	HBRUSH *old =(HBRUSH *) dc.SelectObject(::GetStockObject(BLACK_BRUSH));
	dc.Rectangle(0,0,rect.BottomRight().x ,rect.BottomRight().x);
	PICS(IDB_BITMAP2);
//	CPen myPen;
//	myPen.CreatePen( PS_SOLID, 1, RGB(255,100,0) );
//	dc.SelectObject(myPen);
//	CBrush ok(RGB(0,255,31));
//	dc.FillRect(&myrect,&ok);
CDC dc2;
dc2.CreateCompatibleDC (&dc);
dc2.SelectObject (&bm1);
    dc.BitBlt(myrect.CenterPoint().x-10,myrect.CenterPoint().y-(int)(23/2),20 ,23 ,&dc2,0,0,SRCCOPY);

	dc.SelectObject(old);

	// TODO: Add your message handler code here
	
	// Do not call CDialog::OnPaint() for painting messages
}

BOOL C3D::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	load(IDB_BITMAP3);
//	myrect=new CRect(0,0,20,20);
	myrect= CRect(0,0,20,20);
m_myRect=CRect(0,0,225,170);
bm1.LoadBitmap (IDB_BITMAP2);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void C3D::OnCancelMode() 
{
	CDialog::OnCancelMode();
	
	
	
}
void C3D::Adjustpos(CPoint point)
{

	CRect rect;
	GetClientRect(rect);
    // Move the sound object around the listener. The maximum radius of the
    // orbit is 27.5 units.*/
	
    D3DVECTOR vPosition;
    vPosition.x =(float) (point.x-rect.CenterPoint().x)/100;
    vPosition.y = 0.0f;
	vPosition.z = (float)(point.y-rect.CenterPoint().y)/100;	
	CString str;
	str.Format("hi x=%f y=%f",vPosition.x ,vPosition.y);
	CEffectoDlg *parent=(CEffectoDlg *)this->GetOwner();
	if(parent->m_3D==true)
   parent->SetObjectProperties( &vPosition);
	
}

void C3D::OnDestroy()
{
	CDialog::OnDestroy();
delete bit;
	// TODO: Add your message handler code here
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Egypt Egypt
My name is Ahmed Ismaiel Zakaria
i'm programming c++ & visual c++ (MFC )& Visual basic and recently COM,ATL
Student in Faculty of computer and information science in Egypt

Comments and Discussions