Click here to Skip to main content
15,913,854 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionGDIObject leak in my MFC method Pin
earlgraham17-Nov-06 8:33
earlgraham17-Nov-06 8:33 
Every time this method get called I get another GDIObject. I cant figure out which object is causing it. The HBITMAP in the return is “DeleteObject” in the calling code. Any recommendations?

Here is my code examples

/*
 * Function: LoadSatRender
 * Copy the present window into the Bitmap and deletes the original file
 * Returns: Bitmap image
 */
HBITMAP CTE3dSatWebClient::LoadSatRender()
{
  BSTR       bitMapLocation;
  HBITMAP    SatBit;
  BSTR       noImagetest = SysAllocString(L"no image");
  LPCTSTR		 SatLoadFile;
  char      szBuffer[256];
  sprintf(szBuffer, "CTE3dSatWebClient::LoadSatRender running ");
  LogDebugInfo(szBuffer);

	if( !m_pSatMap )
		return 0;

  bitMapLocation = m_pSatMap->SaveImageToFile();
  if(bitMapLocation == noImagetest)
  {
    sprintf(szBuffer, "CTE3dSatWebClient::LoadSatRender LoadImage returned failure ");
    LogDebugInfo(szBuffer);
    return 0;
  }

  CString csTmpBuff = bitMapLocation;
  SatLoadFile = csTmpBuff;

  SatBit = (HBITMAP)LoadImage(0, SatLoadFile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_DEFAULTSIZE);
  sprintf(szBuffer, "CTE3dSatWebClient::LoadSatRender LoadImage Complete ");
  LogDebugInfo(szBuffer);

  remove(SatLoadFile);
  sprintf(szBuffer, "CTE3dSatWebClient::LoadSatRender SatLoadFile Removed ");
  LogDebugInfo(szBuffer);
  
  SysFreeString(bitMapLocation);
  SysFreeString(noImagetest);
  return SatBit;
}//END LoadSatRender




Thanks


Programmer
Glenn Earl Graham
Austin, TX

AnswerRe: GDIObject leak in my MFC method Pin
Steve Echols17-Nov-06 8:40
Steve Echols17-Nov-06 8:40 
GeneralRe: GDIObject leak in my MFC method Pin
earlgraham17-Nov-06 9:25
earlgraham17-Nov-06 9:25 
GeneralRe: GDIObject leak in my MFC method Pin
Steve Echols17-Nov-06 9:36
Steve Echols17-Nov-06 9:36 
GeneralRe: GDIObject leak in my MFC method Pin
earlgraham17-Nov-06 10:36
earlgraham17-Nov-06 10:36 
GeneralRe: GDIObject leak in my MFC method Pin
Steve Echols17-Nov-06 10:55
Steve Echols17-Nov-06 10:55 
GeneralRe: GDIObject leak in my MFC method Pin
earlgraham17-Nov-06 11:26
earlgraham17-Nov-06 11:26 
GeneralRe: GDIObject leak in my MFC method Pin
Mark Salsbery17-Nov-06 11:59
Mark Salsbery17-Nov-06 11:59 
GeneralRe: GDIObject leak in my MFC method Pin
Steve Echols17-Nov-06 12:09
Steve Echols17-Nov-06 12:09 
GeneralRe: GDIObject leak in my MFC method Pin
earlgraham17-Nov-06 14:06
earlgraham17-Nov-06 14:06 
QuestionWhat is the meaning of Window Properties Pin
sawerr17-Nov-06 8:29
sawerr17-Nov-06 8:29 
AnswerRe: What is the meaning of Window Properties Pin
Mark Salsbery17-Nov-06 10:31
Mark Salsbery17-Nov-06 10:31 
AnswerRe: What is the meaning of Window Properties Pin
Michael Dunn18-Nov-06 14:18
sitebuilderMichael Dunn18-Nov-06 14:18 
QuestionHow to make setfocus work Pin
prithaa17-Nov-06 8:14
prithaa17-Nov-06 8:14 
QuestionTime Zone String Abbreviation Pin
South_Bay_Girl17-Nov-06 6:47
South_Bay_Girl17-Nov-06 6:47 
AnswerRe: Time Zone String Abbreviation Pin
led mike17-Nov-06 7:22
led mike17-Nov-06 7:22 
GeneralRe: Time Zone String Abbreviation Pin
South_Bay_Girl17-Nov-06 9:11
South_Bay_Girl17-Nov-06 9:11 
QuestionRe: Time Zone String Abbreviation Pin
David Crow17-Nov-06 10:53
David Crow17-Nov-06 10:53 
QuestionUpgraded to 2005, now my code is broke. PLEASE HELP! Pin
Dustin Henry17-Nov-06 6:44
Dustin Henry17-Nov-06 6:44 
AnswerRe: Upgraded to 2005, now my code is broke. PLEASE HELP! Pin
Mark Salsbery17-Nov-06 6:49
Mark Salsbery17-Nov-06 6:49 
GeneralRe: Upgraded to 2005, now my code is broke. PLEASE HELP! Pin
Dustin Henry17-Nov-06 6:59
Dustin Henry17-Nov-06 6:59 
GeneralRe: Upgraded to 2005, now my code is broke. PLEASE HELP! Pin
Mark Salsbery17-Nov-06 7:00
Mark Salsbery17-Nov-06 7:00 
Questionhyperthreading Pin
vineeshV17-Nov-06 4:17
vineeshV17-Nov-06 4:17 
Questionthread demon Pin
zizzzz17-Nov-06 3:00
zizzzz17-Nov-06 3:00 
AnswerRe: thread demon Pin
toxcct17-Nov-06 3:25
toxcct17-Nov-06 3:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.