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 08-May-2007, 05:48
Sujith Sujith is offline
New Member
 
Join Date: Jan 2007
Posts: 4
Sujith is on a distinguished road

Loading wrong images.


hi,
I am developing an application in which i am loading images to display it on the window. My problem is some of the images that are loaded gets replaced by images( such as standard checkbox, slider,combobox,editbox images etc.) I am using selectobject() and bitblt() functions to do these things. I heard if resource leaks are there this may happen, but right now i dont have any resource leaks,How can i fix this problem in my application,

Sujith

See the code below which has been added in the OnPaint() function;

CPP / C++ / C Code:
	CPaintDC objPaintdc(this); // device context for painting	
	BOOL	bRetVal = FALSE;

	CBitmap *pBmpOld = NULL;

	CDC objdc;

	// Creating a dc to paint the Dialog.
	bRetVal = objdc.CreateCompatibleDC(&objPaintdc);
	if(objdc.m_hDC == NULL)
	{
		OutputDebugString(_T("\n CPreferencesDlg::OnPaint() -     objdc.m_hDC object Failed"));
	}
	if(!bRetVal)
	{
		OutputDebugString(_T("\n CPreferencesDlg::OnPaint() -      objdc.CreateCompatibleDC() Failed"));
	}
	pBmpOld = objdc.SelectObject(&m_bmobjBackground);
	if(pBmpOld == NULL)
	{
		OutputDebugString(_T("\n CPreferencesDlg::OnPaint() - objdc.SelectObject(&m_bmobjBackground) Failed"));
	}
	
	bRetVal = objPaintdc.BitBlt(0,0,m_bmBitmapInfo.bmWidth,m_bmBitmapInfo.bmHeight,&objdc,0,0,SRCCOPY);		
	if(!bRetVal)
	{
		OutputDebugString(_T("\n CPreferencesDlg::OnPaint() - objPaintdc.BitBlt() Failed"));
	}

	objdc.SelectObject(pBmpOld);

	// Deleting the dc.
	bRetVal = objdc.DeleteDC();
	if(!bRetVal)
	{
		OutputDebugString(_T("\n CPreferencesDlg::OnPaint() - objdc.DeleteDC() Failed"));
	}
Last edited by LuciWiz : 08-May-2007 at 05:51. Reason: Please insert your C/C++ code between [cpp] & [/cpp] tags
 
 

Recent GIDBlogProgramming ebook direct download available by crystalattice

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
Loading several images simultaneously yashin MS Visual C++ / MFC Forum 0 08-Apr-2007 14:03
Scaling Images Richardknox MySQL / PHP Forum 2 01-Dec-2006 11:25
Downloading images WaltP Web Design Forum 3 30-Jul-2005 20:28
Functions and Classes - Where did I go wrong? redmage C++ Forum 5 10-Apr-2005 19:31
Why are my images distorted? rhino1616 Graphics Forum 0 27-Jun-2003 10:30

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

All times are GMT -6. The time now is 15:25.


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