Click here to Skip to main content
15,905,782 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Link error 2019 Pin
Cedric Moonen11-Jun-10 2:44
Cedric Moonen11-Jun-10 2:44 
GeneralRe: Link error 2019 Pin
arun_pk11-Jun-10 2:46
arun_pk11-Jun-10 2:46 
QuestionGlitchy mouse clicks out of sync. with position of caret in RichEdit control and text displayed incorrectly Pin
Robert Inventor10-Jun-10 23:36
Robert Inventor10-Jun-10 23:36 
AnswerRe: Glitchy mouse clicks out of sync. with position of caret in RichEdit control and text displayed incorrectly Pin
Code-o-mat12-Jun-10 5:16
Code-o-mat12-Jun-10 5:16 
GeneralRe: Glitchy mouse clicks out of sync. with position of caret in RichEdit control and text displayed incorrectly Pin
Robert Inventor12-Jun-10 6:25
Robert Inventor12-Jun-10 6:25 
GeneralRe: Glitchy mouse clicks out of sync. with position of caret in RichEdit control and text displayed incorrectly Pin
Code-o-mat12-Jun-10 7:00
Code-o-mat12-Jun-10 7:00 
GeneralRe: Glitchy mouse clicks out of sync. with position of caret in RichEdit control and text displayed incorrectly Pin
Robert Inventor12-Jun-10 15:18
Robert Inventor12-Jun-10 15:18 
GeneralRe: Glitchy mouse clicks out of sync. with position of caret in RichEdit control and text displayed incorrectly Pin
Robert Inventor12-Jun-10 15:34
Robert Inventor12-Jun-10 15:34 
Yes, with Purify, I got an unhandled access violation during start up.

I don't know if it is related. Possibly not, doesn't seem that likely after looking at it a bit closer.

Unfortunately the evaluation version doesn't show any more information, you have to buy it to find out the line of code etc, and the access violation doesn't happen with the normal debug or release build, only with the debug build when run under Purify. For that matter, doesn't happen with the release build under Purify.

But I managed to find the line of code by adding MessageBox statements and seeing where it happened. It happens here:

HBITMAP LoadPicture(LPCTSTR pszPath)
{
 if(pszPath[0]=='\0')
 return NULL;
 if(!FileExists((char *)pszPath))
 return NULL;
 if(!gis_NT_or_new_OS)
 if(bHasExt((char *)pszPath,".bmp"))
 {
  return (HBITMAP)LoadImage(hInstance,pszPath,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
 }
 {
  WCHAR wpath[AT_MAX_PATH];

  MultiByteToWideChar(CP_ACP, 0, pszPath, -1, wpath, AT_MAX_PATH);

  IPicture* pPic;
  #ifdef _DEBUG
  MessageBox(hwndFocus,"LoadPicture - call OleLoadPicturePath(..)","Debug",0);
  #endif
  OleLoadPicturePath(wpath, NULL, NULL, NULL, IID_IPicture,(LPVOID*)&pPic);
  #ifdef _DEBUG
  MessageBox(hwndFocus,"LoadPicture - after call OleLoadPicturePath(..)","Debug",0);
  #endif
  if(!pPic)
  return NULL;

  HBITMAP hPic = NULL;
  pPic->get_Handle((UINT*)&hPic);
  // http://windowssdk.msdn.microsoft.com/en-us/library/ms678485.aspx
  // The stream must be in BMP (bitmap), JPEG, WMF (metafile), ICO (icon), or GIF format.
  HBITMAP hPicRet = (HBITMAP)CopyImage(hPic, IMAGE_BITMAP, 0, 0, LR_COPYRETURNORG|LR_CREATEDIBSECTION);
  pPic->Release();
  return hPicRet;
 }
}


I put in extra messages to check that wpath was okay and it was. So can't see anything wrong with the code.

It is just "boilerplate code" and again I use it fine in my other programs - it is an easy way to load images in e.g. jpeg format, and documented somewhere on the MS website.

Anyway anyone notice anything wrong with this code?

I'll probably try an evaluation version of Insure++ which has good reviews to see if that gives more information - though it only lasts for I think 3 days so will need to be sure I have plenty of time to work on it during the evaluation period in case it takes a while for some reason.

Robert
GeneralRe: Glitchy mouse clicks out of sync. with position of caret in RichEdit control and text displayed incorrectly [modified] Pin
Robert Inventor12-Jun-10 15:35
Robert Inventor12-Jun-10 15:35 
GeneralRe: Glitchy mouse clicks out of sync. with position of caret in RichEdit control and text displayed incorrectly Pin
Code-o-mat12-Jun-10 23:08
Code-o-mat12-Jun-10 23:08 
GeneralRe: Glitchy mouse clicks out of sync. with position of caret in RichEdit control and text displayed incorrectly Pin
Robert Inventor13-Jun-10 5:40
Robert Inventor13-Jun-10 5:40 
GeneralRe: Glitchy mouse clicks out of sync. with position of caret in RichEdit control and text displayed incorrectly Pin
Code-o-mat13-Jun-10 5:53
Code-o-mat13-Jun-10 5:53 
GeneralRe: Glitchy mouse clicks out of sync. with position of caret in RichEdit control and text displayed incorrectly Pin
Robert Inventor13-Jun-10 10:50
Robert Inventor13-Jun-10 10:50 
GeneralRe: Glitchy mouse clicks out of sync. with position of caret in RichEdit control and text displayed incorrectly Pin
Code-o-mat13-Jun-10 11:14
Code-o-mat13-Jun-10 11:14 
GeneralRe: Glitchy mouse clicks out of sync. with position of caret in RichEdit control and text displayed incorrectly Pin
Robert Inventor20-Jun-10 6:03
Robert Inventor20-Jun-10 6:03 
GeneralRe: Glitchy mouse clicks out of sync. with position of caret in RichEdit control and text displayed incorrectly Pin
Code-o-mat20-Jun-10 7:43
Code-o-mat20-Jun-10 7:43 
GeneralRe: Glitchy mouse clicks out of sync. with position of caret in RichEdit control and text displayed incorrectly Pin
Robert Inventor3-Jul-10 6:30
Robert Inventor3-Jul-10 6:30 
GeneralRe: Glitchy mouse clicks out of sync. with position of caret in RichEdit control and text displayed incorrectly Pin
Code-o-mat3-Jul-10 6:43
Code-o-mat3-Jul-10 6:43 
QuestionMs PowerPoint Pin
MsmVc10-Jun-10 23:21
MsmVc10-Jun-10 23:21 
AnswerRe: Ms PowerPoint Pin
Cool_Dev10-Jun-10 23:55
Cool_Dev10-Jun-10 23:55 
GeneralRe: Ms PowerPoint [modified] Pin
MsmVc11-Jun-10 0:03
MsmVc11-Jun-10 0:03 
GeneralRe: Ms PowerPoint Pin
Cool_Dev11-Jun-10 0:18
Cool_Dev11-Jun-10 0:18 
GeneralRe: Ms PowerPoint Pin
MsmVc11-Jun-10 0:23
MsmVc11-Jun-10 0:23 
GeneralRe: Ms PowerPoint Pin
Cool_Dev11-Jun-10 0:41
Cool_Dev11-Jun-10 0:41 
GeneralRe: Ms PowerPoint Pin
MsmVc11-Jun-10 0:43
MsmVc11-Jun-10 0:43 

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.