GIDForums  

Go Back   GIDForums > Computer Programming Forums > MS Visual C++ / MFC Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 25-Jun-2012, 02:24
Bibhu.GDIForums Bibhu.GDIForums is offline
New Member
 
Join Date: Jun 2012
Posts: 1
Bibhu.GDIForums is on a distinguished road

How to show CStatic control using Gdiplus::Graphics class


Hello members,

I am using MFC for my project in visual studio 2008.
I have a scroll view.
I am showing bmp/jpg files on it by using Graphics class provided by Gdiplus namespace.
The code for that is as below.
//----------------------------------------------------------------
CPP / C++ / C Code:
void CLayer::MyDrawTransparent(CDC* pDC, int XDest, int YDest, int nDestWidth, int nDestHeight)
{
        Graphics graphics(pDC->GetSafeHdc());

        // Create a Rect object that specifies the destination of the image.
        Rect destRect(XDest, YDest, nDestWidth, nDestHeight);
	graphics.DrawImage(m_pGDIPlusBitmap->m_pBitmap, destRect);
}
CLayer is my user defined class.
I am receiving CDC in this function.
m_pGDIPlusBitmap->m_pBitmap populated by bmp or jpg file during runtime.
//-----------------------------------------------------------------

Now I want to show an animated gif file. After a lot of search, I found a class called CPictureEx derived from CStatic class. This CPictureEx class is responsible for loading given gif file and play it. Code for this is as below.
//------------------------------------------------------------------
//declare object of this class in header file.
CPP / C++ / C Code:
CPictureEx m_Picture;

//In cpp file
CPP / C++ / C Code:
void CMyScrollView::OnDraw(CDC* pDC)
{
        m_Picture.Create(_T("Present"), WS_CHILD | WS_VISIBLE | SS_BLACKFRAME,CRect(200, 100, 0, 0),cwnd);
	if (m_Picture3.Load(_T("D:\\eyes.gif")))
		m_Picture3.Draw();
}
I am using a Boolean variable to make the control created once.
Here it is working fine, and I am able to see gif file on scroll view with animation.
//------------------------------------------------------------------

Now I am facing problem how to load m_Picture by using Gdiplus::Graphics class inside the below function.
CPP / C++ / C Code:
void CLayer::MyDrawTransparent(CDC* pDC, int XDest, int YDest, int nDestWidth, int nDestHeight)
{
}

Any guidance shall he highly appreciated.

Thank you very much.
Bibhu
Last edited by LuciWiz : 25-Jun-2012 at 05:41. Reason: Please insert your C++ code between [cpp] & [/cpp] tags
 
 

Recent GIDBlogMatch IP in CIDR by gidnetwork

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
error C2064: term does not evaluate to a function taking 1 arguments AndyCharles C++ Forum 1 11-Sep-2011 10:45
Scope issues with derived class template in g++ Blake C++ Forum 1 04-Apr-2011 14:20
NetBeans - Inventory Program biglez123 Java Forum 1 23-Jan-2011 19:48
Class using another class blackxs C++ Forum 1 26-Nov-2010 06:19
RichEdit Demo Max Payne MS Visual C++ / MFC Forum 3 06-Oct-2004 07:19

Network Sites: GIDNetwork · GIDApp · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 13:03.


vBulletin, Copyright © 2000 - 2013, Jelsoft Enterprises Ltd.