MoveWindow Exception in x64 but not in x86

I have a program that builds and runs fine under Visual Studio 2010 on Windows Server 2008 (32 bit). However, when I compile it for 64 bit, it fails on MoveWindow(). Here's a snippet of the code:

      // Set the size
      if(iWinTop < 0)
            rectWindow.top = 0;
      else
            rectWindow.top = iWinTop;

      if(iWinLeft < 0)
            rectWindow.left = 0;
      else
            rectWindow.left = iWinLeft;

      if(iWinBottom < 0)
            rectWindow.bottom += iWinTop;
      else
            rectWindow.bottom = iWinBottom;

      if(iWinRight < 0)
            rectWindow.right  += iWinLeft;
      else
            rectWindow.right = iWinRight;

      // Place the window
      MoveWindow(&rectWindow, TRUE);


The error that is returned is:
"Unhandled exception at 0x3fac6760 in Myprog.exe 0xC000041D: An unhandled exception was encountered during a user callback."
goondoo27Asked:
Who is Participating?
 
ssnkumarCommented:
Somewhere I read that, "adding the linker setting: /SECTION:.rsrc,rw" will resolve the problem.
Can you also try it and see if that solves your problem?
0
 
ssnkumarCommented:
If your problem is not solved with the above suggestions, try to disable hardware acceleration in Visual Studio. You can look at this page regarding how to do that: http://support.microsoft.com/kb/2023207

Also, somebody has seen that the problem occurs when Aero effects are turned on. Try to turn off Aero effects and check.
0
 
goondoo27Author Commented:
ssnkumar, thanks for all of the suggestions. It turns out that the problem was in a call back function:

static LRESULT CALLBACK SizingProc(HWND, UINT, WPARAM, LPARAM);

In this function I was using the routine PtrToLong(SizingProc) which was stripping the upper 32 bits from the 64 bit handle. Instead of that routine I used: reinterpret_cast<LONG_PTR>(SizigProc), and it works great on both 32 bit and 64 bit OSs.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.